One-to-One (1:1): Each record in Table A is linked toonly one record in Table B, and vice versa.
One-to-Many (1:M): A record in Table A can be linked to multiple records in Table B, but each record in Table B is linked to only one record in Table A.
Many-to-Many (M:N): Records in Table A can be linked to multiple records in Table B, and vice versa.
Example
One-to-one relationship:
A person has one passport, a passport belongs to one person.
Tables: Person and Passport
PersonID
Name
PassportID
1
Alice
101
2
Bob
102
PassportID
IssueDate
101
2020-01-01
102
2021-02-15
One-to-Many relationship:
A teacher can have many students, but each student has only one teacher.
Tables: Teacher and Student
TeacherID
Name
1
Mr. Smith
2
Ms. Johnson
StudentID
Name
TeacherID
101
Alice
1
102
Bob
1
103
Charlie
2
Many-to-many relationship:
Students enroll in multiple courses, and courses have multiple students.
Tables: Student, Course, and Enrollment (junction table)
StudentID
Name
101
Alice
102
Bob
CourseID
Title
201
Math
202
Science
StudentID
CourseID
101
201
101
202
102
201
How Relationships are Represented
Foreign Keys: A foreign key in one table references the primary key in another, establishing a link between records.
Junction Tables: In many-to-many relationships, a junction table is used to break the relationship into two one-to-many relationships.
End of article
Flashcards
Remember key concepts with flashcards
15 flashcards
What is the difference between foreign keys and junction tables?
Lesson
Recap your knowledge with an interactive lesson
9 minute activity
Unlock the rest of this chapter with aFreeaccount
Nice try, unfortunately this paywall isn't as easy to bypass as you think. Want to help devleop the site? Join the team at https://revisiondojo.com/join-us. exercitation voluptate cillum ullamco excepteur sint officia do tempor Lorem irure minim Lorem elit id voluptate reprehenderit voluptate laboris in nostrud qui non Lorem nostrud laborum culpa sit occaecat reprehenderit
Definition
Paywall
(on a website) an arrangement whereby access is restricted to users who have paid to subscribe to the site.
anim nostrud sit dolore minim proident quis fugiat velit et eiusmod nulla quis nulla mollit dolor sunt culpa aliqua
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Note
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam quis nostrud exercitation.
Excepteur sint occaecat cupidatat non proident
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit.
Hint
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum.
Note
Introduction to Database Relationships
In relational databases, relationships define how tables are connected to each other.
They help organize data efficiently and maintain data integrity.
AnalogyThink of database relationships like connections between people on social media platforms. Just as you can have different types of connections (friends, followers, etc.), databases have different types of relationships between tables.
DefinitionDatabase RelationshipA connection between two or more tables that defines how data in one table relates to data in another.
ExampleIn a school database, a relationship might exist between the 'Students' table and the 'Courses' table to show which students are enrolled in which courses.