Schema - mdean7/mikEtsy GitHub Wiki

Schema

users

column name data type details
id integer not null, primary key
username string not null, indexed, unique
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 username, unique: true
  • index on email, unique: true
  • index on session_token, unique: true

products

column name data type details
id integer not null, primary key
title string not null
description text not null,
price integer not null
user_id integer not null, indexed foreign key
order_id integer indexed foreign key
created_at datetime not null
updated_at datetime not null
  • user_id references users
  • index on user_id
  • order_id references orders
  • index on order_id

reviews

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

orders

column name data type details
id integer not null, primary key
total integer not null
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
  • index on user_id
  • product_id references product_listings
  • index on product_id