/******************************************************************************/
/****                                Tables                                ****/
/******************************************************************************/


CREATE GENERATOR GTBPAINEL_PROD_CONF_REL;

CREATE TABLE TBPAINEL_PROD_CONF_RELATORIO (
    ID                INTEGER NOT NULL,
    PAINEL_PROD_ID    INTEGER,
    RELATORIO_CODIGO  INTEGER,
    TEMPO             INTEGER DEFAULT 0
);




/******************************************************************************/
/****                             Primary keys                             ****/
/******************************************************************************/

ALTER TABLE TBPAINEL_PROD_CONF_RELATORIO ADD CONSTRAINT PK_TBPAINEL_PROD_CONF_RELATORIO PRIMARY KEY (ID);


/******************************************************************************/
/****                               Triggers                               ****/
/******************************************************************************/



SET TERM ^ ;



/******************************************************************************/
/****                         Triggers for tables                          ****/
/******************************************************************************/



/* Trigger: TTBPAINEL_PROD_CONF_RELAT_B01I */
CREATE OR ALTER TRIGGER TTBPAINEL_PROD_CONF_RELAT_B01I FOR TBPAINEL_PROD_CONF_RELATORIO
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
    IF (NEW.ID IS NULL) THEN
        NEW.ID = GEN_ID(GTBPAINEL_PROD_CONF_REL, 1);
END
^

SET TERM ; ^



/******************************************************************************/
/****                         Fields descriptions                          ****/
/******************************************************************************/

COMMENT ON COLUMN TBPAINEL_PROD_CONF_RELATORIO.TEMPO IS 
'Tempo em segundos';
