Last active
December 12, 2015 09:19
-
-
Save metametaclass/4750713 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --==================================================================================== | |
| --==================================================================================== | |
| /*MeteoSensors*/; | |
| /*Датчики*/; | |
| create table MeteoSensors( | |
| SENS_ID integer not null, | |
| SENS_Key STR_OBJID, | |
| SENS_Name STR_NAME, | |
| SENS_Position integer, | |
| SENS_KoefA double precision, | |
| SENS_KoefB double precision, | |
| SENS_Unit STR_NAME, | |
| SENS_Skip MBOOLEAN, | |
| constraint PK_MeteoSensors primary key (SENS_ID) | |
| ); | |
| create generator genSENS_ID; | |
| set term ^ ; | |
| create or alter trigger tidMeteoSensors | |
| for MeteoSensors | |
| active Before insert | |
| as | |
| begin | |
| new.SENS_ID=next value for genSENS_ID; | |
| end^ | |
| set term ; ^ | |
| ; | |
| --==================================================================================== | |
| --==================================================================================== | |
| /*MeteoLog*/; | |
| /*Лог измерений*/; | |
| create table MeteoLog( | |
| ML_ID bigint not null, | |
| ML_SENS_ID t2int_id not null, | |
| ML_DTSERVER timestamp default current_timestamp not null, | |
| ML_DT timestamp not null, | |
| ML_Value numeric(18,4) not null, | |
| ML_CalcValue numeric(18,4) not null, | |
| constraint PK_MeteoLog primary key (ML_ID) | |
| ); | |
| create index idxMeteoLog on MeteoLog(ML_SENS_ID,ML_DT); | |
| create generator genML_ID; | |
| set term ^ ; | |
| create or alter trigger tidMeteoLog | |
| for MeteoLog | |
| active Before insert | |
| as | |
| begin | |
| new.ML_ID=next value for genML_ID; | |
| end^ | |
| set term ; ^ | |
| ; | |
| alter table MeteoLog | |
| add constraint FK_ML_SENS_ID foreign key (ML_SENS_ID) | |
| references MeteoSensors(SENS_ID) ; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment