Schema - Heyitswilson/Toasty-fullstack GitHub Wiki

Database Schema

users

column_name data_type details
id integer not null, primary key
name string not null
email string not null, indexed, unique
password_digest string not null
session_token string not null, indexed, unique
  • index on email and session_token, unique: true

products

column_name data_type details
id integer not null, primary key
name string not null, unique, indexed
description string not null
price integer not null
artist_id integer not null, indexed, foreign key
  • artist_id references users
  • index on artist_id and name
  • unique: true on name

reviews

column_name data_type details
id integer not null, primary key
review string not null
rating integer not null
author_id integer not null, indexed, foreign key
product_id integer not null, indexed, foreign key
  • author_id references users, indexed
  • product_id references products, indexed

cart_items

column_name data_type details
id integer not null, primary key
product_id integer not null, indexed, foreign_key
cart_id integer not null, indexed, foreign_key
customer_id integer not null, indexed, foreign_key
quantity integer not null
  • cart_id references carts, indexed
  • product_id references products, indexed
  • customer_id references users, indexed
Guests should receive a temporary shopping cart, and logged-in users should receive a saved shopping cart