Files
homework/aharlamcev/postgresql/homeworkDDL.sql
T
2026-01-17 14:45:48 +03:00

35 lines
718 B
SQL

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)
) ;
alter table users
rename column crated_at to created_at;