/*****************************************************************************
*
* Filename              - bag_status.sql
*
* Project Name          - UltraTrak Database
*
* Source Code Identifier - UAS/URBRS/SS/10127
*
* Description           - Table creation script for BAG_STATUS.
*                         Lookup table, containing a list of the possible bag
*                         statuses and their index values.
*
* Language              - Oracle PL/SQL
*
* File History          - For the development history run the Show History report in PVCS
*
* Copyright Ultra Electronics Airport Systems, 2003
*
*****************************************************************************/

PROMPT Creating table TRACKING_EVENTS

create table tracking_events ( 
   description                   varchar2(60) not null, 
   event_no                      number (10)   not null, 
   link_event                    number (10), 
   mandatory_flag                varchar2(1)  not null, 
   automatic_flag                varchar2(1)  not null, 
   location                      char(6), 
   agent_code                    char(5)      not null, 
   group_name                    char(15), 
   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 tracking_events add ( constraint tracking_events_pk primary key (appn_row_id) using index tablespace &1._indexes);

alter table tracking_events add ( constraint tracking_events_uk1 unique (event_no) using index tablespace &1._indexes);

alter table tracking_events add constraint tracking_events_mand_flag_ch check ( mandatory_flag in ('Y','N'));

alter table tracking_events add constraint tracking_event_auto_flag_ch check ( automatic_flag in ('Y','N'));

COMMENT ON TABLE TRACKING_EVENTS IS 'This table contains a list of bag tracking events';

COMMENT ON COLUMN TRACKING_EVENTS.AGENT_CODE IS  'Agent code';
COMMENT ON COLUMN TRACKING_EVENTS.AUTOMATIC_FLAG IS  'Indicates automatic event';
COMMENT ON COLUMN TRACKING_EVENTS.DESCRIPTION IS  'Event description';
COMMENT ON COLUMN TRACKING_EVENTS.EVENT_NO IS  'Event number';
COMMENT ON COLUMN TRACKING_EVENTS.GROUP_NAME IS  'Group name';
COMMENT ON COLUMN TRACKING_EVENTS.LINK_EVENT IS  'Number of the link event';
COMMENT ON COLUMN TRACKING_EVENTS.LOCATION IS  'Location code';
COMMENT ON COLUMN TRACKING_EVENTS.MANDATORY_FLAG IS  'Indicates mandatory event';
COMMENT ON COLUMN TRACKING_EVENTS.APPN_ROW_ID IS 'Unique sequence number for this row';
COMMENT ON COLUMN TRACKING_EVENTS.ROW_CREATE_TIME IS 'The time the row was created';
COMMENT ON COLUMN TRACKING_EVENTS.ROW_DATE_TIME IS 'The time the row was last modified';
COMMENT ON COLUMN TRACKING_EVENTS.CUSER IS 'The user who created the row';
COMMENT ON COLUMN TRACKING_EVENTS.MUSER IS 'The user who last modified the row';
COMMENT ON COLUMN TRACKING_EVENTS.MTERM IS 'The terminal from which the last modifcation to this row was made';
COMMENT ON COLUMN TRACKING_EVENTS.SYSTEM_ID IS 'The system identifier';
COMMENT ON COLUMN TRACKING_EVENTS.SOURCE IS 'The process that last amended this row ';
COMMENT ON COLUMN TRACKING_EVENTS.TO_BE_ARCHIVED IS 'Indicates that this row is to be archived or has been archived';

