Relations
Relations connect records across different tables.
While tables store different types of information and columns describe their attributes, relations define how those records are linked together.
This allows the system to store information once and reuse it wherever it is needed.
For example:
- A booking can be linked to the person who made it.
- A room can be linked to the building where it is located.
- An employee can be linked to the department they belong to.
Without relations, the same information would often need to be stored repeatedly in many places.
For example, every booking might store a person's name, phone number, and email address. If that person changes their phone number, all those records would need to be updated individually.
By linking records instead, the information is stored once and reused everywhere it is referenced.
What a relation represents
A relation defines a connection between two tables.
When a relation exists, rows in one table can reference rows in another table.
This allows the system to link related information together.
For example, instead of storing a person's name inside every booking record, the booking can reference the corresponding row in the Person table.
This keeps information consistent and easier to maintain.
Direction
Relations have a defined direction between the two tables.
This direction determines how the system moves from one record to another when evaluating logic or navigating related data.
For example, a booking may reference a person, meaning the system can move from the booking to the associated person.
Cardinality
Relations also define how many records can be connected across the link.
Common patterns include:
- one to one – each record connects to at most one record on the other side
- one to many – one record may connect to multiple records
- many to one – many records connect to a single record
- many to many – multiple records connect to multiple records
These patterns describe the structure of the relationship between the two tables.
Related resources
Reference
Related concepts