Conceptual Model: Entity-Relationship Modelling (ERD), Crow’s Foot notation.
Logical Model: Convert conceptual model to detailed logical model ready for DB implementation.
Relational Model: Convert ER model to tables, apply Normalisation.
SQL: Use Relational Model to implement database.
Data Definition Language (DDL) defines the tables.
Data Manipulation Language (DML) queries/updates the tables.
Grouping of entities and relationships, especially when ERD is large.
Example: OFFERING (SEMESTER, COURSE, CLASS), LOCATION (ROOM, BUILDING).
Relation: two-dimensional table.
Tuples: rows.
Attributes: column headers.
Keys: identifiers for a row.
Schema: name of relation and its attributes.
Database schema: set of schemas for all relations in a database.
Data Dictionary (Metadata): describes schema details.
Unique name.
Unique attribute names.
Atomic attribute values.
Unique rows.
Irrelevant column order.
Irrelevant row order.
Describes schema details (table purpose, column data types) and other database objects.
CHAR, VARCHAR: Character strings.
INTEGER: Integer numbers.
NUMERIC, FLOAT: Decimal numbers.
DATE, TIME, TIMESTAMP: Date and time.
Primary Key: Unique identifier for a table.
Candidate Key: A set of columns that can uniquely identify rows.
Alternate Key: Candidate key not selected as primary key.
Foreign Key: Links to the primary key of another table.
Entity Integrity: Primary key must be unique and not NULL.
Referential Integrity: Foreign key must be NULL or match a primary key in the referenced table.
Domain Integrity: Data values must conform to predefined data type and constraints.
Translate entities (including composite entities) into relations (tables).
Attributes of the entity become attributes of the relation.
Translate relationships to FK links.
1:1 Unary/Recursive: Composite entity becomes a relation.
1:M Unary/Recursive: Use a recursive FK.
M:N Unary/Recursive: Composite entity to break down the relationship.
Avoid one big relation due to data integrity and storage space issues.
Avoid separate relations for each subtype, which scatters common attributes.
Create separate relations for each subtype and the supertype.
Used in e-commerce and invoicing to avoid repeated data.
ER entities become relational schemata.
Entity relationships become relational schema or FK references.
ER attributes become column headers.
Data Definition Language (DDL): CREATE, ALTER, DROP.
Data Manipulation Language (DML): SELECT, INSERT, UPDATE, DELETE.
Transaction Control Language (TCL): COMMIT, ROLLBACK, SAVEPOINT.
CREATE SCHEMA AUTHORIZATION Creator;
CREATE TABLE tablename (column1 data type [constraint], …);
PRIMARY KEY, FOREIGN KEY, NOT NULL, UNIQUE, DEFAULT, CHECK.
SELECT [DISTINCT | ALL] columnexpression [AS newname] [, …] FROM tablename [alias] [WHERE condition] [GROUP BY columnlist] [HAVING condition] [ORDER BY column_list];
=, <, <=, >, >=, <>, BETWEEN, LIKE, IN, EXISTS, ISNULL.
AND, OR, NOT.
Sort query results by column(s).