CREATE TABLE SensorDeboraVitoria (
  idSensorDeboraVitoria INTEGER UNSIGNED  NOT NULL   AUTO_INCREMENT,
  Nome VARCHAR(15)  NULL  ,
  Contador INTEGER UNSIGNED  NULL DEFAULT 0   ,
PRIMARY KEY(idSensorDeboraVitoria));



CREATE TABLE UsuarioDeboraVitoria (
  idUsuarioDeboraVitoria INTEGER UNSIGNED  NOT NULL   AUTO_INCREMENT,
  Login VARCHAR(25)  NULL  ,
  Nome VARCHAR(50)  NULL  ,
  Senha VARCHAR(15)  NULL    ,
PRIMARY KEY(idUsuarioDeboraVitoria));



CREATE TABLE Mac (
  idMac VARCHAR(17)  NOT NULL  ,
  Nome VARCHAR(35)  NULL  ,
  Contador INTEGER UNSIGNED  NULL DEFAULT 0   ,
PRIMARY KEY(idMac));



CREATE TABLE LeituraDeboraVitoria (
  idLeituraDeboraVitoria INTEGER UNSIGNED  NOT NULL   AUTO_INCREMENT,
  SensorDeboraVitoria_idSensorDeboraVitoria INTEGER UNSIGNED  NOT NULL  ,
  Mac_idMac VARCHAR(17)  NOT NULL  ,
  DataLeitura DATE  NULL  ,
  HoraLeitura TEXT  NULL  ,
  ValorSensor REAL  NULL    ,
PRIMARY KEY(idLeituraDeboraVitoria)  ,
INDEX LeituraDeboraVitoria_FKIndex1(Mac_idMac)  ,
INDEX LeituraDeboraVitoria_FKIndex2(SensorDeboraVitoria_idSensorDeboraVitoria),
  FOREIGN KEY(Mac_idMac)
    REFERENCES Mac(idMac)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
  FOREIGN KEY(SensorDeboraVitoria_idSensorDeboraVitoria)
    REFERENCES SensorDeboraVitoria(idSensorDeboraVitoria)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION);




