I'm getting my data automatically from a PCD (weather station), if any of these data goes beyond the limit registered by the ADM, an alert will be shown to the user.
I have the following tables in my bank:
CREATE TABLE PARAMETROS_DE_ALERTAS (
PRA_ID INTEGER AUTO_INCREMENT PRIMARY KEY,
PRA_VALOR_MAXIMO INTEGER(5) NOT NULL,
PRA_VALOR_MINIMO INTEGER NOT NULL,
PRA_COR_MINIMA VARCHAR(30) NOT NULL,
PRA_COR_MAXIMA VARCHAR(30) NOT NULL,
SEN_ID INTEGER NOT NULL
);
This table is the parameter for the alerts, where the minimum and maximum measurement from the PCD will be registered for it to be an alert.
CREATE TABLE MEDICOES (
MED_ID INTEGER AUTO_INCREMENT PRIMARY KEY,
MED_DADO VARCHAR(10) NOT NULL,
MED_DATA_HORA_MEDICAO DATETIME NOT NULL,
API_ID INTEGER,
SEN_ID INTEGER NOT NULL
);
This is the measurement table, where you will save the data coming from PCD.
CREATE TABLE ALERTAS_CRITICOS (
ALC_DATA_HORA_ALERTA DATETIME NOT NULL,
ALC_ID INTEGER AUTO_INCREMENT PRIMARY KEY,
ALC_VALOR_MEDICAO FLOAT NOT NULL,
SEN_ID INTEGER NOT NULL
);
The system should add a record of this table if the measurement data is larger or smaller than the parameters. After this critical alert is registered, the system should display an alert to the user browsing any page of my site.
The problem is that I do not know how to check if a record has been added to the bank.