DevPath · Learn to code ESPTEN

Project: full-stack blog

The plan: modeling a blog

A blog is, above all, data

Behind any blog there are two entities that relate to each other:

This is a one-to-many (1:N) relationship: a post has many comments, but each comment belongs to a single post. The post_id column of the comments table is the foreign key that materializes that relationship.

posts ──< (post_id) comments
  1                    N

The slug: a readable URL

A post's title is for people: "My first post". But a URL with spaces and accents is fragile. That's why we generate a slug: a version of the title suitable for URLs, in lowercase and with hyphens instead of spaces.

"Learning SQL"  →  /posts/learning-sql

The slug is stable and unique: even if you change the visible title, the link can keep working. And it's readable, which helps people and SEO.

Pagination: don't load it all

A blog with hundreds of posts can't send them all at once. Pagination splits the listing into pages of a fixed size (e.g. 10 per page) and the client requests the one it wants: /posts?page=2. In SQL this is LIMIT + OFFSET; in JavaScript, a slice over the array.

Put this into practice

DevPath is a hands-on course: you read the theory here; in the app you put it into practice with exercises that really run, offline.

Start free in the app →
From data to the screen →