From 467787a1d1605e15d6d30877b070fe081fdb9836 Mon Sep 17 00:00:00 2001 From: "av.kalyanov" Date: Sun, 26 Apr 2026 08:07:24 +0300 Subject: [PATCH] Add first ddl --- SQL/ddl.sql | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 SQL/ddl.sql diff --git a/SQL/ddl.sql b/SQL/ddl.sql new file mode 100644 index 0000000..a3047ed --- /dev/null +++ b/SQL/ddl.sql @@ -0,0 +1,34 @@ +-- Таблица пользователей +create table akalyanov.users ( + id int primary key, + name varchar(100) not null, + age smallint, + email varchar(100), + country varchar(2), + 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, + in_stock boolean +); +-- Таблица заказов +create table akalyanov.orders ( + id int primary key, + user_id int, + order_date date not null, + status varchar(20), + foreign key (user_id) references akalyanov.users(id) +); +-- Таблица товаров в заказе +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) +); \ No newline at end of file