-
Notifications
You must be signed in to change notification settings - Fork 0
Database Schema
Aaron Agarunov edited this page Dec 28, 2017
·
8 revisions
Column Name | Data Type | Constraints |
---|---|---|
id |
integer | not null, pkey |
username |
string | not null, index, unique |
password_digest |
string | not null |
session_token |
string | not null, index, unique |
profile_photo |
string | |
bio |
text | |
location |
string | |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
profile_photo
is a custom upload that isn't available for editing or viewing on the user's profile, but can be replaced by uploading another profile photo
Column Name | Data Type | Constraints |
---|---|---|
id |
integer | not null, pkey |
author_id |
integer | not null, index, fkey |
photo_url |
string | not null |
title |
string | |
description |
text | |
is_cover_photo |
boolean | default: false, unique for author_id
|
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
author_id
referencesusers
- when
is_cover_photo
is true, theauthor_id
is using the photo as their cover photo- a user
has_one cover_photo -> { where is_cover_photo: true }
(has_one
scoping)
- a user
Column Name | Data Type | Constraints |
---|---|---|
id |
integer | not null, pkey |
follower_id |
integer | not null, index, fkey |
followee_id |
integer | not null, index, fkey |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
follower_id
andfollowee_id
referenceusers
- unique index on
follower_id
andfollowee_id
Column Name | Data Type | Constraints |
---|---|---|
id |
integer | not null, pkey |
author_id |
integer | not null, index, fkey |
photo_id |
integer | not null, index, fkey |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
author_id
referencesusers
-
photo_id
referencesphotos
- unique index on
author_id
andphoto_id
Column Name | Data Type | Constraints |
---|---|---|
id |
integer | not null, pkey |
name |
string | not null, unique |
created_at |
datetime | not null |
updated_at |
datetime | not null |
Column Name | Data Type | Constraints |
---|---|---|
id |
integer | not null, pkey |
photo_id |
integer | not null, index, fkey, unique |
tag_id |
integer | not null, index, fkey, unique |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- unique index on
tag_id
andphoto_id
- index on
photo_id