Recall & Review
beginner
What does a OneToMany relation represent in NestJS with TypeORM?
It means one entity instance can be linked to many instances of another entity. For example, one author can have many books.
Click to reveal answer
beginner
Explain the ManyToOne relation in NestJS.
Many instances of an entity relate to one instance of another entity. For example, many books belong to one author.
Click to reveal answer
intermediate
How does a ManyToMany relation work in NestJS?
It connects many instances of one entity to many instances of another. For example, many students can enroll in many courses.
Click to reveal answer
intermediate
In NestJS, which decorator is used to define the owner side of a ManyToOne relation?
The @ManyToOne decorator is used on the owner side, which holds the foreign key to the related entity.
Click to reveal answer
intermediate
What is the purpose of the @JoinTable() decorator in a ManyToMany relation?
It marks the owner side of the ManyToMany relation and creates a join table to store the relation links.
Click to reveal answer
Which decorator defines a one-to-many relation in NestJS with TypeORM?
✗ Incorrect
The @OneToMany decorator defines a one-to-many relation where one entity relates to many others.
In a ManyToOne relation, where is the foreign key stored?
✗ Incorrect
The foreign key is stored on the entity that has the ManyToOne decorator, which is the owner side.
What does the @JoinTable() decorator do in a ManyToMany relation?
✗ Incorrect
@JoinTable() creates a join table that stores the links between the two entities in a ManyToMany relation.
Which relation type allows many instances of one entity to relate to many instances of another?
✗ Incorrect
ManyToMany relations connect many instances of one entity to many instances of another.
If an Author has many Books, which decorator would you use on the Author entity?
✗ Incorrect
The Author entity uses @OneToMany to show it has many Books.
Describe how to set up a OneToMany and ManyToOne relation between two entities in NestJS.
Think about how one author can have many books and how each book belongs to one author.
You got /4 concepts.
Explain the role of @JoinTable in a ManyToMany relation and which side should have it.
Imagine a table that connects students and courses they attend.
You got /4 concepts.