Postgres Database Schema - KevLin2358/Slickr GitHub Wiki
users
| column name | data type | details |
|---|---|---|
id |
integer | not null, primary key |
username |
string | not null, indexed, unique |
first_name |
string | not null, indexed |
last_name |
string | not null, indexed |
email |
string | not null, indexed, unique |
password_digest |
string | not null |
session_token |
string | not null, indexed, unique |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- indexed
usernamefirst_namelast_nameemailsession_token
usershas manyphotosusershas manyalbumsusershas manycommentsusershas manylikes
photos
| column name | data type | details |
|---|---|---|
id |
integer | not null, primary key |
uploader_id |
integer | not null, indexed, foreign_key |
title |
string | not null, indexed |
description |
text | |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- indexed
uploader_idtitle
uploader_idreferences from tableusersidphotosbelongs touploaderphotoshas manycomments
albums
| column name | data type | details |
|---|---|---|
id |
integer | not null, primary key |
owner_id |
integer | not null, indexed, foreign_key |
title |
string | not null, indexed |
description |
text | |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- indexed
user_idtitle
owner_idreferences from tableusersidalbumsbelongs toowner
album_photo
| column name | data type | details |
|---|---|---|
id |
integer | not null, primary key |
album_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 |
- indexed
album_idphoto_id
photo_idreferences from tablephotosidalbum_idreferences from tablealbumsid
likes
| column name | data type | details |
|---|---|---|
id |
integer | not null, primary key |
liker_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 |
-
indexed
liker_idphoto_id
-
liker_idreferences from tableusersid -
photo_idreferences from tablephotosid -
index on [:liker_id, :photo_id], unique: true
-
photo_idhas oneliker -
likesbelongsusers
comments
| column name | data type | details |
|---|---|---|
id |
integer | not null, primary key |
commenter_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 |
-
indexed
commenter_idphoto_id
-
commenter_idreferences from tableusersid -
photo_idreferences from tablephotosid -
commentsbelongs tophotos -
commentsbelongs tousers
tag
| column name | data type | details |
|---|---|---|
id |
integer | not null, primary key |
name |
string | not null |
created_at |
datetime | not null |
updated_at |
datetime | not null |
photo_tags
| column name | data type | details |
|---|---|---|
id |
integer | not null, primary key |
tag_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 |
-
indexed
tag_idphoto_id
-
tag_idreferences from tabletagsid -
photo_idreferences from tablephotosid
followers
| column name | data type | details |
|---|---|---|
id |
integer | not null, primary key |
followee_id |
integer | not null, indexed, foreign_key |
follower_id |
integer | not null, indexed, foreign_key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
indexed
followee_idfollower_id
-
followee_idandfollower_idreferences from tableusersid -
index on [:follower_id, :user_id], unique: true
-
followee_idhas onefollower_id