/* Created 03/03/2008 Modified 25/11/2011 Project Model Company Author Version Database PostgreSQL 8.1 */ /* Create Tables */ Create table "aeroporto" ( "siglaaero" Varchar NOT NULL, "nomeaero" Varchar, primary key ("siglaaero") ) Without Oids; Create table "atendimento" ( "codcidade" int NOT NULL, "siglaaero" Varchar NOT NULL, "distanciaaero" int NOT NULL, primary key ("codcidade","siglaaero") ) Without Oids; Create table "cidade" ( "codcidade" int NOT NULL, "nomecidade" Varchar NOT NULL, "codpais" int NOT NULL, primary key ("codcidade") ) Without Oids; Create table "filial" ( "codfilial" int NOT NULL, "enderecofilial" Varchar NOT NULL, "codcidade" int NOT NULL, "siglaaero" Varchar NOT NULL, primary key ("codfilial") ) Without Oids; Create table "pais" ( "codpais" int NOT NULL, "nomepais" Varchar NOT NULL, primary key ("codpais") ) Without Oids; /* Create Foreign Keys */ Alter table "atendimento" add foreign key ("siglaaero") references "aeroporto" ("siglaaero"); Alter table "atendimento" add foreign key ("codcidade") references "cidade" ("codcidade"); Alter table "filial" add foreign key ("codcidade") references "cidade" ("codcidade"); Alter table "cidade" add foreign key ("codpais") references "pais" ("codpais"); Alter table "filial" add foreign key ("siglaaero") references "aeroporto" ("siglaaero");