/*****************************************************************************
*
* Filename         - $Workfile:   uld_dests.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: uld_dests table and associated items
*
* Language         - Oracle SQL*Plus script
*
* Classification   - Commercial In Confidence
*
*          (c) Ultra Electronics Limited, 1997
*
*****************************************************************************/
/****************************************************************************
* @(#)$Workfile:   uld_dests.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/uld_dests.svl  $
 *
 *    Rev 1.4   18 Jun 2001 13:48:38   tagtrak
 * OR:
 * CR: 15428
 * REV: 1.4
 * DESC: User Group Changes 2001
 *
 *    Rev 1.2.1.2   10 Jun 1999 14:51:50   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:43:52   tagtrak
 * OR:
 * CR:
 * REV:
 * Initial Issue
 * See label for concession
 *
 *    Rev 1.1   26 Feb 1998 11:08:28   tagtrak
 * OR:
 * CR:
 * REV:
 * Initial core product version
 *
 *    Rev 1.0   22 Oct 1997 11:08:22   tagtrak
 * OR:
 * CR:
 * REV:
 * Initial check-in
*
****************************************************************************/

PROMPT Creating table ULD_DESTS

create table ULD_DESTS (
   ULD_NO                        char(10)   NOT NULL,
   FLIGHT_ID                     number(10) NOT NULL,
   ULD_DESTINATION               char(3)    NOT NULL,
   ULD_CLASS_LIST                char(10),
   ONWARD_FLIGHT_NO              VARCHAR(8),
   ONWARD_FLIGHT_DATE            VARCHAR(5),
   dest_order                    number     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 uld_dests add ( constraint uld_dests_pk primary key (appn_row_id) using index tablespace &1._indexes);

alter table uld_dests add constraint uld_dests_uk1 unique (uld_no,flight_id,uld_destination,uld_class_list,onward_flight_no,onward_flight_date) using index tablespace &1._indexes;

alter table uld_dests add ( constraint uld_dests_fk_ulds foreign key (uld_no, flight_id) references ulds (uld_no, flight_id) on delete cascade);

ALTER TABLE uld_dests ADD (CONSTRAINT uld_dests_uk2 UNIQUE (uld_no,flight_id, dest_order));

ALTER TABLE uld_dests ADD (CONSTRAINT uld_dests_ck1 CHECK (dest_order > 0));

create index ULD_DESTS_SK2 on ULD_DESTS(ULD_DESTINATION) tablespace &1._indexes;

create index ULD_DESTS_SK3 on ULD_DESTS(ULD_NO) tablespace &1._indexes;

create index ULD_DESTS_SK4 on ULD_DESTS(FLIGHT_ID) tablespace &1._indexes;

create index uld_flight_ind2 on uld_dests(uld_no,flight_id)tablespace &1._indexes;

COMMENT ON TABLE ULD_DESTS IS 'This table contains ULD destinations';

COMMENT ON COLUMN ULD_DESTS.FLIGHT_ID IS  'Flight identifier';
COMMENT ON COLUMN ULD_DESTS.ONWARD_FLIGHT_DATE IS  'Onward flight date';
COMMENT ON COLUMN ULD_DESTS.ONWARD_FLIGHT_NO IS  'Onward flight number';
COMMENT ON COLUMN ULD_DESTS.ULD_CLASS_LIST IS  'ULD class list';
COMMENT ON COLUMN ULD_DESTS.ULD_DESTINATION IS  'ULD destination';
COMMENT ON COLUMN ULD_DESTS.ULD_NO IS  'ULD number';
COMMENT ON COLUMN ULD_DESTS.DEST_ORDER IS 'Destination sequence number for the ULD';
COMMENT ON COLUMN ULD_DESTS.APPN_ROW_ID IS 'Unique sequence number for this row';
COMMENT ON COLUMN ULD_DESTS.ROW_CREATE_TIME IS 'The time the row was created';
COMMENT ON COLUMN ULD_DESTS.ROW_DATE_TIME IS 'The time the row was last modified';
COMMENT ON COLUMN ULD_DESTS.CUSER IS 'The user who created the row';
COMMENT ON COLUMN ULD_DESTS.MUSER IS 'The user who last modified the row';
COMMENT ON COLUMN ULD_DESTS.MTERM IS 'The terminal from which the last modifcation to this row was made';
COMMENT ON COLUMN ULD_DESTS.SYSTEM_ID IS 'The system identifier';
COMMENT ON COLUMN ULD_DESTS.SOURCE IS 'The process that last amended this row ';
COMMENT ON COLUMN ULD_DESTS.TO_BE_ARCHIVED IS 'Indicates that this row is to be archived or has been archived';
