Skip to content

Database Schema

rkoron007 edited this page Apr 10, 2018 · 18 revisions

Users

Column Name Data Type Details
id integer not null, primary key
username string not null, indexed, unique
img_url 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

Items

Column Name Data Type Details
id integer not null, primary key
user_id integer not null, foreign key
img_url string not null
description text not null, indexed
title string not null, indexed
price float not null, indexed
created_at datetime not null
updated_at datetime not null
  • index on [:title] for search purposes
  • index on [:price] for filtering purposes
  • index on [:description] for search purposes
  • user_id references users

Reviews

Column Name Data Type Details
id integer not null, primary key
author_id integer not null, foriegn key
item_id integer not null, foreign key
rating float not null
body text not null
created_at datetime not null
updated_at datetime not null
  • author_id references users
  • item_id references Items
  • index on [:author_id, :item_id], unique: true

Cart

Column Name Data Type Details
id integer not null, primary key
user_id integer not null, foreign key
created_at datetime not null
updated_at datetime not null
  • user_id references users

Cart Item

Column Name Data Type Details
id integer not null, primary key
cart_id integer not null, foreign key
item_id integer not null, foreign key
quantity integer not null
created_at datetime not null
updated_at datetime not null
  • cart_id references carts
  • item_id references Items

Clone this wiki locally