/*****************************************************************************
*
* Filename         - $Workfile:   bmm_routes.sql  $
*
*                     Name              Date      Version     CR Number
* Author           - See revision history below.
* Last Update      - See revision history below.
*
* Project Name     - TAGTRAK(Oracle Database)
*
* Source Code
* Identifier       - 0/3/300/8010/112
*
* Design Spec
* Section          -
*
* Contents         - Live Schema: bmm_routes table and associated items
*
* Language         - Oracle SQL*Plus script
*
* Classification   - Commercial In Confidence
*
*          (c) Ultra Electronics Limited, 2006
*
*****************************************************************************/

PROMPT Creating table BMM_ROUTES

CREATE TABLE bmm_routes (
   route_id                      NUMBER(10)  NOT NULL,
   site_id                       NUMBER(10)  NOT NULL,
   carrier                       VARCHAR2(3) NOT NULL,
   destination                   VARCHAR2(3),
   process_name                  CHAR(20),
   unit_name                     CHAR(10),
   subunit_name                  CHAR(4),
   dcsid                         CHAR(7),
   routing_data                  VARCHAR2(200),
   route_description             VARCHAR2(30),
   row_create_time               date,
   row_date_time                 date,
   cuser                         varchar2(30),
   muser                         varchar2(30),
   mterm                         varchar2(64),
   source                        varchar2(8),
   to_be_archived                varchar2(1),
   appn_row_id                   number(18) not null,
   system_id                     number(4) default 0 not null
);

alter table bmm_routes add (constraint bmm_routes_pk primary key (appn_row_id) using index tablespace &1._indexes);

ALTER TABLE bmm_routes add (CONSTRAINT bmm_routes_uk1 unique (route_id) USING INDEX TABLESPACE &1._indexes);

ALTER TABLE bmm_routes ADD (CONSTRAINT bmm_routes_fk_site_info FOREIGN KEY ( destination ) REFERENCES site_info( airport_code ));

ALTER TABLE bmm_routes ADD (CONSTRAINT bmm_routes_fk_system_cfg FOREIGN KEY ( process_name, unit_name, subunit_name, dcsid ) REFERENCES system_cfg( process_name, unit_name, subunit_name, dcsid ));

CREATE INDEX bmm_routes_sk1 ON bmm_routes(destination) TABLESPACE &1._indexes;

CREATE INDEX bmm_routes_sk2 ON bmm_routes(process_name, unit_name, subunit_name, dcsid) TABLESPACE &1._indexes;

COMMENT ON TABLE BMM_ROUTES IS 'This table is required to configure the routing information for Outgoing BMMs';

COMMENT ON COLUMN BMM_ROUTES.CARRIER IS  'The flight carrier';
COMMENT ON COLUMN BMM_ROUTES.DCSID IS  'Part of the unique DCS identifier';
COMMENT ON COLUMN BMM_ROUTES.DESTINATION IS  'The destination airport';
COMMENT ON COLUMN BMM_ROUTES.PROCESS_NAME IS  'Indicator of how this entry was created or last updated i.e. FIDS, DCS or DUMMY ';
COMMENT ON COLUMN BMM_ROUTES.ROUTE_DESCRIPTION IS  'Description of route';
COMMENT ON COLUMN BMM_ROUTES.ROUTE_ID IS  'The route identifier';
COMMENT ON COLUMN BMM_ROUTES.ROUTING_DATA IS  'Free format string';
COMMENT ON COLUMN BMM_ROUTES.SITE_ID IS  'The site identifier';
COMMENT ON COLUMN BMM_ROUTES.SUBUNIT_NAME IS  'Address stamp of the DCS which sent the BSM';
COMMENT ON COLUMN BMM_ROUTES.UNIT_NAME IS  'The UNIT_NAME from the SYSTEM_CFG table for the DCS that this entry was received from.';
COMMENT ON COLUMN BMM_ROUTES.APPN_ROW_ID IS 'Unique sequence number for this row';
COMMENT ON COLUMN BMM_ROUTES.ROW_CREATE_TIME IS 'The time the row was created';
COMMENT ON COLUMN BMM_ROUTES.ROW_DATE_TIME IS 'The time the row was last modified';
COMMENT ON COLUMN BMM_ROUTES.CUSER IS 'The user who created the row';
COMMENT ON COLUMN BMM_ROUTES.MUSER IS 'The user who last modified the row';
COMMENT ON COLUMN BMM_ROUTES.MTERM IS 'The terminal from which the last modifcation to this row was made';
COMMENT ON COLUMN BMM_ROUTES.SYSTEM_ID IS 'The system identifier';
COMMENT ON COLUMN BMM_ROUTES.SOURCE IS 'The process that last amended this row ';
COMMENT ON COLUMN BMM_ROUTES.TO_BE_ARCHIVED IS 'Indicates that this row is to be archived or has been archived';

