Files
homework/skonev/greenplum/STEP1.2_create_tables.sql
T
2025-12-23 21:03:02 +03:00

45 lines
995 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
--создаем таблицы для raw слоя с DISTRIBUTED REPLICATED, т.к. таблицы довольно маленькие
CREATE TABLE raw.users (
id BIGINT PRIMARY KEY,
name VARCHAR(100),
age INT,
email VARCHAR(255) UNIQUE,
registration_date DATE NOT NULL
)
DISTRIBUTED REPLICATED;
CREATE TABLE raw.courses(
id BIGINT PRIMARY KEY,
title TEXT NOT NULL,
category VARCHAR(255) CHECK (category IN ('data', 'programming', 'business')),
created_at DATE NOT NULL
)
DISTRIBUTED REPLICATED;
CREATE TABLE raw.lessons(
id BIGINT PRIMARY KEY,
course_id INT NOT NULL,
title TEXT NOT NULL,
duration_min INT NOT NULL
)
DISTRIBUTED REPLICATED;
CREATE TABLE raw.enrollments(
id BIGINT PRIMARY KEY,
user_id INT NOT NULL,
course_id INT NOT NULL,
enrolled_at DATE NOT NULL
)
DISTRIBUTED REPLICATED;
CREATE TABLE raw.lesson_views(
id BIGINT PRIMARY KEY,
user_id INT NOT NULL,
lesson_id INT NOT NULL,
viewed_at TIMESTAMP NOT NULL
)
DISTRIBUTED REPLICATED;