1. The relational model
A relation is a set of tuples over a schema ; each attribute takes values from a domain. In a table: columns are attributes, rows are tuples.
- Degree (arity): number of attributes. Cardinality: number of tuples.
- A relation is a set: no duplicate tuples, and the order of rows does not matter. (SQL tables are multisets, so duplicates may appear.)
- Values are atomic (first normal form).
Keys. A superkey is any set of attributes whose values are unique across tuples. A candidate key is a minimal superkey. One candidate key is chosen as the primary key (no NULLs allowed). A foreign key in refers to the primary key of : every non-null foreign-key value must appear in (referential integrity).
Useful counts: with attributes and one candidate key of attributes, the number of superkeys containing it is .
The relational query languages are relational algebra (procedural: says how), tuple relational calculus (declarative: says what) and SQL, which is based on both. Basic relational algebra and safe relational calculus have the same expressive power (Codd's theorem); neither can express transitive closure or aggregates.