Add dml.sql and fix ddl.sql
This commit is contained in:
12
SQL/ddl.sql
12
SQL/ddl.sql
@@ -8,19 +8,19 @@ create table akalyanov.users (
|
||||
is_active boolean,
|
||||
created_at timestamp not null
|
||||
);
|
||||
-- Таблица товаров
|
||||
-- Таблица продуктов
|
||||
create table akalyanov.products (
|
||||
id int primary key,
|
||||
name varchar(100) not null,
|
||||
category varchar(50),
|
||||
price decimal(10, 2) not null,
|
||||
price decimal(10,2) not null,
|
||||
in_stock boolean
|
||||
);
|
||||
-- Таблица заказов
|
||||
create table akalyanov.orders (
|
||||
id int primary key,
|
||||
user_id int,
|
||||
order_date date not null,
|
||||
order_date timestamptz not null,
|
||||
status varchar(20),
|
||||
foreign key (user_id) references akalyanov.users(id)
|
||||
);
|
||||
@@ -29,6 +29,8 @@ create table akalyanov.order_items (
|
||||
order_id int,
|
||||
product_id int,
|
||||
quantity smallint not null,
|
||||
price_at_purchase decimal(10, 2) not null,
|
||||
primary key (order_id, product_id)
|
||||
price_at_purchase decimal(10,2) not null,
|
||||
primary key (order_id, product_id),
|
||||
foreign key (order_id) references akalyanov.orders(id),
|
||||
foreign key (product_id) references akalyanov.products(id)
|
||||
);
|
||||
Reference in New Issue
Block a user