From 5c2037a49affb52129cc7961368a92bd61e2adbf Mon Sep 17 00:00:00 2001 From: mnoskov Date: Thu, 23 Apr 2026 23:28:03 +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=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB?= =?UTF-8?q?=D0=B8=20=D1=82=D0=B8=D0=BF=D1=8B=20=D1=81=D1=82=D0=BE=D0=BB?= =?UTF-8?q?=D0=B1=D1=86=D0=BE=D0=B2=20=D0=B2=20core=20=D1=82=D0=B0=D0=BA?= =?UTF-8?q?=D0=B8=D0=BC=D0=B8=20=D0=B6=D0=B5=20=D0=BA=D0=B0=D0=BA=20=D0=B2?= =?UTF-8?q?=20raw.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Пет проект: DWH/Step_3_core_layer.sql | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/mnoskov/greenplum/Пет проект: DWH/Step_3_core_layer.sql b/mnoskov/greenplum/Пет проект: DWH/Step_3_core_layer.sql index c2b6c59..eed6ab3 100644 --- a/mnoskov/greenplum/Пет проект: DWH/Step_3_core_layer.sql +++ b/mnoskov/greenplum/Пет проект: DWH/Step_3_core_layer.sql @@ -1,27 +1,27 @@ -- 4 - --DROP TABLE IF EXISTS core.dim_user; CREATE TABLE core.dim_user ( - user_id int PRIMARY KEY, - name text, - age int, - email text NOT NULL, - registration_date date NOT NULL + user_id bigint PRIMARY KEY, + name varchar(100), + age smallint, + email varchar(100) NOT NULL, + registration_date timestamptz 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 NOT NULL, - category text + course_id bigint PRIMARY KEY, + title varchar(150) NOT NULL, + category varchar(50), + created_at timestamptz NOT NULL ) DISTRIBUTED BY (course_id); --DROP TABLE IF EXISTS core.dim_lesson; CREATE TABLE core.dim_lesson ( - lesson_id int PRIMARY KEY, - title text NOT NULL, - duration_min int, - course_id int NOT NULL REFERENCES core.dim_course(course_id) + lesson_id bigint PRIMARY KEY, + title varchar(150) NOT NULL, + duration_min smallint, + course_id bigint 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 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 + user_id bigint NOT NULL REFERENCES core.dim_user(user_id), + lesson_id bigint NOT NULL REFERENCES core.dim_lesson(lesson_id), + course_id bigint NOT NULL REFERENCES core.dim_course(course_id), + viewed_at timestamptz NOT NULL ) DISTRIBUTED BY (user_id); --DROP TABLE IF EXISTS core.enrollments; CREATE TABLE core.enrollments ( - 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 + user_id bigint NOT NULL REFERENCES core.dim_user(user_id), + course_id bigint NOT NULL REFERENCES core.dim_course(course_id), + enrolled_at timestamptz NOT NULL ) DISTRIBUTED BY (user_id);