Created tables users, products, orders, order_items.
This commit is contained in:
@@ -0,0 +1,32 @@
|
|||||||
|
create table users (
|
||||||
|
id int primary key,
|
||||||
|
name VARCHAR(100) not null,
|
||||||
|
email VARCHAR(100),
|
||||||
|
country VARCHAR(50),
|
||||||
|
crated_at date not null
|
||||||
|
) ;
|
||||||
|
|
||||||
|
create table products (
|
||||||
|
id int primary key,
|
||||||
|
name VARCHAR(100) not null,
|
||||||
|
category VARCHAR(50),
|
||||||
|
price DECIMAL(10, 2),
|
||||||
|
in_stock BOOLEAN default true
|
||||||
|
) ;
|
||||||
|
|
||||||
|
create table orders (
|
||||||
|
id int primary key,
|
||||||
|
user_id int,
|
||||||
|
order_date DATE not null,
|
||||||
|
status VARCHAR(20),
|
||||||
|
foreign key (user_id) references users(id)
|
||||||
|
) ;
|
||||||
|
|
||||||
|
create table order_items (
|
||||||
|
order_id int,
|
||||||
|
product_id int,
|
||||||
|
quantity int not null,
|
||||||
|
price_at_purchase DECIMAL(10, 2) not null,
|
||||||
|
foreign key (order_id) references orders(id),
|
||||||
|
foreign key (product_id) references products(id)
|
||||||
|
) ;
|
||||||
Reference in New Issue
Block a user