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
username
first_name
last_name
email
session_token
users
has manyphotos
users
has manyalbums
users
has manycomments
users
has 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_id
title
uploader_id
references from tableusers
id
photos
belongs touploader
photos
has 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_id
title
owner_id
references from tableusers
id
albums
belongs 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_id
photo_id
photo_id
references from tablephotos
id
album_id
references from tablealbums
id
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_id
photo_id
-
liker_id
references from tableusers
id
-
photo_id
references from tablephotos
id
-
index on [:liker_id, :photo_id], unique: true
-
photo_id
has oneliker
-
likes
belongsusers
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_id
photo_id
-
commenter_id
references from tableusers
id
-
photo_id
references from tablephotos
id
-
comments
belongs tophotos
-
comments
belongs 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_id
photo_id
-
tag_id
references from tabletags
id
-
photo_id
references from tablephotos
id
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_id
follower_id
-
followee_id
andfollower_id
references from tableusers
id
-
index on [:follower_id, :user_id], unique: true
-
followee_id
has onefollower_id