-
Notifications
You must be signed in to change notification settings - Fork 0
/
star-schema.sql
46 lines (38 loc) · 1.09 KB
/
star-schema.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
-- This script was generated by a beta version of the ERD tool in pgAdmin 4.
-- Please log an issue at https://redmine.postgresql.org/projects/pgadmin4/issues/new if you find any bugs, including reproduction steps.
BEGIN;
CREATE TABLE public."FactBilling"
(
billid serial,
customerid integer NOT NULL,
monthid integer NOT NULL,
billedamount integer NOT NULL,
PRIMARY KEY (billid)
);
CREATE TABLE public."DimMonth"
(
monthid integer NOT NULL,
year integer NOT NULL,
month integer NOT NULL,
monthname varchar(10) NOT NULL,
quarter integer NOT NULL,
quartername varchar(2) NOT NULL,
PRIMARY KEY (monthid)
);
CREATE TABLE public."DimCustomer"
(
customerid integer NOT NULL,
category varchar(10) NOT NULL,
country varchar(40) NOT NULL,
industry varchar(40) NOT NULL,
PRIMARY KEY (customerid)
);
ALTER TABLE public."FactBilling"
ADD FOREIGN KEY (customerid)
REFERENCES public."DimCustomer" (customerid)
NOT VALID;
ALTER TABLE public."FactBilling"
ADD FOREIGN KEY (monthid)
REFERENCES public."DimMonth" (monthid)
NOT VALID;
END;