-
Notifications
You must be signed in to change notification settings - Fork 1
/
lighting.sql
162 lines (121 loc) · 5.34 KB
/
lighting.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
150
151
152
153
154
155
156
157
158
159
160
161
162
# ************************************************************
# Sequel Pro SQL dump
# Version 4541
#
# http://www.sequelpro.com/
# https://github.com/sequelpro/sequelpro
#
# Host: locutus (MySQL 5.5.5-10.0.31-MariaDB-1~jessie-wsrep)
# Database: lighting
# Generation Time: 2017-10-26 08:31:26 +0000
# ************************************************************
/*!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 */;
/*!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' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
# Dump of table buildings
# ------------------------------------------------------------
CREATE TABLE `buildings` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
# Dump of table floors
# ------------------------------------------------------------
CREATE TABLE `floors` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`level` int(11) NOT NULL,
`building_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `floors_fk0` (`building_id`),
CONSTRAINT `floors_fk0` FOREIGN KEY (`building_id`) REFERENCES `buildings` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
# Dump of table light_lighting_pattern
# ------------------------------------------------------------
CREATE TABLE `light_lighting_pattern` (
`pattern_id` int(11) NOT NULL,
`light_id` int(11) NOT NULL,
`state` varchar(10) NOT NULL,
PRIMARY KEY (`pattern_id`,`light_id`),
KEY `light_lighting_pattern_fk1` (`light_id`),
CONSTRAINT `light_lighting_pattern_fk0` FOREIGN KEY (`pattern_id`) REFERENCES `lighting_patterns` (`id`),
CONSTRAINT `light_lighting_pattern_fk1` FOREIGN KEY (`light_id`) REFERENCES `lights` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
# Dump of table lighting_controllers
# ------------------------------------------------------------
CREATE TABLE `lighting_controllers` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL,
`room_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `lighting_controllers_fk0` (`room_id`),
CONSTRAINT `lighting_controllers_fk0` FOREIGN KEY (`room_id`) REFERENCES `rooms` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
# Dump of table lighting_input_channels
# ------------------------------------------------------------
CREATE TABLE `lighting_input_channels` (
`id` int(11) NOT NULL,
`channel` int(11) NOT NULL,
`controller_id` int(11) NOT NULL,
`pattern_id` int(11) DEFAULT NULL,
`statefull` int(1) NOT NULL,
PRIMARY KEY (`id`),
KEY `lighting_input_channels_fk1` (`pattern_id`),
KEY `lighting_input_channels_fk0` (`controller_id`),
CONSTRAINT `lighting_input_channels_fk0` FOREIGN KEY (`controller_id`) REFERENCES `lighting_controllers` (`id`),
CONSTRAINT `lighting_input_channels_fk1` FOREIGN KEY (`pattern_id`) REFERENCES `lighting_patterns` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
# Dump of table lighting_output_channels
# ------------------------------------------------------------
CREATE TABLE `lighting_output_channels` (
`id` int(11) NOT NULL,
`channel` int(11) NOT NULL,
`controller_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `lighting_output_channels_fk0` (`controller_id`),
CONSTRAINT `lighting_output_channels_fk0` FOREIGN KEY (`controller_id`) REFERENCES `lighting_controllers` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
# Dump of table lighting_patterns
# ------------------------------------------------------------
CREATE TABLE `lighting_patterns` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`next_pattern_id` int(11) DEFAULT NULL,
`timeout` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `lighting_patterns_fk0` (`next_pattern_id`),
CONSTRAINT `lighting_patterns_fk0` FOREIGN KEY (`next_pattern_id`) REFERENCES `lighting_patterns` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
# Dump of table lights
# ------------------------------------------------------------
CREATE TABLE `lights` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT '',
`room_id` int(11) NOT NULL,
`output_channel_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `lights_fk0` (`room_id`),
KEY `lights_fk1` (`output_channel_id`),
CONSTRAINT `lights_fk0` FOREIGN KEY (`room_id`) REFERENCES `rooms` (`id`),
CONSTRAINT `lights_fk1` FOREIGN KEY (`output_channel_id`) REFERENCES `lighting_output_channels` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
# Dump of table rooms
# ------------------------------------------------------------
CREATE TABLE `rooms` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`floor_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `rooms_fk0` (`floor_id`),
CONSTRAINT `rooms_fk0` FOREIGN KEY (`floor_id`) REFERENCES `floors` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
/*!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 */;