Let's try to determine our models from the preceding specifications. Post is obviously a model, as it is the main feature of our blog (we display posts). Each post is created and updated by an authenticated user, meaning that users have to be saved into the database; therefore, we also have a User model. There can be posts without comments, and categories without any posts, meaning they belong to distinct models; therefore, there is also a Category and a Comment model.
That sums up to four models:
Post: This model has the following properties: title, small description, content, and publication date. A post is linked to a unique category and each category has many posts, so we will add an additional column here, named
category_id
. Similarly, each post belongs to a user (the author), so we will add theuser_id
column.Category: This model only has a name property.
Comment: This model has the following properties: name, email, status and...