post_likes table

The post_likes table in the Social Media Database Schema schema has 3 columns, with 2 foreign keys to posts and users.

The composite primary key is what makes a like idempotent. Never store a like as a counter alone.

Columns (3)

Columns of the post_likes table
ColumnTypeConstraintsDescription
post_iduuidnot null, references posts.id
user_iduuidnot null, references users.id
created_attimestamptznot null

Indexes (1)

  • (user_id, created_at)

Relationships