Schema - rd-tran/Bulletin GitHub Wiki
Postgres Database Schema
users
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
fname |
string | not null |
lname |
string | not null |
username |
string | not null, indexed, unique |
email |
string | not null, indexed, unique |
birthday |
date | not null |
gender |
string | not null |
password_digest |
string | not null |
session_token |
string | not null, indexed, unique |
bio |
string | |
workplace |
string | |
education |
string | |
hometown |
string | |
relationship_status_id |
string | |
name_pronunciation |
string | |
website |
string | |
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
posts
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
author_username |
integer | not null, indexed, foreign key |
board_username |
integer | not null, indexed, foreign key |
body |
string | not null |
created_at |
datetime | not null |
updated_at |
datetime | not null |
author_id
andboard_id
referenceusers
table- index on
author_id
- index on
board_id
comments
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
author_id |
integer | not null, indexed, foreign key |
post_id |
integer | not null, indexed, foreign key |
body |
string | not null |
created_at |
datetime | not null |
updated_at |
datetime | not null |
user_id
referencesusers
tablepost_id
referencesposts
table- index on
user_id
- index on
post_id
friend_requests
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
requester_id |
integer | not null, indexed, foreign key |
requestee_id |
integer | not null, indexed, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
requester_id
andrequestee_id
referenceusers
table- index on
[:requester_id, :requestee_id], unique: true
friendships
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
friender_id |
integer | not null, indexed, foreign key |
friended_id |
integer | not null, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
friender_id
andfriended_id
referenceusers
table- index on
[:friender_id, :friended_id], unique: true
likes
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
user_id |
integer | not null, indexed, foreign key |
likeable_id |
integer | not null, indexed, foreign key |
likeable_type |
string | not null, indexed, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- polymorphic table
user_id
referencesusers
likeable_id
referencesposts
table orcomments
tablelikeable_type
referencesPost
model orComment
model- index on
[:user_id, :likeable_id, :likeable_type], unique: true
- index on
[:likeable_id]