From 3fc5535e1de060011a92f8d0e64ffada13b32eb4 Mon Sep 17 00:00:00 2001 From: George Date: Thu, 11 Dec 2025 17:59:31 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=B4=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=B8=20=D0=BD=D0=B0=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=B5=D1=82-=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=D0=B0=20=D0=BF=D0=BE=20sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gmokrousov/postgresql/creating_tables.sql | 69 +++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 gmokrousov/postgresql/creating_tables.sql diff --git a/gmokrousov/postgresql/creating_tables.sql b/gmokrousov/postgresql/creating_tables.sql new file mode 100644 index 0000000..cc3c095 --- /dev/null +++ b/gmokrousov/postgresql/creating_tables.sql @@ -0,0 +1,69 @@ +create table users ( + id serial primary key, + name varchar(50) not null, + age int not null, + email varchar(100) not null, + registration_date date not null +); + +insert into users (name, age, email, registration_date) values + ('Alice', 25, 'alice@mail.com', ; '2023-01-10'), + ('Bob', 30, 'bob@gmail.com', '2023-02-05'), + ('Charlie', 22, 'Charlie@mail.com', '2023-02-20'), + ('Diana', 28, 'diana@mail.com', '2023-03-01'), + ('Ethan', 35, 'ethan@gmail.com', '2023-03-10'); + +create table courses ( + id serial primary key, + title varchar(100) not null, + category varchar(30) not null, + created_at date not_null +); + +insert into courses (title, category, created_at) values + ('SQL для начинающих', 'data', '2023-01-01'), + ('Python для анализа данных', 'programming', '2023-01-15'), + ('BI с нуля', 'business', '2023-03-01'); + +create table lessons ( + id serial primary key, + course_id int references courses(id), + title varchar(100) not null, + duration_min int not null +); + +insert into lessons (course_id, title, duration_min) values + (1, 'SELECT и FROM', 10), + (1, 'JOIN', 15), + (2, 'Pandas', 20), + (3, 'Основы BI', 12), + (3, 'Метрики и дашборды', 18); + +create table enrollments ( + id serial primary key, + user_id int references users(id), + course_id int references courses(id), + enrolled_at date not null +); + +insert into enrollments (user_id, course_id, enrolled_at) values + (1, 1, '2023-01-15'), + (1, 2, '2023-02-01'), + (2, 1, '2023-01-20'), + (3, 2, '2023-03-05'), + (4, 3, '2023-04-01'); + +create table lesson_views ( + id serial primary key, + user_id int references users(id), + lesson_id int references lessons(id), + viewed_at timestamp(0) not null +); + +insert into lesson_views (user_id, lesson_id, viewed_at) values + (1, 1, '2023-01-16 10:00:00'), + (1, 2, '2023-01-16 10:15:00'), + (2, 1, '2023-01-21 09:00:00'), + (3, 3, '2023-03-06 12:00:00'), + (4, 4, '2023-04-02 10:00:00'), + (4, 5, '2023-04-03 10:00:00');