/*****************************************************************************
*
* Filename         - $Workfile:   flight_privileges.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         - Definition of flight_privileges table.
*
* Language         - Oracle SQL*Plus script
*
* Classification   - Commercial In Confidence
*
*          (c) Ultra Electronics Limited, 1997
*
*****************************************************************************/
/****************************************************************************
* @(#)$Workfile:   flight_privileges.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_privileges.svl  $
* 
*    Rev 1.2   21 Jun 2001 14:47:36   tagtrak
* OR:
* CR:
* Re-baseline version 4.0.0 to include patches.
* 
*    Rev 1.1   02 Apr 1998 19:43:02   tagtrak
* OR:
* CR:
* REV:
* Initial Issue
* See label for concession
* 
*    Rev 1.0   26 Feb 1998 11:15:38   tagtrak
* OR:
* CR:
* REV:
* Initial core product version
*
****************************************************************************/

PROMPT Creating table FLIGHT_PRIVILEGES 

create table flight_privileges (
   id                            number(10) not null,
   originating_agent             char(5) not null,
   airline_alpha_code            char(3) not null,
   agent_code                    char(5) not null,
   flight_no                     char(8),
   flight_date                   char(5),
   last_user                     number(10) 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 flight_privileges add ( constraint flight_privileges_pk primary key (appn_row_id) using index tablespace &1._indexes);

alter table flight_privileges add ( constraint flight_privileges_uk1 unique ( id ) using index tablespace &1._indexes);

alter table flight_privileges add ( constraint flight_priv_fk_carrier foreign key ( airline_alpha_code ) references carrier_lookup ( alpha_code ));

alter table flight_privileges add ( constraint flight_privileges_fk_agents foreign key ( agent_code ) references agents ( agent_code ));

alter table flight_privileges add ( constraint flight_privileges_fk_agents2 foreign key ( originating_agent ) references agents ( agent_code ));

CREATE INDEX flight_privileges_sk1 ON flight_privileges(agent_code) TABLESPACE &1._indexes;

CREATE INDEX flight_privileges_sk2 ON flight_privileges(airline_alpha_code) TABLESPACE &1._indexes;

CREATE INDEX flight_privileges_sk3 ON flight_privileges(originating_agent) TABLESPACE &1._indexes;

COMMENT ON TABLE FLIGHT_PRIVILEGES IS 'This table contains details of the flight privileges in the system';

COMMENT ON COLUMN FLIGHT_PRIVILEGES.AGENT_CODE IS  'Agent code';
COMMENT ON COLUMN FLIGHT_PRIVILEGES.AIRLINE_ALPHA_CODE IS  'Carrier Code';
COMMENT ON COLUMN FLIGHT_PRIVILEGES.FLIGHT_DATE IS  'Flight date';
COMMENT ON COLUMN FLIGHT_PRIVILEGES.FLIGHT_NO IS  'Flight number';
COMMENT ON COLUMN FLIGHT_PRIVILEGES.ID IS  'Unique identifier';
COMMENT ON COLUMN FLIGHT_PRIVILEGES.LAST_USER IS  'User identifier of the last user to update this row.';
COMMENT ON COLUMN FLIGHT_PRIVILEGES.ORIGINATING_AGENT IS  'Originating agent';
COMMENT ON COLUMN FLIGHT_PRIVILEGES.APPN_ROW_ID IS 'Unique sequence number for this row';
COMMENT ON COLUMN FLIGHT_PRIVILEGES.ROW_CREATE_TIME IS 'The time the row was created';
COMMENT ON COLUMN FLIGHT_PRIVILEGES.ROW_DATE_TIME IS 'The time the row was last modified';
COMMENT ON COLUMN FLIGHT_PRIVILEGES.CUSER IS 'The user who created the row';
COMMENT ON COLUMN FLIGHT_PRIVILEGES.MUSER IS 'The user who last modified the row';
COMMENT ON COLUMN FLIGHT_PRIVILEGES.MTERM IS 'The terminal from which the last modifcation to this row was made';
COMMENT ON COLUMN FLIGHT_PRIVILEGES.SYSTEM_ID IS 'The system identifier';
COMMENT ON COLUMN FLIGHT_PRIVILEGES.SOURCE IS 'The process that last amended this row ';
COMMENT ON COLUMN FLIGHT_PRIVILEGES.TO_BE_ARCHIVED IS 'Indicates that this row is to be archived or has been archived';
