Database Models¶
The app relies on Flask-SQLAlchemy connected to an SQLite database. Below are the key data models and their relationships.
Entity Relationship Summary¶
erDiagram
USER ||--o{ POST : authors
USER ||--o{ COMMENT : writes
USER ||--o{ LIKE : gives
POST ||--o{ COMMENT : has
POST ||--o{ LIKE : receives
Models Details¶
User¶
- Fields:
id,username,email,password_hash,bio,is_admin,joined_at. - Relationships:
posts,comments,likes.
Post¶
- Fields:
id,title,slug,content,excerpt,category,published,author_id,created_at. - Relationships:
comments,likes. - Properties: Includes computed properties for
like_count,comment_count, andread_time.
Comment¶
- Fields:
id,content,author_id,post_id,created_at. - Connects a
User's thought to a specificPost.
Like¶
- Fields:
id,user_id,post_id. - Acts as a pure junction table linking a
UserandPostwith aUniqueConstrainton(user_id, post_id).