Recall & Review
beginner
What is a many-to-many relationship in databases?
A many-to-many relationship happens when multiple records in one table relate to multiple records in another table. For example, students can enroll in many courses, and courses can have many students.
Click to reveal answer
beginner
How do many-to-many relationships get represented in a database?
They are represented using a join table (also called a junction or linking table) that holds foreign keys from both related tables. This table connects the records from both sides.
Click to reveal answer
intermediate
In GraphQL, how can you model a many-to-many relationship between two types?
You create two types and include a list field in each type that references the other type. The actual linking is handled in the database, often with a join table.
Click to reveal answer
beginner
Why is a join table necessary for many-to-many relationships?
Because relational databases cannot directly link many records to many others without an intermediate table to store each pair of related records.
Click to reveal answer
intermediate
Give a simple GraphQL schema example showing many-to-many between Authors and Books.
type Author {
id: ID!
name: String!
books: [Book!]!
}
type Book {
id: ID!
title: String!
authors: [Author!]!
}
Click to reveal answer
What does a join table in a many-to-many relationship typically contain?
✗ Incorrect
A join table contains foreign keys from both tables to link their records.
In GraphQL, how do you represent a many-to-many relationship between two types?
✗ Incorrect
You add a list field of the related type in each type to represent many-to-many.
Why can't relational databases directly store many-to-many relationships without a join table?
✗ Incorrect
Many-to-many relationships require an intermediate join table to link records.
Which of these is an example of a many-to-many relationship?
✗ Incorrect
Students and courses relate many-to-many because both sides can have multiple connections.
In a GraphQL schema, what type of field would you use to show multiple related records?
✗ Incorrect
Lists in GraphQL represent multiple related records.
Explain how many-to-many relationships work and how they are represented in databases and GraphQL.
Think about students and courses as an example.
You got /4 concepts.
Describe why a join table is necessary and how it connects two tables in a many-to-many relationship.
Imagine a table that stores pairs of IDs.
You got /4 concepts.