Skip to content
le-s edited this page Dec 15, 2018 · 8 revisions

Database Schema

users

column name data type details
id integer not null, primary key
email string not null, indexed, unique
first_name string not null
last_name string not null
password_digest string not null
session_token string not null, indexed, unique
created_at datetime not null
updated_at datetime not null
  • index on email, unique: true
  • index on session_token, unique: true

cars

column name data type details
id integer not null, primary key
owner_id integer not null, foreign key, indexed
year integer not null
make string not null
model string not null
price integer not null
description text not null
mpg integer not null
fuel_type string not null
num_doors integer not null
num_seats integer not null
bluetooth boolean not null
auxiliary_input boolean not null
heated_seats boolean not null
gps boolean not null
automatic_trans boolean not null
usb_ports boolean not null
backup_camera boolean not null
mods text
address string not null
city string not null
state string not null
zipcode integer not null
longitude float not null
latitude float not null
created_at datetime not null
updated_at datetime not null
  • owner_id refers to users
  • index on owner_id
  • index on city

rentals

column name data type details
id integer not null, primary key
car_id integer not null, foreign key, indexed
renter_id integer not null, foreign key, indexed
reserve_date date not null
return_date date not null
created_at datetime not null
updated_at datetime not null
  • car_id refers to cars
  • renter_id refers to users
  • index on car_id
  • index on renter_id

reviews

column name data type details
id integer not null, primary key
author_id integer not null, foreign key, indexed
car_id integer not null, foreign key, indexed
body text not null
rating integer not null
created_at datetime not null
updated_at datetime not null
  • author_id refers to users
  • car_id refers to cars
  • index of author_id
  • index of car_id
Clone this wiki locally