Этап 3. Слой Core — обогащённые данные. Пет проект: DWH. РАБОТА НАД ОШИБКАМИ - сделали типы столбцов в core такими же как в raw.
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user