Designing a RESTful API to interact with a complex PostgreSQL 10.5 database
So far, our Django-based RESTful API performed CRUD operations on a single database table in an SQLite database. Now, we want to create a more complex RESTful API with Django REST Framework to interact with a complex database model that has to allow us to register player scores for playing games that are grouped into ESRB ratings. In our previous RESTful API, we used a string field to specify the ESRB rating for a game. In this case, we want to be able to easily retrieve all the games that have a specific ESRB rating, and therefore, we will have a relationship between a game and an ESRB rating.
We must be able to perform CRUD operations on different related resources and resource collections. The following table enumerates the resources and the class name we will create to represent the model with Django REST Framework:
Resources | Class name that represents the model |
ESRB ratings |
|
Games |
|
Players |
|
Player... |