/*****************************************************************************
*
* Filename         - $Workfile:   flight_access.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         - Table definition for flight_access table
*
* Language         - Oracle SQL*Plus script
*
* Classification   - Commercial In Confidence
*
*          (c) Ultra Electronics Limited, 1997
*
*****************************************************************************/
/****************************************************************************
* @(#)$Workfile:   flight_access.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/flight_access.svl  $
* 
*    Rev 1.2   06 Jun 2000 09:53:16   tagtrak
*  
* 
*    Rev 1.1.1.2   10 Jun 1999 14:51:46   tagtrak
* OR:
* CR: 14043
* REV:
* Changed Archive and Backup so that the database
* can be accessed during the eraseLive function.
* 
* Neil Bishop.
* 
*    Rev 1.1   02 Apr 1998 19:42:58   tagtrak
* OR:
* CR:
* REV:
* Initial Issue
* See label for concession
* 
*    Rev 1.0   26 Feb 1998 11:15:32   tagtrak
* OR:
* CR:
* REV:
* Initial core product version
*
****************************************************************************/

PROMPT Creating table FLIGHT_ACCESS
 
create table flight_access (
   flight_id                     number(10)   not null,
   flight_priv_id                number(10),
   agent_code                    char(5)      not null,
   last_user                     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 flight_access add ( constraint flight_access_pk primary key (appn_row_id) using index tablespace &1._indexes);

alter table flight_access add ( constraint flight_access_fk_flight foreign key (flight_id) references flight (flight_id) on delete cascade);

alter table flight_access add ( constraint flt_access_fk_flt_priv foreign key (flight_priv_id) references flight_privileges (id) on delete cascade);

alter table flight_access add ( constraint flight_access_fk_agents foreign key (agent_code) references agents (agent_code));

create index flight_access_sk1 on flight_access(flight_id) tablespace &1._indexes;

create index flight_access_sk2 on flight_access(agent_code) tablespace &1._indexes;

create index flight_access_sk3 on flight_access(flight_priv_id) tablespace &1._indexes;

COMMENT ON TABLE FLIGHT_ACCESS IS 'This table contains information on which users have access to which flights in the system';

COMMENT ON COLUMN FLIGHT_ACCESS.AGENT_CODE IS  'Agent code';
COMMENT ON COLUMN FLIGHT_ACCESS.FLIGHT_ID IS  'Flight identifier';
COMMENT ON COLUMN FLIGHT_ACCESS.FLIGHT_PRIV_ID IS  'Flight privilege identifier';
COMMENT ON COLUMN FLIGHT_ACCESS.LAST_USER IS  'User identifier of the last user to update this row.';
COMMENT ON COLUMN FLIGHT_ACCESS.APPN_ROW_ID IS 'Unique sequence number for this row';
COMMENT ON COLUMN FLIGHT_ACCESS.ROW_CREATE_TIME IS 'The time the row was created';
COMMENT ON COLUMN FLIGHT_ACCESS.ROW_DATE_TIME IS 'The time the row was last modified';
COMMENT ON COLUMN FLIGHT_ACCESS.CUSER IS 'The user who created the row';
COMMENT ON COLUMN FLIGHT_ACCESS.MUSER IS 'The user who last modified the row';
COMMENT ON COLUMN FLIGHT_ACCESS.MTERM IS 'The terminal from which the last modifcation to this row was made';
COMMENT ON COLUMN FLIGHT_ACCESS.SYSTEM_ID IS 'The system identifier';
COMMENT ON COLUMN FLIGHT_ACCESS.SOURCE IS 'The process that last amended this row ';
COMMENT ON COLUMN FLIGHT_ACCESS.TO_BE_ARCHIVED IS 'Indicates that this row is to be archived or has been archived';
