Recall & Review
beginner
What is a bidirectional relationship in a database context?
A bidirectional relationship means two data entities are connected so that each can access the other directly, like two friends who both know each other.
Click to reveal answer
beginner
How does a bidirectional relationship differ from a unidirectional relationship?
In a bidirectional relationship, both entities can reference each other. In a unidirectional relationship, only one entity knows about the other.
Click to reveal answer
intermediate
In GraphQL, how do you represent a bidirectional relationship between two types?
You add fields in both types that reference each other, for example, a User type with a posts field and a Post type with an author field pointing back to User.
Click to reveal answer
intermediate
Why are bidirectional relationships useful in data querying?
They allow easy navigation from one entity to the related entity in both directions, making queries more flexible and natural, like walking back and forth on a path.
Click to reveal answer
advanced
What is a common challenge when implementing bidirectional relationships?
Avoiding infinite loops or circular references when querying data, which can happen if each side keeps asking for the other endlessly.
Click to reveal answer
In a bidirectional relationship, which statement is true?
✗ Incorrect
Bidirectional means both sides know about and can access each other.
In GraphQL, how do you create a bidirectional relationship between User and Post?
✗ Incorrect
Both types need fields referencing each other to be bidirectional.
What problem can arise from bidirectional relationships in queries?
✗ Incorrect
Bidirectional links can cause queries to loop endlessly if not handled carefully.
Which of these is NOT a benefit of bidirectional relationships?
✗ Incorrect
Bidirectional relationships help navigation and queries but do not automatically validate data.
If User has many Posts and Post belongs to one User, what kind of relationship is this?
✗ Incorrect
User to Posts and Posts back to User is a bidirectional one-to-many relationship.
Explain what a bidirectional relationship is and why it is useful in databases.
Think about two friends who both know each other and can talk back and forth.
You got /3 concepts.
Describe how you would model a bidirectional relationship between two types in GraphQL.
Consider how each type points to the other in the schema.
You got /3 concepts.