Schema - fullernle/printsy GitHub Wiki

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
  • has_one cart association
  • has_many reviews association
  • has_many products_in_cart association
  • has_many listings association

products

column name data type details
id integer not null, primary key
name string not null, indexed
description string not null
price integer not null, indexed
seller_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • index on: seller_id
  • index on: price
  • index on: product_name
  • belongs_to seller association
  • has_many categories association
  • has_many cart_items association

carts

column name data type details
id integer not null, primary key
user_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • index on: user_id
  • belongs_to user association
  • has_many cart_items association
  • has_many products association

cart_items

column name data type details
id integer not null, primary key
quantity integer not null
cart_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
  • index on: user_id
  • index on: cart_id
  • index on: product_id
  • belongs_to cart association
  • belongs_to product association

reviews

column name data type details
id integer not null, primary key
rating integer not null, indexed
body text not null
product_id integer not null, unique, indexed, foreign key
reviewer_id integer not null, unique, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • index on: product_id, unique: true
  • index on: reviewer_id, unique: true
  • index on: rating
  • belongs_to user association
  • belongs_to product association

product_categories

Column Data Type Details
id integer not null, primary key
product_id integer not null, index
created_at datetime not null
updated_at datetime not null
  • index on: product_id
  • belongs_to category association
  • belongs_to product association

category

Column Data Type Details
id integer not null, primary key
name string not null, index
product_category_id integer index
created_at datetime not null
updated_at datetime not null
  • index on: category_id
  • index on: name
  • has_many product_categories association