-
Notifications
You must be signed in to change notification settings - Fork 0
/
db3.sql
110 lines (82 loc) · 4.13 KB
/
db3.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
-- Valentina Studio --
-- MySQL dump --
-- ---------------------------------------------------------
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
-- ---------------------------------------------------------
-- CREATE TABLE "children" ---------------------------------
CREATE TABLE `children` (
`id` Int( 255 ) AUTO_INCREMENT NOT NULL,
`name` VarChar( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
PRIMARY KEY ( `id` )
,
CONSTRAINT `unique_id` UNIQUE( `id` ) )
CHARACTER SET = utf8
COLLATE = utf8_general_ci
ENGINE = InnoDB
AUTO_INCREMENT = 1;
-- ---------------------------------------------------------
-- CREATE TABLE "children_to_parents" ----------------------
CREATE TABLE `children_to_parents` (
`parent_id` Int( 255 ) NULL,
`children_id` Int( 255 ) NULL
)
CHARACTER SET = utf8
COLLATE = utf8_general_ci
ENGINE = InnoDB;
-- ---------------------------------------------------------
-- CREATE TABLE "parents" ----------------------------------
CREATE TABLE `parents` (
`id` Int( 255 ) AUTO_INCREMENT NOT NULL,
`login` VarChar( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`password` VarChar( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
PRIMARY KEY ( `id` )
)
CHARACTER SET = utf8
COLLATE = utf8_general_ci
ENGINE = InnoDB
AUTO_INCREMENT = 1;
-- ---------------------------------------------------------
-- CREATE TABLE "tokens" -----------------------------------
CREATE TABLE `tokens` (
`id` Int( 255 ) AUTO_INCREMENT NOT NULL,
`parent_id` Int( 255 ) NOT NULL,
`token` VarChar( 256 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`type` Int( 255 ) NOT NULL,
PRIMARY KEY ( `id` )
)
CHARACTER SET = utf8
COLLATE = utf8_general_ci
ENGINE = InnoDB
AUTO_INCREMENT = 1;
-- ---------------------------------------------------------
-- CREATE INDEX "index_id" ---------------------------------
CREATE INDEX `index_id` USING BTREE ON `children`( `id` );
-- ---------------------------------------------------------
-- CREATE INDEX "fk_children_to_parents_1_idx" -------------
CREATE INDEX `fk_children_to_parents_1_idx` USING BTREE ON `children_to_parents`( `children_id` );
-- ---------------------------------------------------------
-- CREATE INDEX "fk_children_to_parents_to_parents_idx" ----
CREATE INDEX `fk_children_to_parents_to_parents_idx` USING BTREE ON `children_to_parents`( `parent_id` );
-- ---------------------------------------------------------
-- CREATE INDEX "fk_tokens_to_parent_idx" ------------------
CREATE INDEX `fk_tokens_to_parent_idx` USING BTREE ON `tokens`( `parent_id` );
-- ---------------------------------------------------------
-- CREATE LINK "fk_children_to_parents_to_parents" ---------
ALTER TABLE `children_to_parents` ADD CONSTRAINT `fk_children_to_parents_to_parents` FOREIGN KEY ( `parent_id` ) REFERENCES `parents`( `id` ) ON DELETE Cascade ON UPDATE Cascade;
-- ---------------------------------------------------------
-- CREATE LINK "fk_children_to_parents_to_children" --------
ALTER TABLE `children_to_parents` ADD CONSTRAINT `fk_children_to_parents_to_children` FOREIGN KEY ( `children_id` ) REFERENCES `children`( `id` ) ON DELETE Cascade ON UPDATE Cascade;
-- ---------------------------------------------------------
-- CREATE LINK "fk_tokens_to_parent" -----------------------
ALTER TABLE `tokens` ADD CONSTRAINT `fk_tokens_to_parent` FOREIGN KEY ( `parent_id` ) REFERENCES `parents`( `id` ) ON DELETE No Action ON UPDATE No Action;
-- ---------------------------------------------------------
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
-- ---------------------------------------------------------