-
Notifications
You must be signed in to change notification settings - Fork 0
/
database-init.sql
44 lines (39 loc) · 1.04 KB
/
database-init.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
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'172.17.0.2' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;
CREATE DATABASE hyph;
USE hyph;
CREATE TABLE patterns
(
pattern_id int auto_increment
primary key,
pattern varchar(50) not null,
constraint patterns_pattern_uindex
unique (pattern)
);
CREATE TABLE words
(
word_id int auto_increment
primary key,
word_h varchar(50) null,
word varchar(50) not null,
constraint words_word_uindex
unique (word)
);
CREATE TABLE word_patterns
(
id int auto_increment
primary key,
word_id int null,
pattern_id int null,
constraint word_patterns_unique
unique (word_id, pattern_id),
constraint word_patterns_patterns_pattern_id_fk
foreign key (pattern_id) references patterns (pattern_id)
on update cascade
on delete cascade,
constraint word_patterns_words_word_id_fk
foreign key (word_id) references words (word_id)
on update cascade
on delete cascade
);