Recall & Review
beginner
What does the
hasMany association represent in Express ORM?It means one record in a model can be linked to many records in another model, like one author having many books.
Click to reveal answer
beginner
What is the purpose of the
belongsTo association?It shows that a record belongs to exactly one record in another model, like a book belonging to one author.
Click to reveal answer
intermediate
How do
hasMany and belongsTo work together?They connect two models so you can find all related records easily, like getting all books for an author and the author for a book.
Click to reveal answer
beginner
In Express, where do you usually define
hasMany and belongsTo?You define them in your model files to set up relationships before querying the database.
Click to reveal answer
beginner
Why are associations like
hasMany and belongsTo helpful?They let you write simpler code to get related data without writing complex database queries.Click to reveal answer
Which association means one record owns many records in another model?
✗ Incorrect
hasMany means one record owns many records in another model.
If a Book
belongsTo an Author, what does that mean?✗ Incorrect
belongsTo means the book is linked to one author.
Where do you define associations like
hasMany in Express?✗ Incorrect
Associations are set up in model files to define relationships.
What benefit do associations provide when querying data?
✗ Incorrect
Associations simplify getting related data without complex queries.
Which association would you use if one user can have many posts?
✗ Incorrect
hasMany fits when one user owns many posts.
Explain how
hasMany and belongsTo associations work together in Express models.Think about how authors and books relate.
You got /4 concepts.
Describe why setting up associations like
hasMany and belongsTo is useful in building Express apps.Consider how you get all posts for a user.
You got /4 concepts.