Database Schema - aishnair22/aura-beauty GitHub Wiki

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
created_at datetime not null
updated_at datetime not null
  • index on email, unique: true
  • index on session_token

Associations:

  • has_one :cart

products

Column Name Data Type Details
id integer not null, primary key
name string not null, indexed
description text not null
details text not null
ingredients text not null
how_to_use text not null
price integer not null
quote text not null
category_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • NB: product images stored in AWS
  • index on name
  • index on category_id
  • category_id references categories

Associations:

  • belongs_to :category
  • has_many :cart_items
  • has_many :shades

categories

Column Name Data Type Details
id integer not null, primary key
name string not null, indexed
created_at datetime not null
updated_at datetime not null
  • index on name

Associations:

  • has_many :products

shades

Column Name Data Type Details
id integer not null, primary key
name string not null
product_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • NB: shade images stored in AWS
  • index on product_id
  • product_id references products

Associations:

  • belongs_to :product
  • has_many :cart_items

cart_items

Column Name Data Type Details
id integer not null, primary key
product_id integer not null, indexed, foreign key
cart_id integer not null, indexed, foreign key
quantity integer not null
shade_id integer optional, foreign key
created_at datetime not null
updated_at datetime not null
  • index on product_id
  • index on cart_id
  • product_id references products
  • cart_id references carts
  • shade_id references shades

Associations:

  • belongs_to :product
  • belongs_to :cart
  • belongs_to :shade

carts

Column Name Data Type Details
id integer not null, primary key
user_id integer not null, indexed, unique, foreign key
created_at datetime not null
updated_at datetime not null
  • index on user_id, unique: true
  • user_id references users

Associations:

  • belongs_to :user
  • has_many :cart_items
  • has_many :products (through association)