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
referencescategories
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
referencesproducts
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
referencesproducts
cart_id
referencescarts
shade_id
referencesshades
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
referencesusers
Associations:
- belongs_to :user
- has_many :cart_items
- has_many :products (through association)