Skip to content
caroger edited this page Feb 9, 2021 · 7 revisions

Postgres Database Schema

users

column name data type details
id integer not null, primary key
first_name string not null, indexed
email string not null, indexed, unique
address text not null
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
name string not null
price integer not null
description text not null
seller_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • seller_id references users
  • index on seller_id

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
quantities integer not null
created_at datetime not null
updated_at datetime not null
  • user_id references users
  • product_id references products
  • index on user_id
  • index on product_id

reviews

column name data type details
id integer not null, primary key
product_id integer not null, indexed, foreign key
reviewer_id integer not null, indexed, foreign key
rating integer not null
body text not null
created_at datetime not null
updated_at datetime not null
  • product_id references products
  • reviewer_id references users
  • index on [:product_id_id, :reviewer_id], unique: true

favorites

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
created_at datetime not null
updated_at datetime not null
  • user_id references users
  • product_id references products
  • index on [:user_id, :product_id], unique: true
Clone this wiki locally