Database Schema - michellekontoff/spudhub GitHub Wiki

Users

column name data type details
id integer not null, PK
username string(50) not null, unique
email string(255) not null, unique
address string(255) not null
hashed_password string(255) not null
created_at date not null
updated_at date not null

Order Details (Joins Table)

column name datatype details
id integer not null, PK
order_id integer not null, FK(Orders)
user_id integer not null, FK(Users)
quantity integer not null, default:1
product_id integer not null , FK(Products)
created_at date not null
updated_at date not null

Many to Many (users-products, products-orders)

Products

column name datatype details
id integer not null, PK
name string(50) unique
user_id integer not null, FK(Users)
description string(255) not null
price decimal not null
image TEXT
quantity integer not null
created_at date not null
updated_at date not null

One to Many (User < Products)

Orders

column name datatype details
id integer not null, PK
user_id integer not null, FK(Users)
total_price decimal not null
created_at date not null
updated_at date not null

One to Many (User < Orders)

Reviews

column name datatype details
id integer not null, PK
user_id integer not null, FK(Users)
product_id integer not null, FK(Products)
review text not null
rating integer not null default:0
created_at date not null
updated_at date not null

One to Many (User < Reviews, Product < Reviews)

Database Schema