Skip to content
Elhoussine edited this page Mar 23, 2022 · 8 revisions

Database Schema

users

column name data type details
id integer not null, primary key
email string not null, unique
name string not null
password_digest string not null
session_token string not null, unique
created_at datetime not null
updated_at datetime not null
  • index on email, unique: true
  • index on session_token, unique: true
  • has_many products
  • has_many carts

category

column Name data type details
id integer not null, primary key
name string not null, unique
description text
created_at datetime not null
updated_at datetime not null
  • has_many products

products

column name data type details
id integer not null, primary key
name string not null
style string
color string not null
price float not null
brand string not null
image string not null
description text
release_date date not null
seller_id integer not null
category_id integer not null
created_at datetime not null
updated_at datetime not null
  • index on seller_id
  • index on category_id
  • seller_id references users
  • category_id references category
  • belongs_to category
  • belongs_to user
  • has_many cart_items

cart

column name data type details
id integer not null, primary key
status string not null
amount float not null
user_id integer not null, foreign key
created_at datetime not null
updated_at datetime not null
  • index on user_id
  • user_id references users
  • belongs_to user
  • has_many cart_items

cart_items

column name data type details
id integer not null, primary key
product_id integer not null, foreign key
quantity integer not null.
total float not null.
cart_id integer not null, 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 cart
  • belongs_to cart
  • belongs_to product
Clone this wiki locally