When building a new application, it is important to plan out your data model before diving into implementation. This approach ensures that you have a solid foundation on which you can build your application. In this module, you learn about the main entities in your application, plan the data model, and prepare your database.
A common way to plan your data model is to create an entity-relationship diagram (ERD). An ERD shows the different entities in your application and their properties. It also shows how the entities relate to each other.
In your simple application, you only have a single entity: Games. A Game represents a single time that a user has played a particular level in the game. It stores the user’s username, the level played, the timestamp of the game, and the user’s score in the game.
The ERD for your application is simple, since there is only one entity and no relationships. It is represented below.
You can see that your ERD contains the single entity -- Game -- and the various properties for that entity.
In the following steps, you translate your ERD into database code. First, you create the table to match your ERD. Then, you load some sample data into your database. Finally, you run some queries on your database to handle some of your use cases.
Time to Complete Module: 20 Minutes