-
Notifications
You must be signed in to change notification settings - Fork 1
Schema
natedonato edited this page May 3, 2019
·
1 revision
Database Schema
Current Issues: not sure how images will be stored in database, not sure if through associations are necessary (users likes and photos)
Users
column name | datatype | details |
---|---|---|
id | integer | primary key |
username | string | not null indexed unique |
password_digest | string | not indexed null |
session_token | string | not null |
bio | text | |
full_name | string | |
text | ||
created_at | datetime | not null |
updated_at | datetime | not null |
User has many photos
has one attached profile_pic
has many likes
has many liked photos through likes
has many follows
has many followed_users through follows
has many users_following through follows
has many comments
photos
column name | datatype | details |
---|---|---|
id | integer | primary key |
poster_id | integer | not null indexed, foreign key (user) |
created_at | datetime | not null |
updated_at | datetime | not null |
photo belongs to user
has one attached pic
has many likes
has many comments
has many liking users through likes
photo likes
column name | data type | details |
---|---|---|
id | integer | not null, primary key |
user_id | integer | not null, indexed, foreign key |
photo_id | integer | not null, indexed, foreign key |
created_at | datetime | not null |
updated_at | datetime | not null |
like belongs to user
belongs to photo
comments
column name | data type | details |
---|---|---|
id | integer | not null, primary key |
user_id | integer | not null, indexed, foreign key |
photo_id | integer | not null, indexed, foreign key |
body | text | not null |
created_at | datetime | not null |
updated_at | datetime | not null |
comment belongs to user
belongs to photo
follow
column name | data type | details |
---|---|---|
id | integer | not null, primary key |
follower_id | integer | not null, indexed, foreign key |
followed_id | integer | not null, indexed, foreign key |
created_at | datetime | not null |
updated_at | datetime | not null |
belongs to following_user
belongs to followed_user