-
Notifications
You must be signed in to change notification settings - Fork 0
/
basesql.sql
149 lines (121 loc) · 4 KB
/
basesql.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# SQL Manager Lite for MySQL 5.5.1.45563
# ---------------------------------------
# Host : localhost
# Port : 3306
# Database : localdb
/*!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 */;
/*!40101 SET NAMES utf8 */;
SET FOREIGN_KEY_CHECKS=0;
CREATE DATABASE `localdb`
CHARACTER SET 'utf8'
COLLATE 'utf8_general_ci';
USE `localdb`;
#
# Структура для таблицы `template`:
#
CREATE TABLE `template` (
`id` INTEGER(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(45) COLLATE utf8_general_ci NOT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `id` (`id`) USING BTREE
) ENGINE=InnoDB
AUTO_INCREMENT=12 CHARACTER SET 'utf8' COLLATE 'utf8_general_ci'
;
#
# Структура для таблицы `analiz`:
#
CREATE TABLE `analiz` (
`id` INTEGER(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(45) COLLATE utf8_general_ci DEFAULT NULL,
`template_id` INTEGER(11) DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
KEY `fk_analiz_template1_idx` (`template_id`) USING BTREE,
CONSTRAINT `fk_analiz_template1` FOREIGN KEY (`template_id`) REFERENCES `template` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB
AUTO_INCREMENT=10 CHARACTER SET 'utf8' COLLATE 'utf8_general_ci'
;
#
# Структура для таблицы `analiz_has_element`:
#
CREATE TABLE `analiz_has_element` (
`id` INTEGER(11) NOT NULL AUTO_INCREMENT,
`analiz_id` INTEGER(11) NOT NULL,
`element_id` INTEGER(11) NOT NULL,
`value` VARCHAR(45) COLLATE utf8_general_ci DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
KEY `fk_analiz_has_element_element1_idx` (`element_id`) USING BTREE,
KEY `fk_analiz_has_element_analiz1_idx` (`analiz_id`) USING BTREE
) ENGINE=InnoDB
AUTO_INCREMENT=14 CHARACTER SET 'utf8' COLLATE 'utf8_general_ci'
;
#
# Структура для таблицы `element`:
#
CREATE TABLE `element` (
`id` INTEGER(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(45) COLLATE utf8_general_ci NOT NULL,
PRIMARY KEY (`id`) USING BTREE,
KEY `id` (`id`) USING BTREE
) ENGINE=InnoDB
AUTO_INCREMENT=3 CHARACTER SET 'utf8' COLLATE 'utf8_general_ci'
;
#
# Структура для таблицы `template_has_element`:
#
CREATE TABLE `template_has_element` (
`id` INTEGER(11) NOT NULL AUTO_INCREMENT,
`template_id` INTEGER(11) NOT NULL,
`element_id` INTEGER(11) NOT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `id` (`id`) USING BTREE,
KEY `fk_template_has_element_element1_idx` (`element_id`) USING BTREE,
KEY `fk_template_has_element_template_idx` (`template_id`) USING BTREE,
CONSTRAINT `template_has_element_fk1` FOREIGN KEY (`template_id`) REFERENCES `template` (`id`) ON DELETE CASCADE,
CONSTRAINT `template_has_element_fk2` FOREIGN KEY (`element_id`) REFERENCES `element` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB
AUTO_INCREMENT=11 CHARACTER SET 'utf8' COLLATE 'utf8_general_ci'
;
#
# Data for the `template` table (LIMIT 0,500)
#
INSERT INTO `template` (`id`, `name`) VALUES
(11,'1 анализ');
COMMIT;
#
# Data for the `analiz` table (LIMIT 0,500)
#
INSERT INTO `analiz` (`id`, `name`, `template_id`) VALUES
(6,'1',11),
(7,'23',11),
(8,'434',11),
(9,'12',11);
COMMIT;
#
# Data for the `analiz_has_element` table (LIMIT 0,500)
#
INSERT INTO `analiz_has_element` (`id`, `analiz_id`, `element_id`, `value`) VALUES
(9,6,2,'123'),
(10,7,1,'3452'),
(11,7,2,'111'),
(12,8,2,'324'),
(13,9,1,'34');
COMMIT;
#
# Data for the `element` table (LIMIT 0,500)
#
INSERT INTO `element` (`id`, `name`) VALUES
(1,'1 элемент'),
(2,'2 элемент');
COMMIT;
#
# Data for the `template_has_element` table (LIMIT 0,500)
#
INSERT INTO `template_has_element` (`id`, `template_id`, `element_id`) VALUES
(9,11,1),
(10,11,2);
COMMIT;
/*!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 */;