CREATE TABLE TBMODELO_ATRIBUTO (
    ID INTEGER NOT NULL,
    MODELO_ID INTEGER DEFAULT 0,
    ATRIBUTO_ID INTEGER DEFAULT 0);

ALTER TABLE TBMODELO_ATRIBUTO
ADD CONSTRAINT PK_TBMODELO_ATRIBUTO
PRIMARY KEY (ID);

CREATE SEQUENCE GTBMODELO_ATRIBUTO;

SET TERM ^ ;

create trigger ttbmodelo_atributo_b01i for tbmodelo_atributo
active before insert position 0
as
begin
  if (new.id is null) then
    new.id = gen_id(gtbmodelo_atributo,1);
end
^

SET TERM ; ^

CREATE INDEX ITBMODELO_ATRIBUTO_01
ON TBMODELO_ATRIBUTO (MODELO_ID);

CREATE INDEX ITBMODELO_ATRIBUTO_02
ON TBMODELO_ATRIBUTO (ATRIBUTO_ID);

