-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateDDL.sql
18 lines (18 loc) · 2.61 KB
/
createDDL.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
CREATE TABLE T_USER (ID BIGINT NOT NULL, AGE INTEGER, DEPARTMENT VARCHAR(130), EMAIL VARCHAR(130), FULLNAME VARCHAR(130), GENDERSTRING VARCHAR(130), PASSWORDHASH VARCHAR(130), ROLESTRING VARCHAR(130), USERNAME VARCHAR(100) UNIQUE, ACCOUNT_ID BIGINT, PRIMARY KEY (ID))
CREATE TABLE T_TRANSACTION (ID BIGINT NOT NULL, AMOUNT BIGINT, CHECKEDBYMARKETMAKER TINYINT(1) default 0, ORDERTYPE VARCHAR(130), PRICEATTRADE BIGINT, STATE VARCHAR(130), TIMESTAMP_FIELD DATETIME, ACCOUNT_ID BIGINT, STATEMENT_ID BIGINT, PRIMARY KEY (ID))
CREATE TABLE t_statement (ID BIGINT AUTO_INCREMENT NOT NULL, CURRENTVALUE BIGINT, DESCRIPTION1 VARCHAR(130), DESCRIPTION2 VARCHAR(130), DESCRIPTION3 VARCHAR(130), DESCRIPTION4 VARCHAR(130), TITLE VARCHAR(130), VOTESTARTED TINYINT(1) default 0, PRIMARY KEY (ID))
CREATE TABLE T_ACCOUNT (ID BIGINT AUTO_INCREMENT NOT NULL, COINTELS BIGINT, PRIMARY KEY (ID))
CREATE TABLE T_IDEA (ID BIGINT NOT NULL, COMPANY VARCHAR(130), DESCRIPTION1 VARCHAR(130), DESCRIPTION2 VARCHAR(130), DESCRIPTION3 VARCHAR(130), DESCRIPTION4 VARCHAR(130), TITLE VARCHAR(130), USER_ID BIGINT, PRIMARY KEY (ID))
CREATE TABLE T_SHORTSELL (ID BIGINT NOT NULL, AMOUNT BIGINT, ACCOUNT_ID BIGINT, TRANSACTION_ID BIGINT, PRIMARY KEY (ID))
CREATE TABLE T_STATEMENTSTAKE (ID BIGINT NOT NULL, SHARESCOUNT BIGINT, ACCOUNT_ID BIGINT, STATEMENT_ID BIGINT, PRIMARY KEY (ID))
CREATE TABLE T_ACCOUNT_T_IDEA (Account_ID BIGINT NOT NULL, ideas_ID BIGINT NOT NULL, PRIMARY KEY (Account_ID, ideas_ID))
ALTER TABLE T_USER ADD CONSTRAINT FK_T_USER_ACCOUNT_ID FOREIGN KEY (ACCOUNT_ID) REFERENCES T_ACCOUNT (ID)
ALTER TABLE T_TRANSACTION ADD CONSTRAINT FK_T_TRANSACTION_ACCOUNT_ID FOREIGN KEY (ACCOUNT_ID) REFERENCES T_ACCOUNT (ID)
ALTER TABLE T_TRANSACTION ADD CONSTRAINT FK_T_TRANSACTION_STATEMENT_ID FOREIGN KEY (STATEMENT_ID) REFERENCES t_statement (ID)
ALTER TABLE T_IDEA ADD CONSTRAINT FK_T_IDEA_USER_ID FOREIGN KEY (USER_ID) REFERENCES T_USER (ID)
ALTER TABLE T_SHORTSELL ADD CONSTRAINT FK_T_SHORTSELL_ACCOUNT_ID FOREIGN KEY (ACCOUNT_ID) REFERENCES T_ACCOUNT (ID)
ALTER TABLE T_SHORTSELL ADD CONSTRAINT FK_T_SHORTSELL_TRANSACTION_ID FOREIGN KEY (TRANSACTION_ID) REFERENCES T_TRANSACTION (ID)
ALTER TABLE T_STATEMENTSTAKE ADD CONSTRAINT FK_T_STATEMENTSTAKE_ACCOUNT_ID FOREIGN KEY (ACCOUNT_ID) REFERENCES T_ACCOUNT (ID)
ALTER TABLE T_STATEMENTSTAKE ADD CONSTRAINT FK_T_STATEMENTSTAKE_STATEMENT_ID FOREIGN KEY (STATEMENT_ID) REFERENCES t_statement (ID)
ALTER TABLE T_ACCOUNT_T_IDEA ADD CONSTRAINT FK_T_ACCOUNT_T_IDEA_ideas_ID FOREIGN KEY (ideas_ID) REFERENCES T_IDEA (ID)
ALTER TABLE T_ACCOUNT_T_IDEA ADD CONSTRAINT FK_T_ACCOUNT_T_IDEA_Account_ID FOREIGN KEY (Account_ID) REFERENCES T_ACCOUNT (ID)