forked from GEWIS/API
-
Notifications
You must be signed in to change notification settings - Fork 0
/
psqlDatabaseStructure
20 lines (20 loc) · 3.6 KB
/
psqlDatabaseStructure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
CREATE TABLE Member (lidnr INT NOT NULL, email VARCHAR(255) NOT NULL, lastName VARCHAR(255) NOT NULL, middleName VARCHAR(255) NOT NULL, initials VARCHAR(255) NOT NULL, firstName VARCHAR(255) NOT NULL, gender VARCHAR(1) NOT NULL, generation INT NOT NULL, type VARCHAR(255) NOT NULL, expiration DATE NOT NULL, birth DATE NOT NULL, PRIMARY KEY(lidnr));
CREATE TABLE Decision (meeting_type VARCHAR(255) NOT NULL, meeting_number INT NOT NULL, point INT NOT NULL, number INT NOT NULL, PRIMARY KEY(meeting_type, meeting_number, point, number));
CREATE INDEX IDX_7DDADC1E602FAFFB96F82E16 ON Decision (meeting_type, meeting_number);
CREATE TABLE Meeting (type VARCHAR(255) NOT NULL, number INT NOT NULL, date DATE NOT NULL, PRIMARY KEY(type, number));
CREATE TABLE Event (id INT NOT NULL, name VARCHAR(255) NOT NULL, context VARCHAR(255) NOT NULL, parameters TEXT NOT NULL, PRIMARY KEY(id));
CREATE TABLE SubDecision (meeting_type VARCHAR(255) NOT NULL, meeting_number INT NOT NULL, decision_point INT NOT NULL, decision_number INT NOT NULL, number INT NOT NULL, lidnr INT DEFAULT NULL, r_meeting_type VARCHAR(255) DEFAULT NULL, r_meeting_number INT DEFAULT NULL, r_decision_point INT DEFAULT NULL, r_decision_number INT DEFAULT NULL, r_number INT DEFAULT NULL, type VARCHAR(255) NOT NULL, abbr VARCHAR(255) DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, organType VARCHAR(255) DEFAULT NULL, function VARCHAR(255) DEFAULT NULL, version VARCHAR(32) DEFAULT NULL, date DATE DEFAULT NULL, approval BOOLEAN DEFAULT NULL, changes BOOLEAN DEFAULT NULL, content VARCHAR(255) DEFAULT NULL, PRIMARY KEY(meeting_type, meeting_number, decision_point, decision_number, number));
CREATE INDEX IDX_F0D6EE40602FAFFB96F82E1690E0342DEF6BE237 ON SubDecision (meeting_type, meeting_number, decision_point, decision_number);
CREATE INDEX IDX_F0D6EE40D665E01D ON SubDecision (lidnr);
CREATE INDEX IDX_F0D6EE40EFBA85FF292FAD512F37B76A76CE18779986E2D ON SubDecision (r_meeting_type, r_meeting_number, r_decision_point, r_decision_number, r_number);
CREATE TABLE InstallationFunction (id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id));
CREATE TABLE Address (lidnr INT NOT NULL, type VARCHAR(255) NOT NULL, country VARCHAR(255) NOT NULL, street VARCHAR(255) NOT NULL, number VARCHAR(255) NOT NULL, postalCode VARCHAR(255) NOT NULL, city VARCHAR(255) NOT NULL, phone VARCHAR(255) NOT NULL, PRIMARY KEY(lidnr, type));
CREATE INDEX IDX_C2F3561DD665E01D ON Address (lidnr);
CREATE SEQUENCE Member_lidnr_seq INCREMENT BY 1 MINVALUE 1 START 1;
CREATE SEQUENCE Event_id_seq INCREMENT BY 1 MINVALUE 1 START 1;
CREATE SEQUENCE InstallationFunction_id_seq INCREMENT BY 1 MINVALUE 1 START 1;
ALTER TABLE Decision ADD CONSTRAINT FK_7DDADC1E602FAFFB96F82E16 FOREIGN KEY (meeting_type, meeting_number) REFERENCES Meeting (type, number) NOT DEFERRABLE INITIALLY IMMEDIATE;
ALTER TABLE SubDecision ADD CONSTRAINT FK_F0D6EE40602FAFFB96F82E1690E0342DEF6BE237 FOREIGN KEY (meeting_type, meeting_number, decision_point, decision_number) REFERENCES Decision (meeting_type, meeting_number, point, number) NOT DEFERRABLE INITIALLY IMMEDIATE;
ALTER TABLE SubDecision ADD CONSTRAINT FK_F0D6EE40D665E01D FOREIGN KEY (lidnr) REFERENCES Member (lidnr) NOT DEFERRABLE INITIALLY IMMEDIATE;
ALTER TABLE SubDecision ADD CONSTRAINT FK_F0D6EE40EFBA85FF292FAD512F37B76A76CE18779986E2D FOREIGN KEY (r_meeting_type, r_meeting_number, r_decision_point, r_decision_number, r_number) REFERENCES SubDecision (meeting_type, meeting_number, decision_point, decision_number, number) NOT DEFERRABLE INITIALLY IMMEDIATE;
ALTER TABLE Address ADD CONSTRAINT FK_C2F3561DD665E01D FOREIGN KEY (lidnr) REFERENCES Member (lidnr) NOT DEFERRABLE INITIALLY IMMEDIATE;