Junior — Middle
Can you list the main types of relationships between tables in a relational database?
sobes.tech AI
Answer from AI
In relational databases, there are three main types of relationships between tables:
-
One-to-One — each record in the first table corresponds to exactly one record in the second table and vice versa. Used when data is logically separated but directly related.
-
One-to-Many — one record in the first table corresponds to many records in the second. For example, one user can have many orders.
-
Many-to-Many — records in the first table can correspond to many records in the second and vice versa. Implemented through an intermediate join table that stores pairs of keys from both tables.
These relationships provide structured data storage and efficient data linking in the database.