-
Notifications
You must be signed in to change notification settings - Fork 0
Database Schema
PavelAparcana edited this page Nov 13, 2019
·
5 revisions
| Column name | data type | details |
|---|---|---|
id |
integer | not null, primary key |
username |
string | not null, indexed, unique |
full_name |
string | not null |
email |
string | not null, indexed, unique |
password_digest |
string | not null |
session_token |
string | not null, indexed, unique |
- index on
username, unique: true - index on
email, unique: true - index on
session_token, unique: true -
has_manycomments -
has_manyauthored_likes -
has_manyimages -
has_manyin_follows, foreign_key:followee_id - followers table -
has_manyout_follows, foreign_key:follower_id - followers table -
has_manyfollowers(as a followeethrough in_follows - followers table -
has_manyfollowing(as a followerthrough out_follows - followers table -
has_manysent_messages, foreign_key:senders - messages table -
has_manyreceived_messages, foreign_key:recipient - messages table
Column name |
data type | details |
|---|---|---|
id |
integer | not null, primary key |
author_id |
integer | not null, indexed, foreign key |
image_url |
string | not null |
caption |
text |
- index on
user_id -
has_manycomments -
has_manylikes -
has_manyhashtags -
belongs_toauthor, foreign_key:author_id - users table
Column name |
data type | details |
|---|---|---|
id |
integer | not null, primary key |
author_id |
integer | not null, indexed |
image_id |
integer | not null, indexed |
body |
text | not null |
- indexed on
user_id - indexed on
image_id -
belongs_toauthor, foreign_key:author_id - users table -
belongs_toimage, foreign_key:image_id - images table
Column name |
data type | details |
|---|---|---|
id |
integer | not null, primary key |
user_id |
integer | not null, indexed |
image_id |
integer | not null, indexed |
- indexed on
user_id - indexed on
image_id -
belongs_toauthor, foreign_key:user_id - users table -
belongs_toimage, foreign_key:image_id - images table
Column name |
data type | details |
|---|---|---|
id |
integer | not null, primary key |
followee_id |
integer | not null, indexed |
follower_id |
integer | not null, indexed |
- indexed on
followee_id - indexed on
follower_id -
belongs_tofollowee, foreign_key:followee_id - users table -
belongs_tofollower, foreign_key:follower_id - users table
Column name |
data type | details |
|---|---|---|
id |
integer | not null, primary key |
sender_id |
integer | not null, indexed |
recipient_id |
integer | not null, indexed |
body |
text | not null |
- indexed on
sender_id - indexed on
recipient_id -
belongs_tosender, foreign_key:sender_id - users table -
belongs_torecipient, foreign_key:recipient_id - users table
Column name |
data type | details |
|---|---|---|
id |
integer | not null, primary key |
name |
string | not null, indexed |
image_id |
integer | not null, indexed |
- indexed on
name - indexed on
image_id -
belongs_toimage, foreign_key:image_id - images table