Relational Concepts & SQL
Tables, rows and columns · normalization · primary and foreign keys · DDL, DCL and DML · views, stored procedures and indexes
By the tools4free.dev team · Last reviewed November 13, 2026
Practice questions for this topic →
Relational data
- A relational database models collections of real-world entities as tables. A row represents a single instance of an entity.
- Relational tables are a format for structured data, and each row has the same columns. A column can be empty (NULL), for example a MiddleName column.
- Each column stores data of a specific datatype: text, decimal numbers, integers, date/time values and so on. Most database systems support the standard datatypes defined by ANSI; the available types depend on the database system.
Normalization
Normalization is a schema design process that minimizes data duplication and enforces data integrity. A simple practical definition:
- Separate each entity into its own table.
- Separate each discrete attribute into its own column.
- Uniquely identify each entity instance (row) using a primary key.
- Use foreign key columns to link related entities.
- Each entity instance is one row in its own table, so duplication is removed. To change a customer's address, you modify a single row.
- Individual columns constrain each value to an appropriate data type and allow filtering, for example customers in a specific city.
- A foreign key holds the primary key of a related entity. Typically, a relational database management system (RDBMS) can enforce referential integrity, so a foreign key value must have a corresponding primary key in the related table (no orders for nonexistent customers).
- A key can be a composite key built from a unique combination of multiple columns, such as OrderNo and ItemNo for a line item.
SQL statement types
SQL (Structured Query Language) is the standard language for relational database management systems. Statements are grouped into three main logical groups.
| Group | Purpose | Statements |
|---|---|---|
| DDL (Data Definition Language) | Create, modify and remove tables and other objects | CREATE, ALTER, DROP, RENAME |
| DCL (Data Control Language) | Manage access by granting, denying or revoking permissions | GRANT, DENY, REVOKE |
| DML (Data Manipulation Language) | Manipulate the rows in tables | SELECT, INSERT, UPDATE, DELETE |
SELECT,UPDATEandDELETEapply to every row by default. Use a WHERE clause so only matching rows are selected, updated or deleted. Without WHERE,UPDATEmodifies every row andDELETEremoves every row. SQL doesn't ask "are you sure?".DROPpermanently removes an object. Dropping a table loses all its rows, and unless you have a backup you can't retrieve them.- Rows from a query come back in no specific sequence unless you add ORDER BY. A JOIN clause retrieves data from multiple tables, typically matching a foreign key in one table to its primary key in the other.
- Columns marked
NOT NULLare mandatory. Each table should have a primary key, although SQL doesn't enforce this rule.
| Dialect | Used by |
|---|---|
| Transact-SQL (T-SQL) | Microsoft SQL Server, Azure SQL Database, Azure SQL Managed Instance and SQL Server on Azure Virtual Machines |
| PL/pgSQL | PostgreSQL (procedural language dialect) |
| PL/SQL | Oracle (Procedural Language/SQL) |
Example: SELECT FirstName, LastName, Address, City FROM Customer WHERE City = 'Seattle' ORDER BY LastName;
Database objects
| Object | What it is |
|---|---|
| View | A virtual table based on the results of a SELECT query. You can query and filter it much like a table. |
| Stored procedure | SQL statements that can be run on command, used to encapsulate programmatic logic in the database. It can take parameters. |
| Index | Helps you search for data in a table. It holds a copy of a column's data in sorted order, with pointers to the rows, so the system can fetch data faster than scanning the whole table. |
Indexes aren't free. An index consumes storage space, and indexes must be maintained on every insert, update or delete, which can slow those operations. For a table with few rows an index is probably not more efficient than reading the whole table.
Exam Tips
Tick each tip once you can answer it without looking.
“Every row has the same columns; a person has no middle name” → The MiddleName column is empty (NULL). Trap: Rows can't have different sets of columns.
“Schema design that minimizes data duplication and enforces integrity” → Normalization. Trap: An index speeds up searching; it doesn't remove duplication.
“Entity to table, attribute to column, row identified by primary key, foreign key to link” → The simple steps of normalization. Trap: Don't put several attributes into one column or repeat entity details on every row.
“Column that holds the primary key of a related table” → Foreign key. Trap: A composite key is built from several columns of the same table.
“Key made from a unique combination of multiple columns, such as OrderNo and ItemNo” → Composite key. Trap: A primary or foreign key can itself be composite.
“Stop orders for nonexistent customers” → Referential integrity (foreign key value must match a primary key). Trap: Referential integrity is about a foreign key value matching an existing primary key in the related table.
“CREATE, ALTER, DROP, RENAME” → DDL (objects and structure). Trap: SELECT, INSERT, UPDATE and DELETE are DML; GRANT, DENY and REVOKE are DCL.
“GRANT, DENY, REVOKE” → DCL (permissions). Trap: DCL manages access; it doesn't change rows or structure.
“SELECT, INSERT, UPDATE, DELETE” → DML (rows). Trap: CREATE and DROP act on objects, so they are DDL.
“UPDATE or DELETE with no WHERE clause” → Every row in the table is changed or removed. Trap: SQL has no "are you sure?" prompt.
“DROP TABLE” → Permanently removes the table and all its rows; only a backup can bring the data back. Trap: DELETE removes rows; DROP removes the object.
“Rows returned in no particular order, sort by a column” → ORDER BY. Trap: WHERE filters rows; it doesn't sort.
“Virtual table based on a SELECT query” → View. Trap: A stored procedure runs statements on command; an index is a sorted copy of column data.
“Named SQL statements run on command, with parameters” → Stored procedure. Trap: A view is queried much like a table; a stored procedure is the object that runs on command.
“Look up rows faster by a column, at the cost of storage and slower writes” → Index. Trap: Don't add indexes freely: each insert, update or delete must maintain them.
“T-SQL, PL/pgSQL, PL/SQL” → SQL Server and Azure SQL, PostgreSQL, Oracle. Trap: Vendors add proprietary extensions beyond the SQL standard, which is why dialects exist.
Sources
Checked against Microsoft Learn on November 13, 2026.