Skip to content

Commit c93d691

Browse files
authored
feat(cat-gateway): Add rough high level db schema. To be refined in subsequent PRs. (#1031)
1 parent 95e7024 commit c93d691

File tree

5 files changed

+166
-0
lines changed

5 files changed

+166
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
-- Catalyst Voices Database - Brand Information
2+
-- sqlfluff:dialect:postgres
3+
4+
-- Title : Brand Data
5+
6+
-- Brand Tables
7+
8+
-- -------------------------------------------------------------------------------------------------
9+
10+
-- Brand defintion.
11+
CREATE TABLE IF NOT EXISTS brand (
12+
id UUID NOT NULL PRIMARY KEY DEFAULT GEN_RANDOM_UUID(),
13+
name TEXT NOT NULL UNIQUE
14+
);
15+
16+
COMMENT ON TABLE brand IS
17+
'Defintion of a Brand.';
18+
19+
COMMENT ON COLUMN brand.id IS
20+
'Synthetic Unique ID for the brand (UUIDv4).';
21+
COMMENT ON COLUMN brand.name IS
22+
'The UNIQUE name for the brand.';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
-- Catalyst Voices Database - Campaign Information
2+
-- sqlfluff:dialect:postgres
3+
4+
-- Title : Campaign Data
5+
6+
-- Campaign Tables
7+
8+
-- -------------------------------------------------------------------------------------------------
9+
10+
-- Campaign defintion.
11+
CREATE TABLE IF NOT EXISTS campaign (
12+
id UUID NOT NULL PRIMARY KEY DEFAULT GEN_RANDOM_UUID(),
13+
brand_id UUID NOT NULL,
14+
name TEXT NOT NULL UNIQUE,
15+
16+
CONSTRAINT fk_brand FOREIGN KEY (brand_id) REFERENCES brand (id) ON DELETE CASCADE
17+
);
18+
19+
COMMENT ON TABLE campaign IS
20+
'Defintion of a Campaign.';
21+
22+
COMMENT ON COLUMN campaign.id IS
23+
'Synthetic Unique ID for the campaign (UUIDv4).';
24+
COMMENT ON COLUMN campaign.name IS
25+
'The UNIQUE name for the campaign.';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
-- Catalyst Voices Database - Event Information
2+
-- sqlfluff:dialect:postgres
3+
4+
-- Title : Event Data
5+
6+
-- Event Tables
7+
8+
-- -------------------------------------------------------------------------------------------------
9+
10+
-- Event defintion.
11+
CREATE TABLE IF NOT EXISTS event (
12+
id UUID NOT NULL PRIMARY KEY DEFAULT GEN_RANDOM_UUID(),
13+
campaign_id UUID NOT NULL,
14+
name TEXT NOT NULL UNIQUE,
15+
16+
CONSTRAINT fk_campaign FOREIGN KEY (campaign_id) REFERENCES campaign (id) ON DELETE CASCADE
17+
);
18+
19+
COMMENT ON TABLE event IS
20+
'Defintion of an Event.';
21+
22+
COMMENT ON COLUMN event.id IS
23+
'Synthetic Unique ID for the event (UUIDv4).';
24+
COMMENT ON COLUMN event.name IS
25+
'The UNIQUE name for the event.';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
-- Catalyst Voices Database - Proposal Information
2+
-- sqlfluff:dialect:postgres
3+
4+
-- Title : Proposal Data
5+
6+
-- Proposal Tables
7+
8+
-- -------------------------------------------------------------------------------------------------
9+
10+
-- Proposal Template defintion.
11+
CREATE TABLE IF NOT EXISTS proposal_template (
12+
id UUID NOT NULL PRIMARY KEY DEFAULT GEN_RANDOM_UUID(),
13+
name TEXT NOT NULL UNIQUE,
14+
template JSONB
15+
);
16+
17+
COMMENT ON TABLE proposal_template IS
18+
'Defintion of a Proposal Template.';
19+
20+
COMMENT ON COLUMN proposal_template.id IS
21+
'Synthetic Unique ID for the proposal template (UUIDv4).';
22+
COMMENT ON COLUMN proposal_template.name IS
23+
'The UNIQUE name for the proposal template.';
24+
COMMENT ON COLUMN proposal_template.template IS
25+
'The JSON Schema which must match the data contained in the proposal.';
26+
27+
-- -------------------------------------------------------------------------------------------------
28+
29+
-- Proposal defintion.
30+
CREATE TABLE IF NOT EXISTS proposal (
31+
id UUID NOT NULL PRIMARY KEY DEFAULT GEN_RANDOM_UUID(),
32+
template_id UUID NOT NULL,
33+
34+
CONSTRAINT fk_proposal_template FOREIGN KEY (template_id) REFERENCES proposal_template (id)
35+
);
36+
37+
COMMENT ON TABLE proposal IS
38+
'An individual Proposal.';
39+
40+
COMMENT ON COLUMN proposal.id IS
41+
'The Synthetic Unique ID for the proposal (UUIDv4).';
42+
COMMENT ON COLUMN proposal.template_id IS
43+
'The Template this proposal conforms to.';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
-- Catalyst Voices Database - Category Information
2+
-- sqlfluff:dialect:postgres
3+
4+
-- Title : Category Data
5+
6+
-- Category Tables
7+
8+
-- -------------------------------------------------------------------------------------------------
9+
10+
-- Category defintion.
11+
CREATE TABLE IF NOT EXISTS category (
12+
id UUID NOT NULL PRIMARY KEY DEFAULT GEN_RANDOM_UUID(),
13+
event_id UUID NOT NULL,
14+
name TEXT NOT NULL,
15+
proposal_template UUID NOT NULL,
16+
17+
CONSTRAINT fk_event FOREIGN KEY (event_id) REFERENCES event (id) ON DELETE CASCADE,
18+
CONSTRAINT fk_proposal_template FOREIGN KEY (proposal_template) REFERENCES proposal_template (id)
19+
);
20+
21+
COMMENT ON TABLE category IS
22+
'Defintion of a Category.';
23+
24+
COMMENT ON COLUMN category.id IS
25+
'Synthetic Unique ID for the category (UUIDv4).';
26+
COMMENT ON COLUMN category.event_id IS
27+
'Synthetic ID for the event this category belongs to (UUIDv4).';
28+
COMMENT ON COLUMN category.name IS
29+
'The name for the category.';
30+
COMMENT ON COLUMN category.proposal_template IS
31+
'The template all proposals in this category must use.';
32+
33+
-- -------------------------------------------------------------------------------------------------
34+
35+
-- Proposals submitted to a Category.
36+
CREATE TABLE IF NOT EXISTS category_proposals (
37+
id UUID NOT NULL PRIMARY KEY DEFAULT GEN_RANDOM_UUID(),
38+
category_id UUID NOT NULL,
39+
proposal_id UUID NOT NULL,
40+
41+
CONSTRAINT fk_category FOREIGN KEY (category_id) REFERENCES category (id) ON DELETE CASCADE,
42+
CONSTRAINT fk_proposal_id FOREIGN KEY (proposal_id) REFERENCES proposal (id) ON DELETE CASCADE
43+
);
44+
45+
COMMENT ON TABLE category_proposals IS
46+
'Proposals that are submitted into the linked category.';
47+
48+
COMMENT ON COLUMN category.id IS
49+
'Synthetic ID for the category (UUIDv4) the proposal is linked to.';
50+
COMMENT ON COLUMN category.event_id IS
51+
'Synthetic ID for the proposal (UUIDv4) being submitted to the category.';

0 commit comments

Comments
 (0)