schema - Patrick-Mondala/facebook-clone GitHub Wiki
Database Schema
users
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
first_name |
string | not null |
last_name |
string | not null |
email |
string | not null, indexed, unique |
password_digest |
string | not null |
session_token |
string | not null, indexed, unique |
birth_date |
datetime | not null |
gender |
string | not null |
bio |
string | |
location |
string | |
current_city |
string | |
hometown |
string | |
workplace |
string | |
education |
string | |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- index on
email
,unique: true
- index on
session_token
,unique: true
friendships
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
requester_id |
integer | not null, indexed |
requested_id |
integer | not null, indexed |
accepted |
boolean | not null |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- index on
requester_id
user
who created friend request
- index on
requested_id
user
who received friend request
- index on
[requester_id, requested_id], unique: true
posts
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
author_id |
integer | not null, indexed |
timeline_owner_id |
integer | not null, indexed |
body |
string | |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- index on
author_id
user
who createdpost
- index on
timeline_owner_id
user
who owns the timeline thepost
was posted on
tags
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
post_id |
integer | not null, indexed |
tagger_id |
integer | not null, indexed |
tagged_user_id |
integer | not null, indexed |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- index on
post_id
post
thetag
was made on
- index on
tagger_id
user
thattagged
anotheruser
- index on
tagged_user_id
user
that wastagged
comments
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
body |
string | |
author_id |
integer | not null, indexed |
post_id |
integer | not null, indexed |
parent_comment_id |
integer | indexed |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- index on
author_id
user
who createdcomment
- index on
post_id
post
thecomment
was made on
- index on
parent_comment_id
comment
that the newcomment
was made on