-
Notifications
You must be signed in to change notification settings - Fork 0
/
Crowdfunding_ETL.txt
56 lines (49 loc) · 1.68 KB
/
Crowdfunding_ETL.txt
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
47
48
49
50
51
52
53
54
55
56
Crowdfunding_ETL
CREATE TABLE "Campaign" (
"cf_id" int NOT NULL,
"contact_id" int NOT NULL,
"company_name" varchar(100) NOT NULL,
"description" text NOT NULL,
"goal" numeric(10,2) NOT NULL,
"pledged" numeric(10,2) NOT NULL,
"outcome" varchar(50) NOT NULL,
"backers_count" int NOT NULL,
"country" varchar(10) NOT NULL,
"currency" varchar(10) NOT NULL,
"launch_date" date NOT NULL,
"end_date" date NOT NULL,
"category_id" varchar(10) NOT NULL,
"subcategory_id" varchar(10) NOT NULL,
CONSTRAINT "pk_Campaign" PRIMARY KEY (
"cf_id"
)
);
CREATE TABLE "Contacts" (
"contact_id" int NOT NULL,
"first_name" varchar(50) NOT NULL,
"last_name" varchar(50) NOT NULL,
"email" varchar(100) NOT NULL,
CONSTRAINT "pk_Contacts" PRIMARY KEY (
"contact_id"
)
);
CREATE TABLE "Category" (
"category_id" varchar(10) NOT NULL,
"category" varchar(50) NOT NULL,
CONSTRAINT "pk_Category" PRIMARY KEY (
"category_id"
)
);
CREATE TABLE "Subcategory" (
"subcategory_id" varchar(10) NOT NULL,
"subcategory" varchar(50) NOT NULL,
CONSTRAINT "pk_Subcategory" PRIMARY KEY (
"subcategory_id"
)
);
ALTER TABLE "Campaign" ADD CONSTRAINT "fk_Campaign_contact_id" FOREIGN KEY("contact_id")
REFERENCES "Contacts" ("contact_id");
ALTER TABLE "Campaign" ADD CONSTRAINT "fk_Campaign_category_id" FOREIGN KEY("category_id")
REFERENCES "Category" ("category_id");
ALTER TABLE "Campaign" ADD CONSTRAINT "fk_Campaign_subcategory_id" FOREIGN KEY("subcategory_id")
REFERENCES "Subcategory" ("subcategory_id");