Some of you might have noticed that I haven't put out any new posts for a while. This is because I've had a lot of work to do for school, so I don't have time to write a post and code every day. It's either one or the other. To make up for this, I've decided to put out one post each week now, for the next 12 weeks (100/7 ≈ 14, and this is week 2). Also, this gives me a lot more to talk about.
This week, I created an area on the home page to show the newest 10 posts. A post can be liked by clicking the heart icon to the right side. To create a relationship between users and posts, the database contains a table 'likes' with two columns: 'user' and 'post'. The column 'user' points to the 'username' column of the 'users' table, and 'post' to the 'id' column of the 'posts' table.
Since this relationship is hard to enforce using foreign keys, I decided to only have the 'user' column be a foreign key.
Also, I created an option to order posts by likes instead of the latest time.