Database Schema - deanmayne/marcheauxpuces GitHub Wiki

users

column name data type details
id integer not null
name string not null
username string not null, indexed, unique
password_digest string not null
session_token string not null, indexed, unique
  • username and session_token will be indexed and be unique

products

column name data type details
id integer not null, primary key
name string not null
description text not null
price string not null
category string not null
free_shipping boolean not null
location string not null
owner_id integer not null, indexed, foreign key
  • owner_id will be indexed.
  • product_ids will belong to a user referencing the users table using owner_id.

reviews

column name data type details
id integer not null, primary key
body text not null
rating integer not null
author_id integer not null, indexed, foreign key
product_id integer not null, indexed, foreign key
  • author_id and product_id will be indexed.
  • Reviews will belong to a user referencing the users table using author_id.
  • Reviews will belong to a product referencing the products table using product_id.

carts

column name data type details
id integer not null, primary key
product_id integer not null, indexed, foreign key
shopper_id integer not null, indexed, foreign key
quantity integer not null
  • product_id and shopper_id will be indexed.
  • Carts will belong to a user referencing the users table using shopper_id.
  • Carts will have many products by referencing the products table using product_id.