Skip to content

database schema

Arebiter edited this page Nov 2, 2021 · 27 revisions

Database Schema

users

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

tea_times

column name data type details
id integer not null, primary key
location string not null
start_time datetime not null
end_time datetime not null
city_id integer not null, indexed, foreign key
host_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • index on host_id, unique:true
  • index on city_id, unique: true
  • host_id references users
  • city_id references cities

cities

column name data type details
id integer not null, primary key
city_name string not null
created_at datetime not null
updated_at datetime not null
  • index on name, unique:true

attendance

to keep track of users attending a teatime

column name data type details
id integer not null, primary key
teatime_id integer not null, indexed, foreign key
user_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • index on [teatime_id, user_id]. unique: true - this would need to be a unique combination
  • teatime_id references tea_times
  • user_id references users

reviews

to show reviews of a host

column name data type details
id integer not null, primary key
user_id integer not null, indexed, foreign key
host_id integer not null, indexed, foreign key
rating integer not null
review text not null
created_at datetime not null
updated_at datetime not null
  • index on [user_id, host_id]. unique: true - this would need to be a unique combination - a user can only review a host once?
  • user_id references users
  • host_id references users
  • a host can be reviewed, the review belongs to the user who makes the review
Clone this wiki locally