30 lines
1.1 KiB
MySQL
30 lines
1.1 KiB
MySQL
|
drop table ROOM_BUNTIDEVICE if exists;
|
||
|
drop table devices if exists;
|
||
|
drop table rooms if exists;
|
||
|
|
||
|
create table ROOM_BUNTIDEVICE (ROOM_ID integer not null, BUNTIDEVICE_ID int not null,
|
||
|
primary key (ROOM_ID, BUNTIDEVICE_ID), unique (BUNTIDEVICE_ID));
|
||
|
|
||
|
create table devices (DTYPE varchar(31) not null,
|
||
|
BUNTIDEVICE_ID integer generated by default as identity (start with 1),
|
||
|
deviceName varchar(255),
|
||
|
picture varchar(255),
|
||
|
startAddress integer,
|
||
|
primary key (BUNTIDEVICE_ID));
|
||
|
|
||
|
create table rooms (ROOM_ID integer generated by default as identity (start with 1),
|
||
|
floor varchar(255),
|
||
|
roomName varchar(255),
|
||
|
xCord integer not null,
|
||
|
yCord integer not null,
|
||
|
primary key (ROOM_ID));
|
||
|
|
||
|
alter table ROOM_BUNTIDEVICE add constraint FK96EF8F028BB4B62 foreign key (ROOM_ID) references rooms;
|
||
|
alter table ROOM_BUNTIDEVICE add constraint FK96EF8F021E9F392 foreign key (BUNTIDEVICE_ID) references devices;
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|