-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCrowdfunding_db.sql
44 lines (40 loc) · 1.24 KB
/
Crowdfunding_db.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
CREATE TABLE contacts (
contact_id SERIAL PRIMARY KEY,
first_name VARCHAR(255) NOT NULL,
last_name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL
);
CREATE TABLE category (
category_id VARCHAR(255) PRIMARY KEY,
category VARCHAR(255) NOT NULL
);
CREATE TABLE subcategory (
subcategory_id VARCHAR(255) PRIMARY KEY,
subcategory VARCHAR(255) NOT NULL
);
CREATE TABLE campaign (
cf_id SERIAL PRIMARY KEY,
contact_id INT NOT NULL,
company_name VARCHAR(255) NOT NULL,
description TEXT NOT NULL,
goal DECIMAL(12, 2) NOT NULL,
pledged DECIMAL(12, 2),
outcome VARCHAR(50),
backers_count INT,
country VARCHAR(50),
currency VARCHAR(10),
launched_date TIMESTAMP NOT NULL,
end_date TIMESTAMP NOT NULL,
category_id VARCHAR(255) NOT NULL,
subcategory_id VARCHAR(255),
CONSTRAINT fk_campaign_contact FOREIGN KEY (contact_id)
REFERENCES contacts (contact_id),
CONSTRAINT fk_campaign_category FOREIGN KEY (category_id)
REFERENCES category (category_id),
CONSTRAINT fk_campaign_subcategory FOREIGN KEY (subcategory_id)
REFERENCES subcategory (subcategory_id)
);
SELECT * FROM contacts;
SELECT * FROM category;
SELECT * FROM subcategory;
SELECT * FROM campaign;