schema - adammoftah/Stack-Overwhelm GitHub Wiki

Database Schema

users

column name data type details
id integer not null, primary key
display_name string not null, indexed, unique
email string not null, indexed, unique
password_digest string not null
session_token string not null, indexed, unique
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

questions

column name data type details
id integer not null, primary key
title string not null
body text not null
author_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • index on author_id
  • author_id references users

answers

column name data type details
id integer not null, primary key
body string not null
author_id integer not null, indexed, foreign key
question_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • index on author_id
  • author_id references users
  • index on question_id
  • question_id references questions

votes

column name data type details
id integer not null, primary key
voter_id integer not null
votable_type string not null, indexed
votable_id integer not null, indexed
vote_type integer not null
  • votes represents a polymorphic association, whereby question and answers can both be upvoted

favorites

column name data type details
id integer not null, primary key
user_id integer not null, indexed, foreign key
question_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • index on user_id
  • user_id references users
  • index on question_id
  • question_id references questions

`

⚠️ **GitHub.com Fallback** ⚠️