Blog/News Data Models and APIs
Blog Schemas
Diagram example
Posts Table
Column | Type | Description |
---|---|---|
post_id | integer | Primary key for the post |
title | string | Title of the post |
content | text | Body content of the post |
author_id | integer | Foreign key to the users table for the author |
created_at | datetime | Timestamp of when the post was created |
updated_at | datetime | Timestamp of when the post was last updated |
Comments Table
Column | Type | Description |
---|---|---|
comment_id | integer | Primary key for the comment |
post_id | integer | Foreign key to the posts table for the commented post |
content | text | Body content of the comment |
author_id | integer | Foreign key to the users table for the comment author |
created_at | datetime | Timestamp of when the comment was created |
updated_at | datetime | Timestamp of when the comment was last updated |
Users Table
Column | Type | Description |
---|---|---|
user_id | integer | Primary key for the user |
username | string | Username for the user |
string | Email address of the user | |
password | string | Hashed password of the user |
created_at | datetime | Timestamp of when the user account was created |
updated_at | datetime | Timestamp of when the user account was last updated |
Tags Table
Column | Type | Description |
---|---|---|
tag_id | integer | Primary key for the tag |
name | string | Name of the tag |
created_at | datetime | Timestamp of when the tag was created |
updated_at | datetime | Timestamp of when the tag was last updated |
Post Tags Table
Column | Type | Description |
---|---|---|
post_tag_id | integer | Primary key for the post-tag relationship |
post_id | integer | Foreign key to the posts table for the tagged post |
tag_id | integer | Foreign key to the tags table for the tag |
created_at | datetime | Timestamp of when the relationship was created |
updated_at | datetime | Timestamp of when the relationship was last updated |
Images Table
Column | Type | Description |
---|---|---|
image_id | integer | Primary key for the image |
url | string | URL of the image file |
caption | string | Caption for the image |
created_at | datetime | Timestamp of when the image was added |
updated_at | datetime | Timestamp of when the image was last updated |