-
Notifications
You must be signed in to change notification settings - Fork 0
Schema
thedanielcho edited this page May 10, 2021
·
2 revisions
| column name | data type | details |
|---|---|---|
id |
integer | not null, primary key |
email |
string | not null, indexed, unique |
display_name |
string | not null, indexed |
password_digest |
string | not null |
session_token |
string | not null, indexed, unique |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- Index on
email,display_name, andsession_token-
display_nameis indexed for searching users
-
- Uniqueness on
emailandsession_token - A
usercan have manychannelsas an admin, and can belong to manychannelsas a member - A
usercan have manymessages
| column name | data type | details |
|---|---|---|
id |
integer | not null, primary key |
name |
string | not null, indexed |
description |
string | |
admin_id |
integer | not null, indexed, foreign key |
public |
boolean | not null |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- Index on
nameandadmin_id-
nameis indexed for searching channels
-
-
publicdefaults to true - A
channelcan have manyusersand manymessagesthroughusers - A
channelbelongs to auserthroughadmin_id
| column name | data type | details |
|---|---|---|
id |
integer | not null, primary key |
user_id |
integer | not null, foreign key, indexed |
messageable_id |
integer | not null, foreign key, indexed |
messageable_type |
string | not null |
body |
string | not null |
created_at |
datetime | not null, indexed |
updated_at |
datetime | not null |
- Index on
user_id,messageable_id, andcreated_at - A
messagebelongs to auserthroughuser_id - A
messagebelongs to achannelordirect_messagethrough themessageable_idandmessageable_type- Can also belong to a
threadif I reach the bonus
- Can also belong to a
-
messageable_typecan be eitherchannelordirect_message- Can also be
threadif I reach the bonus
- Can also be
| column name | data type | details |
|---|---|---|
id |
integer | not null, primary key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- A
direct_messagecan have manyusersand manymessages
| column name | data type | details |
|---|---|---|
id |
integer | not null, primary key |
user_id |
integer | not null, foreign key, indexed |
memberable_id |
integer | not null, foreign key, indexed |
memberable_type |
string | not null |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
membershipsis a joins table forusersandchannels/direct_messages - Index on
user_idandmemberable_id - A
usercan belong either achannelor adirect_messagethrough thememberable_idandmemberable_type- Can also belong to a
threadif I reach the bonus
- Can also belong to a
-
memberable_typecan be eitherchannelordirect_message'- Can also be
threadif I reach the bonus
- Can also be
| column name | data type | details |
|---|---|---|
id |
integer | not null, primary key |
parent_message_id |
integer | not null, foreign key, indexed |
created_at |
datetime | not null |
updated_at |
datetime | not null |
Index on parent_message_id
Has many messages and users
Belongs to a message through parent_message_id and belongs to a channel or direct_message through the message