forked from DayanaIm/Crowdfunding_ETL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
crowdfunding_db_schema.sql
56 lines (47 loc) · 1.66 KB
/
crowdfunding_db_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
47
48
49
50
51
52
53
54
55
-- Exported from QuickDBD: https://www.quickdatabasediagrams.com/
-- NOTE! If you have used non-SQL datatypes in your design, you will have to change these here.
CREATE TABLE "campaign" (
"cf_id" INTEGER NOT NULL,
"contact_id" INTEGER NOT NULL,
"company_name" VARCHAR NOT NULL,
"description" VARCHAR NOT NULL,
"goal" FLOAT NOT NULL,
"pledged" FLOAT NOT NULL,
"outcome" VARCHAR NOT NULL,
"backers_count" INTEGER NOT NULL,
"country" VARCHAR NOT NULL,
"currency" VARCHAR NOT NULL,
"launched_date" DATE NOT NULL,
"end_date" DATE NOT NULL,
"category_id" VARCHAR NOT NULL,
"subcategory_id" VARCHAR NOT NULL
);
CREATE TABLE "category" (
"category_id" VARCHAR NOT NULL,
"category" VARCHAR NOT NULL,
CONSTRAINT "pk_category" PRIMARY KEY (
"category_id"
)
);
CREATE TABLE "contacts" (
"contact_id" INTEGER NOT NULL,
"first_name" VARCHAR NOT NULL,
"last_name" VARCHAR NOT NULL,
"email" VARCHAR NOT NULL,
CONSTRAINT "pk_contacts" PRIMARY KEY (
"contact_id"
)
);
CREATE TABLE "subcategory" (
"subcategory_id" VARCHAR NOT NULL,
"subcategory" VARCHAR 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");