Junior — Middle
What types of relationships exist between entities in a database?
sobes.tech AI
Answer from AI
In databases, the following main types of relationships exist between entities:
-
One-to-One
- Each record in one table is related to one record in another.
- Example: each user has one profile.
-
One-to-Many
- One record in the first table is related to multiple records in the second.
- Example: one author can have many books.
-
Many-to-Many
- Records in one table are related to multiple records in another and vice versa.
- Implemented through an intermediate table.
- Example: students and courses — a student can attend many courses, and a course can have many students.
These relationships define how data is connected and how queries are constructed to retrieve related data.