DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

Jake Sarjeant
Jake Sarjeant

Posted on

#100DaysOfCode - Week 2

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.

Top comments (0)

๐ŸŒš Friends don't let friends browse without dark mode.

Sorry, it's true.