Database Schema - skygit97/ConnectMe GitHub Wiki

users

column name datatype details
id integer not null, primary key
email string not null, indexed, unique
session_token string not null, indexed, unique
password_digest string not null
first_name string not null
last_name string not null
gender string not null
birthday date not null
  • index on email, unique: true
  • index on session_token, unique: true
  • has_many posts
  • has_many comments
  • has_many likes

posts

column name datatype details
id integer not null, primary key
author_id integer not null, indexed, foreign key
content string not null
created_at datetime not null
updated_at datetime not null
  • author_id references users
  • index on author_id
  • belongs_to author

comments

column name datatype details
id integer not null, primary key
author_id integer not null, indexed, foreign key
post_id string not null, indexed, foreign key
content string not null
created_at datetime not null
updated_at datetime not null
  • author_id references users
  • index on author_id
  • belongs_to author
  • belongs_to post

likes

column name datatype details
id integer not null, primary key
liker_id integer not null, indexed, foreign key
post_id string not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • liker_id references users
  • post_id references posts
  • index on [:liker_id, :post_id], unique: true
  • belongs_to user
  • belongs_to post