Learning path

Full curriculum

Full curriculum

Unit content

Relational data model

The relational model represents structured data as relations. In practical database systems, a relation is presented as a table with rows and columns.

Rows and columns

Each column, or attribute, has a name and a domain of allowed values. Each row, or tuple, contains one value for each attribute.

For example:

users
id | name | active
1  | Ada  | true
2  | Lin  | false

The schema describes the attributes; the rows are the current data.

Rows are not inherently ordered

A mathematical relation is a set of tuples. The order in which a database happens to return rows has no guaranteed meaning unless a query explicitly requests an ordering.

Likewise, application concepts should not depend on a physical storage position for a row.

Values and NULL

SQL databases commonly support NULL to represent missing or unknown information. NULL is not an ordinary value such as zero or an empty string, and comparisons involving it follow special logic.

Relations connect through values

The relational model does not require one large nested object for everything. Separate relations can describe different entities and connect them through matching key values.

This separation allows data to be queried and recombined declaratively instead of being fixed into one permanent traversal structure.