Recall & Review
beginner
What are nested resources in REST APIs?
Nested resources are resources that exist within the context of another resource, showing a parent-child relationship in the URL structure.
Click to reveal answer
beginner
Why use nested resources in REST API design?
They help organize related data clearly, making URLs more meaningful and showing how resources are connected, like comments belonging to a specific post.
Click to reveal answer
beginner
Example of a nested resource URL for comments of a post with ID 5?
/posts/5/comments
Click to reveal answer
intermediate
How does nesting resources affect HTTP methods like GET or POST?
HTTP methods operate on the nested resource within the parent context, for example, GET /posts/5/comments fetches comments for post 5, POST /posts/5/comments adds a comment to post 5.
Click to reveal answer
intermediate
What is a potential downside of deeply nested resources?
Too many nested levels can make URLs long and complex, which can be hard to read and maintain. It's best to keep nesting shallow.
Click to reveal answer
Which URL represents a nested resource for orders of a user with ID 10?
✗ Incorrect
The correct nested resource URL places the parent resource first, then the child: /users/10/orders.
What HTTP method would you use to add a new comment to a post in a nested resource?
✗ Incorrect
POST is used to create or add new resources, such as a comment under a post.
Why might you avoid very deep nesting in REST API URLs?
✗ Incorrect
Deep nesting can make URLs long and complicated, which is hard to read and maintain.
Which of these is NOT a benefit of nested resources?
✗ Incorrect
Nested resources improve URL clarity but do not automatically improve database performance.
In the URL /books/3/chapters/7, what is the parent resource?
✗ Incorrect
The parent resource is 'books' because chapters are nested inside a specific book.
Explain what nested resources are and give an example URL.
Think about how comments belong to posts in a blog.
You got /3 concepts.
Describe one advantage and one disadvantage of using nested resources in REST APIs.
Consider how URLs look and how easy they are to manage.
You got /2 concepts.