From 243e79401b9379d8b57fcd2c9ed49038e54fada4 Mon Sep 17 00:00:00 2001 From: mnoskov Date: Thu, 23 Apr 2026 22:25:25 +0300 Subject: [PATCH] =?UTF-8?q?=D0=AD=D1=82=D0=B0=D0=BF=203.=20=D0=A1=D0=BB?= =?UTF-8?q?=D0=BE=D0=B9=20Core=20=E2=80=94=20=D0=BE=D0=B1=D0=BE=D0=B3?= =?UTF-8?q?=D0=B0=D1=89=D1=91=D0=BD=D0=BD=D1=8B=D0=B5=20=D0=B4=D0=B0=D0=BD?= =?UTF-8?q?=D0=BD=D1=8B=D0=B5.=20=D0=9F=D0=B5=D1=82=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=B5=D0=BA=D1=82:=20DWH.=20=D0=A0=D0=90=D0=91=D0=9E=D0=A2?= =?UTF-8?q?=D0=90=20=D0=9D=D0=90=D0=94=20=D0=9E=D0=A8=D0=98=D0=91=D0=9A?= =?UTF-8?q?=D0=90=D0=9C=D0=98=20-=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20NULL=20=D0=B2=20=D0=B8=D0=B7=D0=BC=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=B8=20=D1=84=D0=B0=D0=BA=D1=82=D1=8B.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Пет проект: DWH/Step_3_core_layer.sql | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/mnoskov/greenplum/Пет проект: DWH/Step_3_core_layer.sql b/mnoskov/greenplum/Пет проект: DWH/Step_3_core_layer.sql index c21d4fa..c2b6c59 100644 --- a/mnoskov/greenplum/Пет проект: DWH/Step_3_core_layer.sql +++ b/mnoskov/greenplum/Пет проект: DWH/Step_3_core_layer.sql @@ -5,23 +5,23 @@ CREATE TABLE core.dim_user ( user_id int PRIMARY KEY, name text, age int, - email text, - registration_date date + email text NOT NULL, + registration_date date NOT NULL ) DISTRIBUTED BY (user_id); --DROP TABLE IF EXISTS core.dim_course; CREATE TABLE core.dim_course ( course_id int PRIMARY KEY, - title text, + title text NOT NULL, category text ) DISTRIBUTED BY (course_id); --DROP TABLE IF EXISTS core.dim_lesson; CREATE TABLE core.dim_lesson ( lesson_id int PRIMARY KEY, - title text, + title text NOT NULL, duration_min int, - course_id int REFERENCES core.dim_course(course_id) + course_id int NOT NULL REFERENCES core.dim_course(course_id) ) DISTRIBUTED BY (lesson_id); --DROP TABLE IF EXISTS core.dim_date; @@ -37,17 +37,17 @@ CREATE TABLE core.dim_date ( -- 5 --DROP TABLE IF EXISTS core.fact_lesson_views; CREATE TABLE core.fact_lesson_views ( - user_id int REFERENCES core.dim_user(user_id), - lesson_id int REFERENCES core.dim_lesson(lesson_id), - course_id int REFERENCES core.dim_course(course_id), - viewed_at timestamp + user_id int NOT NULL REFERENCES core.dim_user(user_id), + lesson_id int NOT NULL REFERENCES core.dim_lesson(lesson_id), + course_id int NOT NULL REFERENCES core.dim_course(course_id), + viewed_at timestamp NOT NULL ) DISTRIBUTED BY (user_id); --DROP TABLE IF EXISTS core.enrollments; CREATE TABLE core.enrollments ( - user_id int REFERENCES core.dim_user(user_id), - course_id int REFERENCES core.dim_course(course_id), - enrolled_at timestamp + user_id int NOT NULL REFERENCES core.dim_user(user_id), + course_id int NOT NULL REFERENCES core.dim_course(course_id), + enrolled_at timestamp NOT NULL ) DISTRIBUTED BY (user_id); @@ -101,7 +101,7 @@ SELECT FROM raw.lesson_views lv JOIN - raw.lessons l ON lv.lesson_id = l.id + raw.lessons l ON lv.lesson_id = l.id; INSERT INTO core.enrollments (user_id, course_id, enrolled_at) SELECT