Schema - harrisonlhl123/facebook-clone GitHub Wiki
Postgres Database Schema
Users:
| name | type | validations |
|---|---|---|
id |
bigInt | not null, primary key |
email |
string | not null, indexed, unique |
first_name |
string | not null |
last_name |
string | not null |
birthday |
date | not null |
gender |
string | not null |
password_digest |
string | not null |
session_token |
string | not null, indexed, unique |
created_at |
datetime | not null |
updated_at |
datetime | not null |
emailindexed and uniquesession_tokenindexed and uniquehas_many :postshas_many :commentshas_many :friends
Posts:
| name | type | validations |
|---|---|---|
id |
bigInt | not null, primary key |
body |
text | not null |
author_id |
bigInt | not null, indexed, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
author_idis used to reference auserbelongs_to userhas_many comments
Comments:
| name | type | validations |
|---|---|---|
id |
integer | not null, primary key |
user_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_idis used to reference auserpost_idis used to reference apostbelongs_to userbelongs_to post
Friending:
| name | type | validations |
|---|---|---|
id |
bigInt | not null, primary key |
user_id |
bigInt | not null, indexed, foreign key |
friend_id |
bigInt | not null, indexed, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
user_idis used to reference auserfriend_idis used to reference anotheruserbelongs_to userbelongs_to friend[user_id, friend_id]are indexed and unique