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

CREATE GENERATOR ID_ANDROID_SETUP;

CREATE TABLE ANDROID_SETUP (
    ID           INTEGER NOT NULL,
    ID_CENOVNIK  INTEGER,
    ID_DOKUMENT  INTEGER,
    ID_MAGACINA  INTEGER
);




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

ALTER TABLE ANDROID_SETUP ADD CONSTRAINT PK_ANDROID_SETUP PRIMARY KEY (ID);


/******************************************************************************/
/****                             Foreign keys                             ****/
/******************************************************************************/

ALTER TABLE ANDROID_SETUP ADD CONSTRAINT FK_ANDROID_SETUP_1 FOREIGN KEY (ID_CENOVNIK) REFERENCES TIP_CENOVNIKA (ID);
ALTER TABLE ANDROID_SETUP ADD CONSTRAINT FK_ANDROID_SETUP_2 FOREIGN KEY (ID_DOKUMENT) REFERENCES TBLDOKUMENTI (SIFRA_DOKUMENTA);
ALTER TABLE ANDROID_SETUP ADD CONSTRAINT FK_ANDROID_SETUP_3 FOREIGN KEY (ID_MAGACINA) REFERENCES TBLMAGACIN (SIFRA_MAGACINA);
SET TERM ^ ;



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


/* Trigger: ID_PRED_STASTAV_TMP */
CREATE OR ALTER TRIGGER ID_ANDROID_SETUP_TRIG FOR ANDROID_SETUP
ACTIVE BEFORE INSERT POSITION 0
AS
  BEGIN
   new.id = GEN_ID(ID_ANDROID_SETUP, 1);
  END
^
SET TERM ; ^


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