Skip to content
chen445 edited this page Jun 1, 2021 · 8 revisions

Ama2on Database Schema

users

column name data type details
id integer not null, primary key
first_name string not null
last_name string not null
email string not null, indexed, unique
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

products

column name data type details
id integer not null, primary key
product_name string not null, indexed
price float not null
seller_id integer not null, indexed, foreign key
product_description text not null
created_at datetime not null
updated_at datetime not null
  • index on product_name
  • index on seller_id
  • seller_id references users

cart_items

column name data type details
id integer not null, primary key
user_id integer not null, indexed, foreign key
product_id integer not null, indexed, foreign key
quantity integer not null
created_at datetime not null
updated_at datetime not null
  • user_id references users
  • index on user_id
  • index on product_id

reviews

column name data type details
id integer not null, primary key
reviewer_id integer not null, indexed, foreign key
product_id integer not null, indexed, foreign key
rating integer not null
title string not null
body text not null
created_at datetime not null
updated_at datetime not null
  • reviewer_id references users
  • index on reviewer_id
  • index on product_id

Clone this wiki locally