CREATE TABLE users
( user_id int auto_increment PRIMARY KEY,
username varchar(50) NOT NULL,
email varchar(100) NOT NULL UNIQUE,
password varchar(255) NOT NULL );
--
create table orders
( order_id int auto_increment primary key,
user_id int not null,
total_amount decimal(10,2) not null,
order_date datetime ,
constraint fk_orders_users foreign key(user_id) references users(user_id) );
--
create table products
( product_id int auto_increment primary key,
name varchar(100) not null,
price decimal(10,2) not null,
category varchar(50) );
create table order_items
( item_id int auto_increment primary key,
order_id int not null,
product_id int not null,
quantity int not null,
constraint fk_order_items_order_id foreign key(order_id) references orders(order_id),
constraint fk_order_items_product_id foreign key(product_id) references products(product_id) );
-- payments
create table payments
( payment_id int auto_increment primary key,
order_id int not null,
method varchar(100) not null,
status varchar(100) not null,
constraint fk_payments_order_id foreign key(order_id) references orders(order_id) );
create table inventory
( product_id int auto_increment primary key,
quanty int not null,
last_updateed datetime,
constraint fk_inventory_product_id foreign key(product_id) references products(product_id) );