Recall & Review
beginner
What is a one-to-one relationship in databases?
A one-to-one relationship means each record in one table is linked to exactly one record in another table, and vice versa.
Click to reveal answer
beginner
How do you represent a one-to-one relationship in GraphQL schema?
You use fields in types that reference each other, often with unique IDs to link exactly one record from one type to one record in another.
Click to reveal answer
intermediate
Why use one-to-one relationships instead of combining data in one type?
To keep data organized, avoid duplication, and separate concerns, especially when some data is optional or sensitive.
Click to reveal answer
intermediate
In GraphQL, how can you ensure a one-to-one relationship is enforced?
By using unique identifiers and resolvers that fetch exactly one related record, and by database constraints like unique foreign keys.
Click to reveal answer
beginner
Give a simple example of a one-to-one relationship in GraphQL types.
type User { id: ID! profile: Profile } type Profile { id: ID! user: User } Each User has one Profile and each Profile belongs to one User.
Click to reveal answer
What does a one-to-one relationship mean?
✗ Incorrect
A one-to-one relationship means each record in one table is linked to exactly one record in another table.
In GraphQL, how do you link two types in a one-to-one relationship?
✗ Incorrect
You link two types by adding a field in one type that references the other type.
Why might you separate data into two types with a one-to-one relationship?
✗ Incorrect
Separating data helps organize it and keeps sensitive or optional info separate.
Which database constraint helps enforce one-to-one relationships?
✗ Incorrect
A unique foreign key ensures each record links to only one record in the related table.
In a GraphQL one-to-one example, what does the User type typically contain?
✗ Incorrect
User type contains a field referencing Profile to show the one-to-one link.
Explain what a one-to-one relationship is and how you would model it in GraphQL.
Think about how each record links to exactly one record in another type.
You got /3 concepts.
Describe why one-to-one relationships are useful and give a simple GraphQL example.
Consider when you want to keep some data separate but connected.
You got /3 concepts.