From f050458471e3959dc4bf7ad2740a56f95104dae3 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 17 Jan 2026 10:02:47 +0300 Subject: [PATCH] Created tables users, products, orders, order_items. --- aharlamcev/postgresql/homeworkDDL.sql | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 aharlamcev/postgresql/homeworkDDL.sql diff --git a/aharlamcev/postgresql/homeworkDDL.sql b/aharlamcev/postgresql/homeworkDDL.sql new file mode 100644 index 0000000..7bc5255 --- /dev/null +++ b/aharlamcev/postgresql/homeworkDDL.sql @@ -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) +) ; \ No newline at end of file