Skip to content

database schema

Arebiter edited this page Oct 21, 2021 · 27 revisions

Database Schema

Users Table

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 not null
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

TeaTimes

column name data type details
id integer not null, primary key
host_id integer not null, indexed, foreign key
location string not null
start_time datetime not null
duration float not null
city_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 table
  • city_id references cities

Cities

column name data type details
id integer not null, primary key
name string not null, unique, indexed
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
status integer not null
created_at datetime not null
updated_at datetime not null
  • index on teatime_id, unique:true
  • index on user_id, unique: true

or?

  • index on [teatime_id, user_id]. unique: true - this would need to be a unique combination
  • teatime_id references TeaTime
  • users_id references users table
Clone this wiki locally