-
Notifications
You must be signed in to change notification settings - Fork 0
schema
Kevin Chen edited this page Mar 21, 2022
·
9 revisions
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
username |
string | not null, indexed, unique |
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 |
- index on
username, unique: true
- index on
email, unique: true
- index on
session_token, unique: true
has_many posts
has_many follows
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
pet_name |
string | not null |
pet_gender |
string | not null |
pet_breed |
string | not null |
pet_age |
integer | not null |
author_id |
integer | not null, indexed, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
author_id
referencesusers
- index on
author_id
belongs_to author
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
user_id |
integer | not null, indexed, foreign key |
post_id |
integer | not null, indexed, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
user_id
referencesusers
-
post_id
referencesposts
- index on
[:post_id, :user_id], unique: true
belongs_to user
belongs_to post
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
body |
string | not null |
user_id |
integer | not null, indexed, foreign key |
receiver_id |
integer | not null, indexed, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
user_id
referencesuser
-
receiver_id
referencesuser
- index on
[:post_id, :user_id], unique: true
belongs_to user
belongs_to user
// We don't need a separate index for post_id or user_id because the first index adds it for us.