From a9fab0c8789f2317e8fd87d0b89a87f10d6a0e06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=96=D1=83=D0=BB=D1=8C=20=D0=9A=D0=B8=D1=80=D0=B8=D0=BB?= =?UTF-8?q?=D0=BB?= <118897479+KirillZhul@users.noreply.github.com> Date: Sun, 28 May 2023 13:08:46 +0300 Subject: [PATCH] Create datamart_ddl.sql MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DDL-запрос на создание витрины данных. --- datamart_ddl.sql | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 datamart_ddl.sql diff --git a/datamart_ddl.sql b/datamart_ddl.sql new file mode 100644 index 0000000..4a0e6e6 --- /dev/null +++ b/datamart_ddl.sql @@ -0,0 +1,6 @@ +CREATE TABLE analysis.dm_rfm_segments (user_id int PRIMARY KEY, +recency int CHECK(recency > 0 AND recency <= 5), +frequency int CHECK(frequency > 0 AND recency <= 5), +monetary_value int CHECK(monetary_value > 0 AND monetary_value <= 5)) + +ALTER TABLE analysis.dm_rfm_segments ADD CONSTRAINT dm_rfm_segments_user_id_fkey FOREIGN KEY (user_id) REFERENCES production.users(id);