Relational Databases, Keys & ERDs

A relational database organises data into related tables that are linked using keys. This lesson explains how primary and foreign keys connect tables, how entity-relationship diagrams show the relationships, and how this reduces redundancy and inconsistency.

Key terms

Relational database
A database made of tables that are linked to each other using keys.
Entity
A real-world object or concept that data is stored about, such as a student.
Primary key
A field (or fields) that uniquely identifies each record in a table.
Foreign key
A field in one table that is the primary key of another table, creating a link between them.
Referential integrity
Every foreign key value must match an existing primary key value, so there are no broken links.
One-to-one relationship
One record in table A relates to exactly one record in table B.
One-to-many relationship
One record in table A can relate to many records in table B.
Many-to-many relationship
Records in each table can relate to many records in the other. It is resolved with a linking table.
Cardinality
The number of records on each side of a relationship: one-to-one, one-to-many or many-to-many.
Entity-relationship (ER) diagram
A diagram showing the entities in a database and the relationships between them.

Part of Databases.