-- C:\Andy\svn\WEBMIP\Schema\mip.con
--
-- Generated for Oracle 10g on Fri Feb 08  15:56:52 2008 by Server Generator 10.1.2.6.18
  
PROMPT Creating Primary Key on 'SYSTEM_CONFIGURATION'
ALTER TABLE SYSTEM_CONFIGURATION
 ADD (CONSTRAINT SYCO_PK PRIMARY KEY 
  (PARAMETER)
 USING INDEX 
 INITRANS 2
 MAXTRANS 255
 PCTFREE 10
 STORAGE
 (
   INITIAL 65536
   MINEXTENTS 1
   MAXEXTENTS UNLIMITED
 ))
/

PROMPT Creating Primary Key on 'REGULATORS'
ALTER TABLE REGULATORS
 ADD (CONSTRAINT REGU_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'SERVICE_PRESSURE_TYPES'
ALTER TABLE SERVICE_PRESSURE_TYPES
 ADD (CONSTRAINT SVCPT_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'PARTY_ADDRESS_ROLES'
ALTER TABLE PARTY_ADDRESS_ROLES
 ADD (CONSTRAINT PAR_PK PRIMARY KEY 
  (START_DATE
  ,PADDR_START_DATE
  ,PADDR_ADDR_CODE
  ,PADDR_PRTY_ID
  ,RT_CODE))
/

PROMPT Creating Primary Key on 'QUOTE_REASONING'
ALTER TABLE QUOTE_REASONING
 ADD (CONSTRAINT QURE_PK PRIMARY KEY 
  (ID))
/

PROMPT Creating Primary Key on 'DATA_ITEM_ROLES'
ALTER TABLE DATA_ITEM_ROLES
 ADD (CONSTRAINT DIR_PK PRIMARY KEY 
  (TABLE_NAME
  ,FIELD_NAME
  ,CONDITION
  ,ENTY_CODE))
/

PROMPT Creating Primary Key on 'CONTACT_MECHANISMS'
ALTER TABLE CONTACT_MECHANISMS
 ADD (CONSTRAINT COME_PK PRIMARY KEY 
  (ID))
/

PROMPT Creating Primary Key on 'QUOTE_STATUSES'
ALTER TABLE QUOTE_STATUSES
 ADD (CONSTRAINT QUST_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'PARTY_CONTACT_MECHANISMS'
ALTER TABLE PARTY_CONTACT_MECHANISMS
 ADD (CONSTRAINT PCM_PK PRIMARY KEY 
  (START_DATE
  ,PRTY_ID
  ,COME_ID))
/

PROMPT Creating Primary Key on 'CARE_CATEGORIES'
ALTER TABLE CARE_CATEGORIES
 ADD (CONSTRAINT CACA_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'RELIEF_VALVE_TYPES'
ALTER TABLE RELIEF_VALVE_TYPES
 ADD (CONSTRAINT RVTY_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'CAVEAT_TEXTS'
ALTER TABLE CAVEAT_TEXTS
 ADD (CONSTRAINT CATE_PK PRIMARY KEY 
  (ID))
/

PROMPT Creating Primary Key on 'CONNECTION_ORIENTATIONS'
ALTER TABLE CONNECTION_ORIENTATIONS
 ADD (CONSTRAINT CNOR_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'REGIONS'
ALTER TABLE REGIONS
 ADD (CONSTRAINT REGI_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'METER_SIZE_CODES'
ALTER TABLE METER_SIZE_CODES
 ADD (CONSTRAINT MESC_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'COSTS'
ALTER TABLE COSTS
 ADD (CONSTRAINT COST_PK PRIMARY KEY 
  (ID))
/

PROMPT Creating Primary Key on 'DOCUMENTS'
ALTER TABLE DOCUMENTS
 ADD (CONSTRAINT DOCU_PK PRIMARY KEY 
  (ID))
/

PROMPT Creating Primary Key on 'CONTACT_MECHANISM_TYPES'
ALTER TABLE CONTACT_MECHANISM_TYPES
 ADD (CONSTRAINT COMT_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'DOCUMENT_EVENTS'
ALTER TABLE DOCUMENT_EVENTS
 ADD (CONSTRAINT DOEV_PK PRIMARY KEY 
  (ID))
/

PROMPT Creating Primary Key on 'FILTERS'
ALTER TABLE FILTERS
 ADD (CONSTRAINT FLTR_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'PARTY_CONTACT_MECHANISM_ROLES'
ALTER TABLE PARTY_CONTACT_MECHANISM_ROLES
 ADD (CONSTRAINT PCMR_PK PRIMARY KEY 
  (START_DATE
  ,PCM_START_DATE
  ,PCM_PRTY_ID
  ,PCM_COME_ID
  ,RT_CODE))
/

PROMPT Creating Primary Key on 'QUOTE_ROLES'
ALTER TABLE QUOTE_ROLES
 ADD (CONSTRAINT QURO_PK PRIMARY KEY 
  (PRTY_ID
  ,QUTE_ID
  ,RT_CODE
  ,START_DATE))
/

PROMPT Creating Primary Key on 'QUOTES'
ALTER TABLE QUOTES
 ADD (CONSTRAINT QUTE_PK PRIMARY KEY 
  (ID))
/

PROMPT Creating Primary Key on 'PARTY_RELATIONSHIPS'
ALTER TABLE PARTY_RELATIONSHIPS
 ADD (CONSTRAINT PREL_PK PRIMARY KEY 
  (START_DATE
  ,TO_PARL_ID
  ,TO_PARL_PRTY_ID
  ,TO_PARL_RT_CODE
  ,FROM_PARL_ID
  ,FROM_PARL_PRTY_ID
  ,FROM_PARL_RT_CODE))
/

PROMPT Creating Primary Key on 'QUOTE_EVENTS'
ALTER TABLE QUOTE_EVENTS
 ADD (CONSTRAINT QUEV_PK PRIMARY KEY 
  (ID))
/

PROMPT Creating Primary Key on 'PARTY_ADDRESSES'
ALTER TABLE PARTY_ADDRESSES
 ADD (CONSTRAINT PADDR_PK PRIMARY KEY 
  (START_DATE
  ,ADDR_CODE
  ,PRTY_ID))
/

PROMPT Creating Primary Key on 'SERVICE_PRESSURES'
ALTER TABLE SERVICE_PRESSURES
 ADD (CONSTRAINT SVCP_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'ENQUIRY_EVENTS'
ALTER TABLE ENQUIRY_EVENTS
 ADD (CONSTRAINT ENEV_PK PRIMARY KEY 
  (ID))
/

PROMPT Creating Primary Key on 'PARTIES'
ALTER TABLE PARTIES
 ADD (CONSTRAINT PRTY_PK PRIMARY KEY 
  (ID))
/

PROMPT Creating Primary Key on 'POSTCODES'
ALTER TABLE POSTCODES
 ADD (CONSTRAINT POCO_PK PRIMARY KEY 
  (ID))
/

PROMPT Creating Primary Key on 'ENQUIRY_TYPES'
ALTER TABLE ENQUIRY_TYPES
 ADD (CONSTRAINT ENTY_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'DOCUMENT_ROLES'
ALTER TABLE DOCUMENT_ROLES
 ADD (CONSTRAINT DORO_PK PRIMARY KEY 
  (ID))
/

PROMPT Creating Primary Key on 'QUOTE_ITEMS'
ALTER TABLE QUOTE_ITEMS
 ADD (CONSTRAINT QUIT_PK PRIMARY KEY 
  (ID))
/

PROMPT Creating Primary Key on 'ROLE_TYPES'
ALTER TABLE ROLE_TYPES
 ADD (CONSTRAINT RT_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'PASSWORDS'
ALTER TABLE PASSWORDS
 ADD (CONSTRAINT PWD_PK PRIMARY KEY 
  (PRTY_ID
  ,CREATED_ON))
/

PROMPT Creating Primary Key on 'ASSET_LOCATION_TYPES'
ALTER TABLE ASSET_LOCATION_TYPES
 ADD (CONSTRAINT ALTY_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'CONNECTION_TYPES'
ALTER TABLE CONNECTION_TYPES
 ADD (CONSTRAINT CNTY_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'METERS'
ALTER TABLE METERS
 ADD (CONSTRAINT METR_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'SLAMSHUT_VALVES'
ALTER TABLE SLAMSHUT_VALVES
 ADD (CONSTRAINT SLVA_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'ENQUIRY_ROLES'
ALTER TABLE ENQUIRY_ROLES
 ADD (CONSTRAINT ENRO_PK PRIMARY KEY 
  (PRTY_ID
  ,ENQU_ID
  ,RT_CODE
  ,START_DATE))
/

PROMPT Creating Primary Key on 'DOCUMENT_STATUS_TYPES'
ALTER TABLE DOCUMENT_STATUS_TYPES
 ADD (CONSTRAINT DOST_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'ERROR_LOGS'
ALTER TABLE ERROR_LOGS
 ADD (CONSTRAINT ERLO_PK PRIMARY KEY 
  (ERLO_ID)
 USING INDEX 
 INITRANS 2
 MAXTRANS 255
 PCTFREE 10
 STORAGE
 (
   INITIAL 65536
   MINEXTENTS 1
   MAXEXTENTS UNLIMITED
 ))
/

PROMPT Creating Primary Key on 'SLAMSHUT_TYPES'
ALTER TABLE SLAMSHUT_TYPES
 ADD (CONSTRAINT SLTY_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'ENQUIRY_STATUS_TYPES'
ALTER TABLE ENQUIRY_STATUS_TYPES
 ADD (CONSTRAINT ENST_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'ENQUIRIES'
ALTER TABLE ENQUIRIES
 ADD (CONSTRAINT ENQU_PK PRIMARY KEY 
  (ID))
/

PROMPT Creating Primary Key on 'RELIEF_VALVES'
ALTER TABLE RELIEF_VALVES
 ADD (CONSTRAINT REVA_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'HOUSING_TYPES'
ALTER TABLE HOUSING_TYPES
 ADD (CONSTRAINT HOTY_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'PARTY_RELATIONSHIP_TYPES'
ALTER TABLE PARTY_RELATIONSHIP_TYPES
 ADD (CONSTRAINT PRTP_PK PRIMARY KEY 
  (TO_RT_CODE
  ,FROM_RT_CODE))
/

PROMPT Creating Primary Key on 'BASES'
ALTER TABLE BASES
 ADD (CONSTRAINT BAS_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'APEX_AUTHORIZATION'
ALTER TABLE APEX_AUTHORIZATION
 ADD (CONSTRAINT AUTH_PK PRIMARY KEY 
  (PRIVILEGE
  ,COMPONENT_TYPE
  ,COMPONENT_NAME
  ,RT_CODE))
/

PROMPT Creating Primary Key on 'REGULATOR_TYPES'
ALTER TABLE REGULATOR_TYPES
 ADD (CONSTRAINT RETY_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'METER_TYPES'
ALTER TABLE METER_TYPES
 ADD (CONSTRAINT METY_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'MODULES'
ALTER TABLE MODULES
 ADD (CONSTRAINT MODU_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'HOUSINGS'
ALTER TABLE HOUSINGS
 ADD (CONSTRAINT HOU_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'REGI_ENQU_EXCLUSIONS'
ALTER TABLE REGI_ENQU_EXCLUSIONS
 ADD (CONSTRAINT REEX_PK PRIMARY KEY 
  (ID))
/

PROMPT Creating Primary Key on 'BYPASS_REASONS'
ALTER TABLE BYPASS_REASONS
 ADD (CONSTRAINT BYRE_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'EXCEPTION_MESSAGES'
ALTER TABLE EXCEPTION_MESSAGES
 ADD (CONSTRAINT EXME_PK PRIMARY KEY 
  (EXCEPTION_NUMBER)
 USING INDEX 
 INITRANS 2
 MAXTRANS 255
 PCTFREE 10
 STORAGE
 (
   INITIAL 65536
   MINEXTENTS 1
   MAXEXTENTS UNLIMITED
 ))
/

PROMPT Creating Primary Key on 'FILTER_TYPES'
ALTER TABLE FILTER_TYPES
 ADD (CONSTRAINT FITY_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'ADDRESSES'
ALTER TABLE ADDRESSES
 ADD (CONSTRAINT ADDR_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'DRAWINGS'
ALTER TABLE DRAWINGS
 ADD (CONSTRAINT DRWG_PK PRIMARY KEY 
  (CODE))
/

PROMPT Creating Primary Key on 'PARTY_ROLES'
ALTER TABLE PARTY_ROLES
 ADD (CONSTRAINT PARL_PK PRIMARY KEY 
  (ID
  ,PRTY_ID
  ,RT_CODE))
/

PROMPT Creating Primary Key on 'ADDITIONAL_ITEMS'
ALTER TABLE ADDITIONAL_ITEMS
 ADD (CONSTRAINT ADIT_PK PRIMARY KEY 
  (CODE))
/


PROMPT Creating Unique Key on 'POSTCODES'
ALTER TABLE POSTCODES
 ADD (CONSTRAINT POCO_POCO_UK UNIQUE 
  (OUTCODE
  ,INCODE))
/

PROMPT Creating Unique Key on 'DOCUMENT_ROLES'
ALTER TABLE DOCUMENT_ROLES
 ADD (CONSTRAINT DORO_DORO_UK UNIQUE 
  (DOCU_ID
  ,RT_CODE
  ,START_DATE))
/

PROMPT Creating Unique Key on 'REGI_ENQU_EXCLUSIONS'
ALTER TABLE REGI_ENQU_EXCLUSIONS
 ADD (CONSTRAINT REEX_REEX_UK UNIQUE 
  (REGI_CODE
  ,ENTY_CODE
  ,ADIT_CODE))
/

               
PROMPT Creating Check Constraint on 'METER_SIZE_CODES'
ALTER TABLE METER_SIZE_CODES
 ADD (CONSTRAINT AVCON_1202486212_VALID_000 CHECK (VALID_FOR_EXISTING_METER IN ('YES', 'NO')))
/

PROMPT Creating Check Constraint on 'METER_SIZE_CODES'
ALTER TABLE METER_SIZE_CODES
 ADD (CONSTRAINT AVCON_1202486212_VALID_001 CHECK (VALID_FOR_NEW_METER IN ('YES', 'NO')))
/
 
PROMPT Creating Check Constraint on 'COSTS'
ALTER TABLE COSTS
 ADD (CONSTRAINT AVCON_1202486212_COST__000 CHECK (COST_TYPE 
IN ('LACO', 'BACO', 'MOCO', 'MECO', 'AICO', 'HOCO', 'COST')))
/
 
PROMPT Creating Check Constraint on 'DOCUMENTS'
ALTER TABLE DOCUMENTS
 ADD (CONSTRAINT AVCON_1202486212_DOCU__000 CHECK (DOCU_TYPE IN ('DOCU', 'INDO', 'EXDO', 'FIDO')))
/
      
PROMPT Creating Check Constraint on 'QUOTES'
ALTER TABLE QUOTES
 ADD (CONSTRAINT AVCON_1202486212_QUTE__000 CHECK (QUTE_TYPE IN ('AQ', 'MQ', 'QUTE')))
/
 
PROMPT Creating Check Constraint on 'PARTY_RELATIONSHIPS'
ALTER TABLE PARTY_RELATIONSHIPS
 ADD (CONSTRAINT PARL_PRTP_MISMATCH CHECK (from_parl_rt_code = from_prtp_rt_code
and
to_parl_rt_code = to_prtp_rt_code))
/
     
PROMPT Creating Check Constraint on 'PARTIES'
ALTER TABLE PARTIES
 ADD (CONSTRAINT AVCON_1202486212_TRIPA_000 CHECK (TRIPARTITE_MEMBER IN ('YES', 'NO')))
/

PROMPT Creating Check Constraint on 'PARTIES'
ALTER TABLE PARTIES
 ADD (CONSTRAINT AVCON_1202486212_STATU_000 CHECK (STATUS IN ('OPEN', 'EXPIRED', 'LOCKED')))
/

PROMPT Creating Check Constraint on 'PARTIES'
ALTER TABLE PARTIES
 ADD (CONSTRAINT AVCON_1202486212_PRTY__000 CHECK (PRTY_TYPE 
IN ('PRTY', 'IO', 'EO', 'MKTP', 'PERS', 'MANU', 'NEMP', 'EMP', 'ORG'
)))
/
    
PROMPT Creating Check Constraint on 'DOCUMENT_ROLES'
ALTER TABLE DOCUMENT_ROLES
 ADD (CONSTRAINT DORO_CK CHECK ((
(DORO_TYPE='ENDO' and ENQU_ID is not null)
OR
(DORO_TYPE='DRRO' and DRWG_CODE is not null)
OR
(DORO_TYPE='QUDO' and QUTE_ID is not null)
)))
/

PROMPT Creating Check Constraint on 'DOCUMENT_ROLES'
ALTER TABLE DOCUMENT_ROLES
 ADD (CONSTRAINT AVCON_1202486212_DORO__000 CHECK (DORO_TYPE IN ('DRRO', 'DORO', 'ENDO', 'QUDO')))
/
 
PROMPT Creating Check Constraint on 'QUOTE_ITEMS'
ALTER TABLE QUOTE_ITEMS
 ADD (CONSTRAINT AVCON_1202486212_QUIT__000 CHECK (QUIT_TYPE IN ('LQI', 'AQI', 'BQI', 'MQI', 'QUIT', 'HQI')))
/
 
PROMPT Creating Check Constraint on 'ROLE_TYPES'
ALTER TABLE ROLE_TYPES
 ADD (CONSTRAINT AVCON_1202486212_RT_TY_000 CHECK (RT_TYPE IN ('DORT', 'PART', 'RT', 'PCMRT', 'QURT', 'ENRT', 'PRT')))
/
           
PROMPT Creating Check Constraint on 'ENQUIRIES'
ALTER TABLE ENQUIRIES
 ADD (CONSTRAINT AVCON_1202486212_DOWNS_000 CHECK (DOWNSTREAM_BOOSTER_OR_COMPRESS IN ('YES', 'NO')))
/

PROMPT Creating Check Constraint on 'ENQUIRIES'
ALTER TABLE ENQUIRIES
 ADD (CONSTRAINT AVCON_1202486212_INDIC_000 CHECK (INDICATIVE_TIME IN ('DY', 'AM', 'PM')))
/

PROMPT Creating Check Constraint on 'ENQUIRIES'
ALTER TABLE ENQUIRIES
 ADD (CONSTRAINT AVCON_1202486212_HOUSI_000 CHECK (HOUSING_REQUIRED IN ('YES', 'NO')))
/

PROMPT Creating Check Constraint on 'ENQUIRIES'
ALTER TABLE ENQUIRIES
 ADD (CONSTRAINT AVCON_1202486212_BASE__000 CHECK (BASE_REQUIRED IN ('YES', 'NO')))
/

PROMPT Creating Check Constraint on 'ENQUIRIES'
ALTER TABLE ENQUIRIES
 ADD (CONSTRAINT AVCON_1202486212_CONVE_000 CHECK (CONVERTOR_REQUIRED IN ('YES', 'NO')))
/

PROMPT Creating Check Constraint on 'ENQUIRIES'
ALTER TABLE ENQUIRIES
 ADD (CONSTRAINT AVCON_1202486212_AMR_R_000 CHECK (AMR_REQUIRED IN ('YES', 'NO')))
/

PROMPT Creating Check Constraint on 'ENQUIRIES'
ALTER TABLE ENQUIRIES
 ADD (CONSTRAINT AVCON_1202486212_EMS_R_000 CHECK (EMS_REQUIRED IN ('YES', 'NO')))
/

PROMPT Creating Check Constraint on 'ENQUIRIES'
ALTER TABLE ENQUIRIES
 ADD (CONSTRAINT AVCON_1202486212_TWIN__000 CHECK (TWIN_STREAM_REQUIRED IN ('YES', 'NO')))
/

PROMPT Creating Check Constraint on 'ENQUIRIES'
ALTER TABLE ENQUIRIES
 ADD (CONSTRAINT AVCON_1202486212_EXIST_000 CHECK (EXISTING_LOGGER IN ('YES', 'NO')))
/

PROMPT Creating Check Constraint on 'ENQUIRIES'
ALTER TABLE ENQUIRIES
 ADD (CONSTRAINT AVCON_1202486212_LOAD__000 CHECK (LOAD_CONTROL_TYPE IN ('Constant', 'On/Off', 'Modulating')))
/

PROMPT Creating Check Constraint on 'ENQUIRIES'
ALTER TABLE ENQUIRIES
 ADD (CONSTRAINT AVCON_1202486212_EXIST_001 CHECK (EXISTING_METER_OWNER IN ('S', 'T', 'C')))
/

PROMPT Creating Check Constraint on 'ENQUIRIES'
ALTER TABLE ENQUIRIES
 ADD (CONSTRAINT AVCON_1202486212_EXIST_002 CHECK (EXISTING_CONVERTOR IN ('YES', 'NO')))
/

PROMPT Creating Check Constraint on 'ENQUIRIES'
ALTER TABLE ENQUIRIES
 ADD (CONSTRAINT AVCON_1202486212_MARKE_000 CHECK (MARKET_SECTOR_CODE IN ('I', 'D')))
/
                 

PROMPT Creating Foreign Key on 'REGULATORS'
ALTER TABLE REGULATORS ADD (CONSTRAINT
 REGU_RETY_FK FOREIGN KEY 
  (RETY_CODE) REFERENCES REGULATOR_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'PARTY_ADDRESS_ROLES'
ALTER TABLE PARTY_ADDRESS_ROLES ADD (CONSTRAINT
 PAR_PADDR_FK FOREIGN KEY 
  (PADDR_START_DATE
  ,PADDR_ADDR_CODE
  ,PADDR_PRTY_ID) REFERENCES PARTY_ADDRESSES
  (START_DATE
  ,ADDR_CODE
  ,PRTY_ID))
/

PROMPT Creating Foreign Key on 'PARTY_ADDRESS_ROLES'
ALTER TABLE PARTY_ADDRESS_ROLES ADD (CONSTRAINT
 PAR_RT_FK FOREIGN KEY 
  (RT_CODE) REFERENCES ROLE_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'QUOTE_REASONING'
ALTER TABLE QUOTE_REASONING ADD (CONSTRAINT
 QURE_ENQU_FK FOREIGN KEY 
  (ENQU_ID) REFERENCES ENQUIRIES
  (ID))
/

PROMPT Creating Foreign Key on 'DATA_ITEM_ROLES'
ALTER TABLE DATA_ITEM_ROLES ADD (CONSTRAINT
 DIR_ENTY_FK FOREIGN KEY 
  (ENTY_CODE) REFERENCES ENQUIRY_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'CONTACT_MECHANISMS'
ALTER TABLE CONTACT_MECHANISMS ADD (CONSTRAINT
 COME_COMT_FK FOREIGN KEY 
  (COMT_CODE) REFERENCES CONTACT_MECHANISM_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'PARTY_CONTACT_MECHANISMS'
ALTER TABLE PARTY_CONTACT_MECHANISMS ADD (CONSTRAINT
 PCM_COME_FK FOREIGN KEY 
  (COME_ID) REFERENCES CONTACT_MECHANISMS
  (ID))
/

PROMPT Creating Foreign Key on 'PARTY_CONTACT_MECHANISMS'
ALTER TABLE PARTY_CONTACT_MECHANISMS ADD (CONSTRAINT
 PCM_PRTY_FK FOREIGN KEY 
  (PRTY_ID) REFERENCES PARTIES
  (ID))
/

PROMPT Creating Foreign Key on 'PARTY_CONTACT_MECHANISMS'
ALTER TABLE PARTY_CONTACT_MECHANISMS ADD (CONSTRAINT
 PCM_PADDR_FK FOREIGN KEY 
  (PADDR_START_DATE
  ,PADDR_ADDR_CODE
  ,PADDR_PRTY_ID) REFERENCES PARTY_ADDRESSES
  (START_DATE
  ,ADDR_CODE
  ,PRTY_ID))
/

PROMPT Creating Foreign Key on 'CAVEAT_TEXTS'
ALTER TABLE CAVEAT_TEXTS ADD (CONSTRAINT
 CATE_METY_FK FOREIGN KEY 
  (METY_CODE) REFERENCES METER_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'CAVEAT_TEXTS'
ALTER TABLE CAVEAT_TEXTS ADD (CONSTRAINT
 CATE_SVCPT_FK FOREIGN KEY 
  (SVCPT_CODE) REFERENCES SERVICE_PRESSURE_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'CAVEAT_TEXTS'
ALTER TABLE CAVEAT_TEXTS ADD (CONSTRAINT
 CATE_ENTY_FK FOREIGN KEY 
  (ENTY_CODE) REFERENCES ENQUIRY_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'COSTS'
ALTER TABLE COSTS ADD (CONSTRAINT
 COST_ENTY_FK FOREIGN KEY 
  (ENTY_CODE) REFERENCES ENQUIRY_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'COSTS'
ALTER TABLE COSTS ADD (CONSTRAINT
 COST_HOU_FK FOREIGN KEY 
  (HOU_CODE) REFERENCES HOUSINGS
  (CODE))
/

PROMPT Creating Foreign Key on 'COSTS'
ALTER TABLE COSTS ADD (CONSTRAINT
 COST_METR_FK FOREIGN KEY 
  (METR_CODE) REFERENCES METERS
  (CODE))
/

PROMPT Creating Foreign Key on 'COSTS'
ALTER TABLE COSTS ADD (CONSTRAINT
 COST_MESC_FK FOREIGN KEY 
  (MESC_CODE) REFERENCES METER_SIZE_CODES
  (CODE))
/

PROMPT Creating Foreign Key on 'COSTS'
ALTER TABLE COSTS ADD (CONSTRAINT
 COST_MODU_FK FOREIGN KEY 
  (MODU_CODE) REFERENCES MODULES
  (CODE))
/

PROMPT Creating Foreign Key on 'COSTS'
ALTER TABLE COSTS ADD (CONSTRAINT
 COST_ADIT_FK FOREIGN KEY 
  (ADIT_CODE) REFERENCES ADDITIONAL_ITEMS
  (CODE))
/

PROMPT Creating Foreign Key on 'COSTS'
ALTER TABLE COSTS ADD (CONSTRAINT
 COST_REGI_FK FOREIGN KEY 
  (REGI_CODE) REFERENCES REGIONS
  (CODE))
/

PROMPT Creating Foreign Key on 'COSTS'
ALTER TABLE COSTS ADD (CONSTRAINT
 COST_METY_FK FOREIGN KEY 
  (METY_CODE) REFERENCES METER_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'COSTS'
ALTER TABLE COSTS ADD (CONSTRAINT
 COST_BAS_FK FOREIGN KEY 
  (BAS_CODE) REFERENCES BASES
  (CODE))
/

PROMPT Creating Foreign Key on 'COSTS'
ALTER TABLE COSTS ADD (CONSTRAINT
 COST_SVCPT_FK FOREIGN KEY 
  (SVCPT_CODE) REFERENCES SERVICE_PRESSURE_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'DOCUMENT_EVENTS'
ALTER TABLE DOCUMENT_EVENTS ADD (CONSTRAINT
 DOEV_DOST_FK FOREIGN KEY 
  (DOST_CODE) REFERENCES DOCUMENT_STATUS_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'DOCUMENT_EVENTS'
ALTER TABLE DOCUMENT_EVENTS ADD (CONSTRAINT
 DOEV_DOCU_FK FOREIGN KEY 
  (DOCU_ID) REFERENCES DOCUMENTS
  (ID))
/

PROMPT Creating Foreign Key on 'FILTERS'
ALTER TABLE FILTERS ADD (CONSTRAINT
 FLTR_FITY_FK FOREIGN KEY 
  (FITY_CODE) REFERENCES FILTER_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'PARTY_CONTACT_MECHANISM_ROLES'
ALTER TABLE PARTY_CONTACT_MECHANISM_ROLES ADD (CONSTRAINT
 PCMR_RT_FK FOREIGN KEY 
  (RT_CODE) REFERENCES ROLE_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'PARTY_CONTACT_MECHANISM_ROLES'
ALTER TABLE PARTY_CONTACT_MECHANISM_ROLES ADD (CONSTRAINT
 PCMR_PCM_FK FOREIGN KEY 
  (PCM_START_DATE
  ,PCM_PRTY_ID
  ,PCM_COME_ID) REFERENCES PARTY_CONTACT_MECHANISMS
  (START_DATE
  ,PRTY_ID
  ,COME_ID))
/

PROMPT Creating Foreign Key on 'QUOTE_ROLES'
ALTER TABLE QUOTE_ROLES ADD (CONSTRAINT
 QURO_PRTY_FK FOREIGN KEY 
  (PRTY_ID) REFERENCES PARTIES
  (ID))
/

PROMPT Creating Foreign Key on 'QUOTE_ROLES'
ALTER TABLE QUOTE_ROLES ADD (CONSTRAINT
 QURO_QUTE_FK FOREIGN KEY 
  (QUTE_ID) REFERENCES QUOTES
  (ID))
/

PROMPT Creating Foreign Key on 'QUOTE_ROLES'
ALTER TABLE QUOTE_ROLES ADD (CONSTRAINT
 QURO_RT_FK FOREIGN KEY 
  (RT_CODE) REFERENCES ROLE_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'QUOTES'
ALTER TABLE QUOTES ADD (CONSTRAINT
 QUTE_ENQU_FK FOREIGN KEY 
  (ENQU_ID) REFERENCES ENQUIRIES
  (ID))
/

PROMPT Creating Foreign Key on 'PARTY_RELATIONSHIPS'
ALTER TABLE PARTY_RELATIONSHIPS ADD (CONSTRAINT
 PREL_PARL_TO_FK FOREIGN KEY 
  (TO_PARL_ID
  ,TO_PARL_PRTY_ID
  ,TO_PARL_RT_CODE) REFERENCES PARTY_ROLES
  (ID
  ,PRTY_ID
  ,RT_CODE))
/

PROMPT Creating Foreign Key on 'PARTY_RELATIONSHIPS'
ALTER TABLE PARTY_RELATIONSHIPS ADD (CONSTRAINT
 PREL_PRTP_FK FOREIGN KEY 
  (TO_PRTP_RT_CODE
  ,FROM_PRTP_RT_CODE) REFERENCES PARTY_RELATIONSHIP_TYPES
  (TO_RT_CODE
  ,FROM_RT_CODE))
/

PROMPT Creating Foreign Key on 'PARTY_RELATIONSHIPS'
ALTER TABLE PARTY_RELATIONSHIPS ADD (CONSTRAINT
 PREL_PARL_FROM_FK FOREIGN KEY 
  (FROM_PARL_ID
  ,FROM_PARL_PRTY_ID
  ,FROM_PARL_RT_CODE) REFERENCES PARTY_ROLES
  (ID
  ,PRTY_ID
  ,RT_CODE))
/

PROMPT Creating Foreign Key on 'QUOTE_EVENTS'
ALTER TABLE QUOTE_EVENTS ADD (CONSTRAINT
 QUEV_QUTE_FK FOREIGN KEY 
  (QUTE_ID) REFERENCES QUOTES
  (ID))
/

PROMPT Creating Foreign Key on 'QUOTE_EVENTS'
ALTER TABLE QUOTE_EVENTS ADD (CONSTRAINT
 QUEV_QUST_FK FOREIGN KEY 
  (QUST_CODE) REFERENCES QUOTE_STATUSES
  (CODE))
/

PROMPT Creating Foreign Key on 'PARTY_ADDRESSES'
ALTER TABLE PARTY_ADDRESSES ADD (CONSTRAINT
 PADDR_PRTY_FK FOREIGN KEY 
  (PRTY_ID) REFERENCES PARTIES
  (ID))
/

PROMPT Creating Foreign Key on 'PARTY_ADDRESSES'
ALTER TABLE PARTY_ADDRESSES ADD (CONSTRAINT
 PADDR_ADDR_FK FOREIGN KEY 
  (ADDR_CODE) REFERENCES ADDRESSES
  (CODE))
/

PROMPT Creating Foreign Key on 'SERVICE_PRESSURES'
ALTER TABLE SERVICE_PRESSURES ADD (CONSTRAINT
 SVCP_SVCPT_FK FOREIGN KEY 
  (SVCPT_CODE) REFERENCES SERVICE_PRESSURE_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'ENQUIRY_EVENTS'
ALTER TABLE ENQUIRY_EVENTS ADD (CONSTRAINT
 ENEV_ENQU_FK FOREIGN KEY 
  (ENQU_ID) REFERENCES ENQUIRIES
  (ID))
/

PROMPT Creating Foreign Key on 'ENQUIRY_EVENTS'
ALTER TABLE ENQUIRY_EVENTS ADD (CONSTRAINT
 ENEV_ENST_FK FOREIGN KEY 
  (ENST_CODE) REFERENCES ENQUIRY_STATUS_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'POSTCODES'
ALTER TABLE POSTCODES ADD (CONSTRAINT
 POCO_REGI_FK FOREIGN KEY 
  (REGI_CODE) REFERENCES REGIONS
  (CODE))
/

PROMPT Creating Foreign Key on 'DOCUMENT_ROLES'
ALTER TABLE DOCUMENT_ROLES ADD (CONSTRAINT
 DORO_DRWG_FK FOREIGN KEY 
  (DRWG_CODE) REFERENCES DRAWINGS
  (CODE))
/

PROMPT Creating Foreign Key on 'DOCUMENT_ROLES'
ALTER TABLE DOCUMENT_ROLES ADD (CONSTRAINT
 DORO_RT_FK FOREIGN KEY 
  (RT_CODE) REFERENCES ROLE_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'DOCUMENT_ROLES'
ALTER TABLE DOCUMENT_ROLES ADD (CONSTRAINT
 DORO_QUTE_FK FOREIGN KEY 
  (QUTE_ID) REFERENCES QUOTES
  (ID))
/

PROMPT Creating Foreign Key on 'DOCUMENT_ROLES'
ALTER TABLE DOCUMENT_ROLES ADD (CONSTRAINT
 DORO_ENQU_FK FOREIGN KEY 
  (ENQU_ID) REFERENCES ENQUIRIES
  (ID))
/

PROMPT Creating Foreign Key on 'DOCUMENT_ROLES'
ALTER TABLE DOCUMENT_ROLES ADD (CONSTRAINT
 DORO_DOCU_FK FOREIGN KEY 
  (DOCU_ID) REFERENCES DOCUMENTS
  (ID))
/

PROMPT Creating Foreign Key on 'QUOTE_ITEMS'
ALTER TABLE QUOTE_ITEMS ADD (CONSTRAINT
 QUIT_SVCPT_FK FOREIGN KEY 
  (SVCPT_CODE) REFERENCES SERVICE_PRESSURE_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'QUOTE_ITEMS'
ALTER TABLE QUOTE_ITEMS ADD (CONSTRAINT
 QUIT_MESC_FK FOREIGN KEY 
  (MESC_CODE) REFERENCES METER_SIZE_CODES
  (CODE))
/

PROMPT Creating Foreign Key on 'QUOTE_ITEMS'
ALTER TABLE QUOTE_ITEMS ADD (CONSTRAINT
 QUIT_ENTY_FK FOREIGN KEY 
  (ENTY_CODE) REFERENCES ENQUIRY_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'QUOTE_ITEMS'
ALTER TABLE QUOTE_ITEMS ADD (CONSTRAINT
 QUIT_ADIT_FK FOREIGN KEY 
  (ADIT_CODE) REFERENCES ADDITIONAL_ITEMS
  (CODE))
/

PROMPT Creating Foreign Key on 'QUOTE_ITEMS'
ALTER TABLE QUOTE_ITEMS ADD (CONSTRAINT
 QUIT_HOU_FK FOREIGN KEY 
  (HOU_CODE) REFERENCES HOUSINGS
  (CODE))
/

PROMPT Creating Foreign Key on 'QUOTE_ITEMS'
ALTER TABLE QUOTE_ITEMS ADD (CONSTRAINT
 QUIT_MODU_FK FOREIGN KEY 
  (MODU_CODE) REFERENCES MODULES
  (CODE))
/

PROMPT Creating Foreign Key on 'QUOTE_ITEMS'
ALTER TABLE QUOTE_ITEMS ADD (CONSTRAINT
 QUIT_BAS_FK FOREIGN KEY 
  (BAS_CODE) REFERENCES BASES
  (CODE))
/

PROMPT Creating Foreign Key on 'QUOTE_ITEMS'
ALTER TABLE QUOTE_ITEMS ADD (CONSTRAINT
 QUIT_METY_FK FOREIGN KEY 
  (METY_CODE) REFERENCES METER_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'QUOTE_ITEMS'
ALTER TABLE QUOTE_ITEMS ADD (CONSTRAINT
 QUIT_QUTE_FK FOREIGN KEY 
  (QUTE_ID) REFERENCES QUOTES
  (ID))
/

PROMPT Creating Foreign Key on 'PASSWORDS'
ALTER TABLE PASSWORDS ADD (CONSTRAINT
 PWD_PRTY_FK FOREIGN KEY 
  (PRTY_ID) REFERENCES PARTIES
  (ID))
/

PROMPT Creating Foreign Key on 'METERS'
ALTER TABLE METERS ADD (CONSTRAINT
 METR_DRWG_FK FOREIGN KEY 
  (DRWG_CODE) REFERENCES DRAWINGS
  (CODE))
/

PROMPT Creating Foreign Key on 'METERS'
ALTER TABLE METERS ADD (CONSTRAINT
 METR_METY_FK FOREIGN KEY 
  (METY_CODE) REFERENCES METER_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'METERS'
ALTER TABLE METERS ADD (CONSTRAINT
 METR_PRTY_FK FOREIGN KEY 
  (PRTY_ID) REFERENCES PARTIES
  (ID))
/

PROMPT Creating Foreign Key on 'SLAMSHUT_VALVES'
ALTER TABLE SLAMSHUT_VALVES ADD (CONSTRAINT
 SLVA_SLTY_FK FOREIGN KEY 
  (SLTY_CODE) REFERENCES SLAMSHUT_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'ENQUIRY_ROLES'
ALTER TABLE ENQUIRY_ROLES ADD (CONSTRAINT
 ENRO_ENQU_FK FOREIGN KEY 
  (ENQU_ID) REFERENCES ENQUIRIES
  (ID))
/

PROMPT Creating Foreign Key on 'ENQUIRY_ROLES'
ALTER TABLE ENQUIRY_ROLES ADD (CONSTRAINT
 ENRO_PRTY_FK FOREIGN KEY 
  (PRTY_ID) REFERENCES PARTIES
  (ID))
/

PROMPT Creating Foreign Key on 'ENQUIRY_ROLES'
ALTER TABLE ENQUIRY_ROLES ADD (CONSTRAINT
 ENRO_RT_FK FOREIGN KEY 
  (RT_CODE) REFERENCES ROLE_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'ENQUIRIES'
ALTER TABLE ENQUIRIES ADD (CONSTRAINT
 ENQU_ALTY_FK FOREIGN KEY 
  (ALTY_CODE) REFERENCES ASSET_LOCATION_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'ENQUIRIES'
ALTER TABLE ENQUIRIES ADD (CONSTRAINT
 ENQU_MESC_EXISTING_FK FOREIGN KEY 
  (EXISTING_MESC_CODE) REFERENCES METER_SIZE_CODES
  (CODE))
/

PROMPT Creating Foreign Key on 'ENQUIRIES'
ALTER TABLE ENQUIRIES ADD (CONSTRAINT
 ENQU_MESC_REQUIRED_FK FOREIGN KEY 
  (REQUIRED_MESC_CODE) REFERENCES METER_SIZE_CODES
  (CODE))
/

PROMPT Creating Foreign Key on 'ENQUIRIES'
ALTER TABLE ENQUIRIES ADD (CONSTRAINT
 ENQU_COMT_AGENT_FK FOREIGN KEY 
  (AGENT_COMT_CODE) REFERENCES CONTACT_MECHANISM_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'ENQUIRIES'
ALTER TABLE ENQUIRIES ADD (CONSTRAINT
 ENQU_CACA_FK FOREIGN KEY 
  (CACA_CODE) REFERENCES CARE_CATEGORIES
  (CODE))
/

PROMPT Creating Foreign Key on 'ENQUIRIES'
ALTER TABLE ENQUIRIES ADD (CONSTRAINT
 ENQU_SVCP_REQUIRED_FK FOREIGN KEY 
  (REQUIRED_SVCP_CODE) REFERENCES SERVICE_PRESSURES
  (CODE))
/

PROMPT Creating Foreign Key on 'ENQUIRIES'
ALTER TABLE ENQUIRIES ADD (CONSTRAINT
 ENQU_ENTY_FK FOREIGN KEY 
  (ENTY_CODE) REFERENCES ENQUIRY_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'ENQUIRIES'
ALTER TABLE ENQUIRIES ADD (CONSTRAINT
 ENQU_METY_FK FOREIGN KEY 
  (EXISTING_METY_CODE) REFERENCES METER_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'RELIEF_VALVES'
ALTER TABLE RELIEF_VALVES ADD (CONSTRAINT
 REVA_RVTY_FK FOREIGN KEY 
  (RVTY_CODE) REFERENCES RELIEF_VALVE_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'PARTY_RELATIONSHIP_TYPES'
ALTER TABLE PARTY_RELATIONSHIP_TYPES ADD (CONSTRAINT
 PRTP_RT_FROM_FK FOREIGN KEY 
  (FROM_RT_CODE) REFERENCES ROLE_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'PARTY_RELATIONSHIP_TYPES'
ALTER TABLE PARTY_RELATIONSHIP_TYPES ADD (CONSTRAINT
 PRTP_RT_FK FOREIGN KEY 
  (TO_RT_CODE) REFERENCES ROLE_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'BASES'
ALTER TABLE BASES ADD (CONSTRAINT
 BAS_DRWG_FK FOREIGN KEY 
  (DRWG_CODE) REFERENCES DRAWINGS
  (CODE))
/

PROMPT Creating Foreign Key on 'APEX_AUTHORIZATION'
ALTER TABLE APEX_AUTHORIZATION ADD (CONSTRAINT
 AUTH_RT_FK FOREIGN KEY 
  (RT_CODE) REFERENCES ROLE_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'MODULES'
ALTER TABLE MODULES ADD (CONSTRAINT
 MODU_SLVA_FK FOREIGN KEY 
  (SLVA_CODE) REFERENCES SLAMSHUT_VALVES
  (CODE))
/

PROMPT Creating Foreign Key on 'MODULES'
ALTER TABLE MODULES ADD (CONSTRAINT
 MODU_FLTR_FK FOREIGN KEY 
  (FLTR_CODE) REFERENCES FILTERS
  (CODE))
/

PROMPT Creating Foreign Key on 'MODULES'
ALTER TABLE MODULES ADD (CONSTRAINT
 MODU_CNOR_OUTLET_FK FOREIGN KEY 
  (OUTLET_CNOR_CODE) REFERENCES CONNECTION_ORIENTATIONS
  (CODE))
/

PROMPT Creating Foreign Key on 'MODULES'
ALTER TABLE MODULES ADD (CONSTRAINT
 MODU_CNTY_INLET_FK FOREIGN KEY 
  (INLET_CNTY_CODE) REFERENCES CONNECTION_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'MODULES'
ALTER TABLE MODULES ADD (CONSTRAINT
 MODU_REVA_FK FOREIGN KEY 
  (REVA_CODE) REFERENCES RELIEF_VALVES
  (CODE))
/

PROMPT Creating Foreign Key on 'MODULES'
ALTER TABLE MODULES ADD (CONSTRAINT
 MODU_METR_FK FOREIGN KEY 
  (METR_CODE) REFERENCES METERS
  (CODE))
/

PROMPT Creating Foreign Key on 'MODULES'
ALTER TABLE MODULES ADD (CONSTRAINT
 MODU_DRWG_FK FOREIGN KEY 
  (DRWG_CODE) REFERENCES DRAWINGS
  (CODE))
/

PROMPT Creating Foreign Key on 'MODULES'
ALTER TABLE MODULES ADD (CONSTRAINT
 MODU_CNTY_OUTLET_FK FOREIGN KEY 
  (OUTLET_CNTY_CODE) REFERENCES CONNECTION_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'MODULES'
ALTER TABLE MODULES ADD (CONSTRAINT
 MODU_SVCP_FK FOREIGN KEY 
  (SVCP_CODE) REFERENCES SERVICE_PRESSURES
  (CODE))
/

PROMPT Creating Foreign Key on 'MODULES'
ALTER TABLE MODULES ADD (CONSTRAINT
 MODU_CNOR_INLET_FK FOREIGN KEY 
  (INLET_CNOR_CODE) REFERENCES CONNECTION_ORIENTATIONS
  (CODE))
/

PROMPT Creating Foreign Key on 'MODULES'
ALTER TABLE MODULES ADD (CONSTRAINT
 MODU_REGU_FK FOREIGN KEY 
  (REGU_CODE) REFERENCES REGULATORS
  (CODE))
/

PROMPT Creating Foreign Key on 'MODULES'
ALTER TABLE MODULES ADD (CONSTRAINT
 MODU_BAS_FK FOREIGN KEY 
  (BAS_CODE) REFERENCES BASES
  (CODE))
/

PROMPT Creating Foreign Key on 'MODULES'
ALTER TABLE MODULES ADD (CONSTRAINT
 MODU_HOU_FK FOREIGN KEY 
  (HOU_CODE) REFERENCES HOUSINGS
  (CODE))
/

PROMPT Creating Foreign Key on 'MODULES'
ALTER TABLE MODULES ADD (CONSTRAINT
 MODU_PRTY_FK FOREIGN KEY 
  (PRTY_ID) REFERENCES PARTIES
  (ID))
/

PROMPT Creating Foreign Key on 'HOUSINGS'
ALTER TABLE HOUSINGS ADD (CONSTRAINT
 HOU_HOTY_FK FOREIGN KEY 
  (HOTY_CODE) REFERENCES HOUSING_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'HOUSINGS'
ALTER TABLE HOUSINGS ADD (CONSTRAINT
 HOU_PRTY_FK FOREIGN KEY 
  (PRTY_ID) REFERENCES PARTIES
  (ID))
/

PROMPT Creating Foreign Key on 'HOUSINGS'
ALTER TABLE HOUSINGS ADD (CONSTRAINT
 HOU_DRWG_FK FOREIGN KEY 
  (DRWG_CODE) REFERENCES DRAWINGS
  (CODE))
/

PROMPT Creating Foreign Key on 'REGI_ENQU_EXCLUSIONS'
ALTER TABLE REGI_ENQU_EXCLUSIONS ADD (CONSTRAINT
 REEX_ADIT_FK FOREIGN KEY 
  (ADIT_CODE) REFERENCES ADDITIONAL_ITEMS
  (CODE))
/

PROMPT Creating Foreign Key on 'REGI_ENQU_EXCLUSIONS'
ALTER TABLE REGI_ENQU_EXCLUSIONS ADD (CONSTRAINT
 REEX_REGI_FK FOREIGN KEY 
  (REGI_CODE) REFERENCES REGIONS
  (CODE))
/

PROMPT Creating Foreign Key on 'REGI_ENQU_EXCLUSIONS'
ALTER TABLE REGI_ENQU_EXCLUSIONS ADD (CONSTRAINT
 REEX_ENTY_FK FOREIGN KEY 
  (ENTY_CODE) REFERENCES ENQUIRY_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'PARTY_ROLES'
ALTER TABLE PARTY_ROLES ADD (CONSTRAINT
 PARL_RT_FK FOREIGN KEY 
  (RT_CODE) REFERENCES ROLE_TYPES
  (CODE))
/

PROMPT Creating Foreign Key on 'PARTY_ROLES'
ALTER TABLE PARTY_ROLES ADD (CONSTRAINT
 PARL_PRTY_FK FOREIGN KEY 
  (PRTY_ID) REFERENCES PARTIES
  (ID))
/


