-
Notifications
You must be signed in to change notification settings - Fork 0
Database Schema
londelidess edited this page Aug 23, 2023
·
8 revisions
)
---------------------------------------------------------------------------|
| column name | data type | details |
---------------------------------------------------------------------------|
| id | integer | not null, primary key |
| username | string | not null, unique |
| email | string | not null, unique |
| hashed_password| string | not null (hashed) |
---------------------------------------------------------------------------|
-
Relationship
| posts | relationship | one-to-many with Post | | comments | relationship | one-to-many with Comment | | likes | relationship | one-to-many with Like | | followers | relationship | many-to-many with User (self-referential) | | following | relationship | many-to-many with User (self-referential) |
----------------------------------------------------------------------------------|
| column name | data type | details |
----------------------------------------------------------------------------------|
| id | integer | not null, primary key |
| content | string | not null |
| user_id | integer | not null, foreign key (references User) |
| post_date | integer | not null, foreign key (references User) |
----------------------------------------------------------------------------------|
-
user_id
referencesusers
table -
Relationship
| comments | relationship | one-to-many with Comment | | likes | relationship | one-to-many with Like |
----------------------------------------------------------------------------------|
| column name | data type | details |
----------------------------------------------------------------------------------|
| id | integer | not null, primary key |
| content | string | not null |
| user_id | integer | not null, foreign key (references User) |
| post_id | integer | not null, foreign key (references Post) |
----------------------------------------------------------------------------------|
-
user_id
referencesusers
table -
post_id
referencesposts
table
----------------------------------------------------------------------------------|
| column name | data type | details |
----------------------------------------------------------------------------------|
| id | integer | not null, primary key |
| user_id | integer | not null, indexed, foreign key (references User) |
| post_id | integer | not null, indexed, foreign key (references Post) |
----------------------------------------------------------------------------------|
-
user_id
referencesusers
table -
post_id
referencesposts
table
----------------------------------------------------------------------------------|
| column name | data type | details |
----------------------------------------------------------------------------------|
| id | integer | not null, primary key |
| follower_id | integer | not null, indexed, foreign key (references User) |
| followed_id | integer | not null, indexed, foreign key (references User) |
----------------------------------------------------------------------------------|
-
follower_id
referencesusers
table -
followed_id
referencesusers
table
--------------------------------------------------------------------------------------|
| column name | data type | details |
--------------------------------------------------------------------------------------|
| id | integer | not null, primary key |
| post_id | integer | not null, indexed, foreign key (references posts) |
| media_type | string | not null (e.g., 'image', 'video') |
| media_url | string | not null (URL to where the media is stored) |
--------------------------------------------------------------------------------------|
-
post_id
referencesposts
table