-
Notifications
You must be signed in to change notification settings - Fork 5
/
tables_mysql.sql
126 lines (107 loc) · 2.92 KB
/
tables_mysql.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
CREATE TABLE `PUBLISHER` (
ID BIGINT NOT NULL AUTO_INCREMENT,
VERSION INTEGER NOT NULL,
`NAME` VARCHAR(50),
`ADDRESS` VARCHAR(255),
PRIMARY KEY(ID)
)
ENGINE=InnoDB
DEFAULT CHARSET=utf8;
ALTER TABLE `PUBLISHER` AUTO_INCREMENT = 100;
CREATE TABLE `BOOK` (
ID BIGINT NOT NULL AUTO_INCREMENT,
VERSION INTEGER NOT NULL,
`NAME` VARCHAR(100),
`PUBLISHED` TIMESTAMP,
`PRICE` DECIMAL(18,4),
`PUBLISHER_ID` BIGINT,
PRIMARY KEY(ID)
)
ENGINE=InnoDB
DEFAULT CHARSET=utf8;
ALTER TABLE `BOOK` AUTO_INCREMENT = 100;
CREATE TABLE `BOOK_I18N` (
ID BIGINT NOT NULL AUTO_INCREMENT,
VERSION INTEGER NOT NULL,
BOOK_ID BIGINT NOT NULL,
`LANG` VARCHAR(10),
`TITLE` VARCHAR(100),
PRIMARY KEY(ID)
)
ENGINE=InnoDB
DEFAULT CHARSET=utf8;
ALTER TABLE `BOOK_I18N` AUTO_INCREMENT = 100;
CREATE TABLE `BOOK_BIN` (
ID BIGINT NOT NULL AUTO_INCREMENT,
VERSION INTEGER NOT NULL,
`HARDCOVER` LONGBLOB NOT NULL,
PRIMARY KEY(ID)
)
ENGINE=InnoDB
DEFAULT CHARSET=utf8;
ALTER TABLE `BOOK_BIN` AUTO_INCREMENT = 100;
CREATE TABLE `AUTHOR` (
ID BIGINT NOT NULL AUTO_INCREMENT,
VERSION INTEGER NOT NULL,
`NAME` VARCHAR(50),
`SECRET` VARCHAR(50),
PRIMARY KEY(ID)
)
ENGINE=InnoDB
DEFAULT CHARSET=utf8;
ALTER TABLE `AUTHOR` AUTO_INCREMENT = 100;
CREATE TABLE `AUTHOR_BOOK` (
AUTHOR_ID BIGINT NOT NULL,
BOOK_ID BIGINT NOT NULL,
PRIMARY KEY(AUTHOR_ID, BOOK_ID)
)
ENGINE=InnoDB
DEFAULT CHARSET=utf8;
ALTER TABLE `BOOK` ADD CONSTRAINT FK_BOOK1 FOREIGN KEY (`PUBLISHER_ID`) REFERENCES `PUBLISHER` (ID);
ALTER TABLE `AUTHOR_BOOK` ADD CONSTRAINT FK_AUTHOR_BOOK1 FOREIGN KEY (`AUTHOR_ID`) REFERENCES `AUTHOR` (ID);
ALTER TABLE `AUTHOR_BOOK` ADD CONSTRAINT FK_AUTHOR_BOOK2 FOREIGN KEY (`BOOK_ID`) REFERENCES `BOOK` (ID);
ALTER TABLE `BOOK_BIN` ADD CONSTRAINT FK_BOOK_BIN1 FOREIGN KEY (`ID`) REFERENCES `BOOK` (`ID`);
ALTER TABLE `BOOK_I18N` ADD CONSTRAINT FK_BOOK_I18N1 FOREIGN KEY (`BOOK_ID`) REFERENCES `BOOK` (ID);
ALTER TABLE `BOOK_I18N` ADD CONSTRAINT UK_BOOK_I18N1 UNIQUE (`BOOK_ID`, `LANG`);
CREATE TABLE `PROJECT` (
ID BIGINT NOT NULL AUTO_INCREMENT,
VERSION INTEGER NOT NULL,
`NAME` VARCHAR(50),
MANAGER_ID BIGINT NOT NULL,
MANAGER_TYPE CHAR(1) NOT NULL,
`STATUS_COD` VARCHAR(50),
PRIMARY KEY(ID)
)
ENGINE=InnoDB
DEFAULT CHARSET=utf8;
ALTER TABLE `PROJECT` AUTO_INCREMENT = 100;
CREATE TABLE `CONSULTANT` (
ID BIGINT NOT NULL AUTO_INCREMENT,
VERSION INTEGER NOT NULL,
`NAME` VARCHAR(50),
PRIMARY KEY(ID)
)
ENGINE=InnoDB
DEFAULT CHARSET=utf8;
ALTER TABLE `CONSULTANT` AUTO_INCREMENT = 100;
CREATE TABLE `EMPLOYEE` (
ID BIGINT NOT NULL AUTO_INCREMENT,
VERSION INTEGER NOT NULL,
`FIRST_NAME` VARCHAR(50),
`LAST_NAME` VARCHAR(50),
PRIMARY KEY(ID)
)
ENGINE=InnoDB
DEFAULT CHARSET=utf8;
ALTER TABLE `EMPLOYEE` AUTO_INCREMENT = 100;
CREATE TABLE `CATALOG` (
ID BIGINT NOT NULL AUTO_INCREMENT,
VERSION INTEGER NOT NULL,
`DOMAIN` VARCHAR(10),
`KEY` VARCHAR(50),
`VALUE` VARCHAR(500),
PRIMARY KEY(ID)
)
ENGINE=InnoDB
DEFAULT CHARSET=utf8;
ALTER TABLE `CATALOG` AUTO_INCREMENT = 100;