Blog Platform — Database Schema

ER diagram — tables, fields, and relationships

erDiagram USER { int id PK string email UK string username UK string name string avatarUrl string bio datetime createdAt } POST { int id PK int authorId FK int categoryId FK string title string slug UK text content string status datetime publishedAt int viewCount } CATEGORY { int id PK string name UK string slug UK string description } TAG { int id PK string name UK string slug UK } POST_TAG { int postId FK int tagId FK } COMMENT { int id PK int postId FK int authorId FK int parentId FK text body bool approved datetime createdAt } LIKE { int postId FK int userId FK datetime likedAt } USER ||--o{ POST : "writes" USER ||--o{ COMMENT : "authors" USER ||--o{ LIKE : "gives" POST ||--o{ COMMENT : "receives" POST ||--o{ LIKE : "receives" POST }o--|| CATEGORY : "belongs to" POST ||--o{ POST_TAG : "tagged with" TAG ||--o{ POST_TAG : "applied to" COMMENT ||--o{ COMMENT : "replies to"