/*****************************************************************************
*
* Filename         - $Workfile:   load_attempt.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 table and associated items
*
* Language         - Oracle SQL*Plus script
*
* Classification   - Commercial In Confidence
*
*          (c) Ultra Electronics Limited, 1997
*
*****************************************************************************/


PROMPT Creating table LOAD_ATTEMPT

create table load_attempt (
   load_id                       number(10),
   user_id                       number(10),
   load_time                     date,
   bag_tag                       char(10),
   flight_id                     number(10),
   location_code                 char(6),
   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 load_attempt add ( constraint load_attempt_pk primary key (appn_row_id) using index tablespace &1._indexes);

alter table load_attempt add constraint user_id_fk foreign key (user_id) references tagtrak_users(user_id);

alter table load_attempt add constraint loc_code_fk foreign key (location_code) references location(location_code);

CREATE INDEX load_attempt_sk1 ON load_attempt(location_code) TABLESPACE &1._indexes;

CREATE INDEX load_attempt_sk2 ON load_attempt(user_id) TABLESPACE &1._indexes;

COMMENT ON TABLE LOAD_ATTEMPT IS 'This table contains details of attempts to load bags';

COMMENT ON COLUMN LOAD_ATTEMPT.BAG_TAG IS  'Ten digit bag tag number';
COMMENT ON COLUMN LOAD_ATTEMPT.FLIGHT_ID IS  'Flight identifier';
COMMENT ON COLUMN LOAD_ATTEMPT.LOAD_ID IS  'Unique identifier';
COMMENT ON COLUMN LOAD_ATTEMPT.LOAD_TIME IS  'Time bag load was attempted';
COMMENT ON COLUMN LOAD_ATTEMPT.LOCATION_CODE IS  'Location code';
COMMENT ON COLUMN LOAD_ATTEMPT.USER_ID IS  'User identifier';
COMMENT ON COLUMN LOAD_ATTEMPT.APPN_ROW_ID IS 'Unique sequence number for this row';
COMMENT ON COLUMN LOAD_ATTEMPT.ROW_CREATE_TIME IS 'The time the row was created';
COMMENT ON COLUMN LOAD_ATTEMPT.ROW_DATE_TIME IS 'The time the row was last modified';
COMMENT ON COLUMN LOAD_ATTEMPT.CUSER IS 'The user who created the row';
COMMENT ON COLUMN LOAD_ATTEMPT.MUSER IS 'The user who last modified the row';
COMMENT ON COLUMN LOAD_ATTEMPT.MTERM IS 'The terminal from which the last modifcation to this row was made';
COMMENT ON COLUMN LOAD_ATTEMPT.SYSTEM_ID IS 'The system identifier';
COMMENT ON COLUMN LOAD_ATTEMPT.SOURCE IS 'The process that last amended this row ';
COMMENT ON COLUMN LOAD_ATTEMPT.TO_BE_ARCHIVED IS 'Indicates that this row is to be archived or has been archived';
