/*****************************************************************************
*
* Filename         - $Workfile:   lba_info.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: triggers for flight table
*
* Language         - Oracle SQL*Plus script
*
* Classification   - Commercial In Confidence
*
*          (c) Ultra Electronics Limited, 1999
*
*****************************************************************************/
/****************************************************************************
* @(#)$Workfile:   lba_info.sql  $  $Revision:   1.2  $
*
* 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/lba_info.svl  $
* 
*    Rev 1.2   21 Jun 2001 14:47:48   tagtrak
* OR:
* CR:
* Re-baseline version 4.0.0 to include patches.
* 
*    Rev 1.1   31 Jan 2000 14:39:14   tagtrak
* OR:
* CR: 14402
* REV: 
* San Francisco Core Product Merge
* Neil Hilier
* 
*    Rev 1.0   07 May 1999 14:59:00   tagtrak
* Initial revision
* 
*
****************************************************************************/


PROMPT Creating table LBA_INFO

create table lba_info (
   transaction_id                number not null,
   insert_date                   date,
   flight_no		         varchar2(8)  not null,
   std_date                      date         not null,
   transaction                   varchar2(12) not null,
   seq_no                        number(3),
   seat                          varchar2(3),
   pax_name                      varchar2(20),
   flight_id                     number(10),
   update_date                   date,
   error_id                      number(10),
   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 lba_info add ( constraint lba_info_pk primary key (appn_row_id) using index tablespace &1._indexes);

alter table lba_info add ( constraint lba_info_uk1 unique (transaction_id) using index tablespace &1._indexes);

alter table lba_info add ( constraint lba_info_fk_flight foreign key (flight_id) references flight(flight_id) on delete cascade);

create index lba_info_sk1 on lba_info (insert_date) tablespace &1._indexes;

create index lba_info_sk2 on lba_info (update_date) tablespace &1._indexes;

create index lba_info_sk4 on lba_info(flight_id) tablespace &1._indexes;

alter table lba_info add ( constraint lba_info_chk_trans check ( transaction in ( 'BOARD', 'DEBOARD', 'DEBOARD_ALL')));

alter table lba_info add ( constraint lba_info_chk_key check ( ((seq_no is not null) OR (seat is not null)) AND ((transaction = 'BOARD') OR (transaction = 'DEBOARD')) OR ((transaction != 'BOARD') AND (transaction != 'DEBOARD'))));

COMMENT ON TABLE LBA_INFO IS 'This table contains transactions received from LBA (Local Boarding Application) in SFO';

COMMENT ON COLUMN LBA_INFO.ERROR_ID IS  'Error identifier';
COMMENT ON COLUMN LBA_INFO.FLIGHT_ID IS  'Flight identifier';
COMMENT ON COLUMN LBA_INFO.FLIGHT_NO IS  'Flight number';
COMMENT ON COLUMN LBA_INFO.INSERT_DATE IS  'Time that row was inserted';
COMMENT ON COLUMN LBA_INFO.PAX_NAME IS  'Passenger name';
COMMENT ON COLUMN LBA_INFO.SEAT IS  'Seat number';
COMMENT ON COLUMN LBA_INFO.SEQ_NO IS  'Sequence number';
COMMENT ON COLUMN LBA_INFO.STD_DATE IS  'Scheduled time of departure';
COMMENT ON COLUMN LBA_INFO.TRANSACTION IS  'Transaction';
COMMENT ON COLUMN LBA_INFO.TRANSACTION_ID IS  'Transaction identifier';
COMMENT ON COLUMN LBA_INFO.UPDATE_DATE IS  'Time that row was updated';
COMMENT ON COLUMN LBA_INFO.APPN_ROW_ID IS 'Unique sequence number for this row';
COMMENT ON COLUMN LBA_INFO.ROW_CREATE_TIME IS 'The time the row was created';
COMMENT ON COLUMN LBA_INFO.ROW_DATE_TIME IS 'The time the row was last modified';
COMMENT ON COLUMN LBA_INFO.CUSER IS 'The user who created the row';
COMMENT ON COLUMN LBA_INFO.MUSER IS 'The user who last modified the row';
COMMENT ON COLUMN LBA_INFO.MTERM IS 'The terminal from which the last modifcation to this row was made';
COMMENT ON COLUMN LBA_INFO.SYSTEM_ID IS 'The system identifier';
COMMENT ON COLUMN LBA_INFO.SOURCE IS 'The process that last amended this row ';
COMMENT ON COLUMN LBA_INFO.TO_BE_ARCHIVED IS 'Indicates that this row is to be archived or has been archived';
