Schema - melflynn/BarkedIn GitHub Wiki

users

Column Data Type Details
id integer not null, primary key
first_name string not null, indexed
last_name string not null, indexed
email string not null, indexed, unique
job_title string
location string
about_me text.
password_digest string not null
session_token string not null, indexed
created_at datetime not null
updated_at datetime not null

DB validations:

  • index on [first_name, last_name] pair

Associations:

  • Custom Associations
    • has_many :connections
    • has_many :connected_users through :connections
    • has_many :connection_requests
    • has_many :users_requesting_connection through :connection_requests
    • has_many :requested_connections
    • has_many :pending_users through :requested_connections
  • has_many :posts
  • has_many :comments
  • has_many :reactions
  • has_many :user_skills
  • has_many :skills through :user_skills

connections

Joins Table

Column Data Type Details
id integer not null, primary key
user_id1 integer not null, indexed, foreign key
user_id2 integer not null, indexed, foreign key
status string not null
created_at datetime not null
updated_at datetime not null

DB Validations:

  • index on [user_id1, user_id2] pair
  • check constraint to validate user_id1 < user_id2
  • status IN ('pending_user1', 'pending_user2', 'connected')

posts

Column Data Type Details
id integer not null, primary key
author_id integer not null, indexed, foreign key
body text not null
created_at datetime not null
updated_at datetime not null
  • belongs_to :author
  • has_many :comments
  • has_many :reactions

comments

Column Data Type Details
id integer not null, primary key
post_id integer not null, indexed, foreign key
author_id integer not null, indexed, foreign key
parent_comment_id integer optional, indexed, foreign key
body string not null
created_at datetime not null
updated_at datetime not null
  • belongs_to :post
  • belongs_to :author
  • belongs_to (optional) :parent_comment
  • has_many :replies
  • has_many :reactions

reactions

Joins Table

Column Data Type Details
id integer not null, primary key
post_id integer indexed, foreign key
comment_id integer indexed, foreign key
liker_id integer not null, indexed, foreign key
reaction_type string not null
created_at datetime not null
updated_at datetime not null
  • belongs_to (optional) :post
  • belongs_to (optional) :comment
  • belongs_to :liker

skills

Column Data Type Details
id integer not null, primary key
title string not null, unique
created_at datetime not null
updated_at datetime not null
  • has_many :user_skills
  • has_many :users_with_skill through :user_skills

user_skills

Joins Table

Column Data Type Details
id integer not null, primary key
user_id integer not null, indexed, foreign key
skill_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • belongs_to :user
  • belongs_to :skill

Bonus

endorsements

Column Data Type Details
id integer not null, primary key
user_skill_id integer not null, indexed, foreign key
endorser_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null

companies

Column Data Type Details
id integer not null, primary key
name string not null
created_at datetime not null
updated_at datetime not null

messages

Column Data Type Details
id integer not null, primary key
author_id integer not null, indexed, foreign key
recipient_id integer not null, indexed, foreign key
parent_message_id integer optional, indexed, foreign key
body text not null
created_at datetime not null
updated_at datetime not null