/*****************************************************************************
*
* Filename         - $Workfile:   bag_alert.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: bag_alert table and associated items
*
* Language         - Oracle SQL*Plus script
*
* Classification   - Commercial In Confidence
*
*          (c) Ultra Electronics Limited, 1997
*
*****************************************************************************/
/****************************************************************************
* @(#)$Workfile:   bag_alert.sql  $  $Revision:   1.4  $
*
* Revision History
*
* Note that user tagtrak is many users. For these users the user
* name is entered as the last line in the change description.
*
* $Log:   /pvcsarch/db_ora/db/source/live/tables/bag_alert.svl  $
 * 
 *    Rev 1.4   21 Jun 2001 14:46:46   tagtrak
 * OR:
 * CR:
 * Re-baseline version 4.0.0 to include patches.
 * 
 *    Rev 1.3   22 Jun 1999 15:50:20   tagtrak
 * OR:
 * CR: 14043
 * REV:
 * Change to Archive and Backup so that when the eraseLive function is
 * called, it deletes the child records first, parent records last, so
 * not to take out any table locks.
 * 
 * Neil Bishop.
 * 
 *    Rev 1.3   10 Jun 1999 14:51:44   tagtrak
 * OR:
 * CR: 14043
 * REV:
 * Changed Archive and Backup so that the database
 * can be accessed during the eraseLive function.
 * 
 * Neil Bishop.
 * 
 *    Rev 1.2   02 Apr 1998 19:42:28   tagtrak
 * OR:
 * CR:
 * REV:
 * Initial Issue
 * See label for concession
 * 
 *    Rev 1.1   26 Feb 1998 11:07:24   tagtrak
 * OR:
 * CR:
 * REV:
 * Initial core product version
 * 
 *    Rev 1.0   22 Oct 1997 11:07:22   tagtrak
 * OR:
 * CR:
 * REV:
 * Initial check-in
*
****************************************************************************/

PROMPT Creating table BAG_ALERT;

create table BAG_ALERT (
   PAX_ID                        number(10) NOT NULL,
   NO_WARNINGS                   number(6) NOT NULL,
   BAG_TAG2B                     char(3) NOT NULL,
   BAG_TAG3                      number(10) NOT NULL,
   LAST_TIME_STAMP               date NOT NULL,
   ALERT_ON_ACTION               char(10) NOT NULL,
   BAG_TAG                       char(10) NOT NULL,
   BAG_TAG2A                     char(3) NULL,
   BAG_TAG1                      char(1) NULL,
   FLIGHT_ID                     number(10) NULL,
   airport_code                  char(3) not null,
   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 bag_alert add ( constraint bag_alert_pk primary key (appn_row_id) using index tablespace &1._indexes);

ALTER TABLE bag_alert ADD (CONSTRAINT bag_alert_fk1_alert_on_action FOREIGN KEY (alert_on_action) REFERENCES bag_alert_priority (alert_type));

create index BAG_ALERT_SK1 on BAG_ALERT(BAG_TAG) tablespace &1._indexes;
 
create index BAG_ALERT_SK2 on BAG_ALERT(ALERT_ON_ACTION) tablespace &1._indexes;
 
create index BAG_ALERT_SK3 on BAG_ALERT(LAST_TIME_STAMP) tablespace &1._indexes;
 
create index BAG_ALERT_SK4 on BAG_ALERT(BAG_TAG3) tablespace &1._indexes;

create index BAG_ALERT_SK5 on bag_alert(pax_id) tablespace &1._indexes;

COMMENT ON TABLE BAG_ALERT IS 'This table contains details of bag alerts in the system';

COMMENT ON COLUMN BAG_ALERT.AIRPORT_CODE IS  'The airport code associated with the bag alert';
COMMENT ON COLUMN BAG_ALERT.ALERT_ON_ACTION IS  'The action to take for the alert';
COMMENT ON COLUMN BAG_ALERT.BAG_TAG IS  'The bag tag associated with the alert';
COMMENT ON COLUMN BAG_ALERT.BAG_TAG1 IS  'The first digit of the bag tag associated with the alert';
COMMENT ON COLUMN BAG_ALERT.BAG_TAG2A IS  'The carrier of the bag associated with the alert';
COMMENT ON COLUMN BAG_ALERT.BAG_TAG2B IS  'The carrier number of the bag assoicated with the alert';
COMMENT ON COLUMN BAG_ALERT.BAG_TAG3 IS  'The last six digits of the bag tag associated with the alert';
COMMENT ON COLUMN BAG_ALERT.FLIGHT_ID IS  'The flight identifier';
COMMENT ON COLUMN BAG_ALERT.LAST_TIME_STAMP IS  'Time of the bag alert';
COMMENT ON COLUMN BAG_ALERT.NO_WARNINGS IS  'The number of warnings associated with the alert';
COMMENT ON COLUMN BAG_ALERT.PAX_ID IS  'The passenger identifier';
COMMENT ON COLUMN BAG_ALERT.APPN_ROW_ID IS 'Unique sequence number for this row';
COMMENT ON COLUMN BAG_ALERT.ROW_CREATE_TIME IS 'The time the row was created';
COMMENT ON COLUMN BAG_ALERT.ROW_DATE_TIME IS 'The time the row was last modified';
COMMENT ON COLUMN BAG_ALERT.CUSER IS 'The user who created the row';
COMMENT ON COLUMN BAG_ALERT.MUSER IS 'The user who last modified the row';
COMMENT ON COLUMN BAG_ALERT.MTERM IS 'The terminal from which the last modifcation to this row was made';
COMMENT ON COLUMN BAG_ALERT.SYSTEM_ID IS 'The system identifier';
COMMENT ON COLUMN BAG_ALERT.SOURCE IS 'The process that last amended this row ';
COMMENT ON COLUMN BAG_ALERT.TO_BE_ARCHIVED IS 'Indicates that this row is to be archived or has been archived';
