Middle+
What types of relationships between tables do you know?
sobes.tech AI
Answer from AI
Main types of relationships between tables in relational databases:
-
One-to-one (1:1)
- Each record in the first table is related to one record in the second table and vice versa.
- Example: the
Userstable and theProfilestable, where each user has one profile.
-
One-to-many (1:N)
- One record in the first table is related to multiple records in the second table.
- Example: the
Authorstable and theBookstable, where one author can have many books.
-
Many-to-many (N:M)
- Records in the first table can be related to multiple records in the second table and vice versa.
- Implemented through an intermediate (linking) table.
- Example: the
Studentstable and theCoursestable, where a student can attend multiple courses, and a course can have many students.
Each type of relationship is implemented through keys (primary and foreign) and ensures data integrity and proper organization of information.