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

PROMPT Creating table KIT

create table kit (
   id                            number(10)   not null,
   type                          varchar2(15) not null,
   serial_number                 varchar2(20) not null,
   user_id                       number(10),
   logged_in                     char(1) default 'N' not null,
   scanner_id                    char(6),
   location_code                 char(6),
   airport_code                  char(3)  not null,
   kit_kis_id                    number(10) not null,
   current_logins                number(3) default 0 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 kit add ( constraint kit_pk primary key (appn_row_id) using index tablespace &1._indexes);

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

alter table kit add ( constraint kit_uk2 unique (type,serial_number) using index tablespace &1._indexes);

alter table kit add ( constraint kit_uk3 unique (scanner_id) using index tablespace &1._indexes);

alter table kit add ( constraint kit_uk4 unique (user_id,serial_number) using index tablespace &1._indexes);

alter table kit add ( constraint kit_fk_tagtrak_users foreign key (user_id) references tagtrak_users( user_id ));

alter table kit add ( constraint kit_fk_kit_type foreign key (type) references kit_type( type ));

alter table kit add ( constraint kit_fk_location foreign key (location_code) references location( location_code ));

alter table kit add ( constraint kit_fk_kit_status foreign key (kit_kis_id) references kit_status (kis_id));

CREATE INDEX kit_sk1 ON kit(kit_kis_id) TABLESPACE &1._indexes;

CREATE INDEX kit_sk2 ON kit(location_code) TABLESPACE &1._indexes;

CREATE INDEX kit_sk3 ON kit(user_id) TABLESPACE &1._indexes;

COMMENT ON TABLE KIT IS 'This table contains a list of equipment used in the system';

COMMENT ON COLUMN KIT.AIRPORT_CODE IS  'Airport code';
COMMENT ON COLUMN KIT.CURRENT_LOGINS IS  'Number of current logins';
COMMENT ON COLUMN KIT.ID IS  'Unique identifier';
COMMENT ON COLUMN KIT.KIT_KIS_ID IS  'Kit status';
COMMENT ON COLUMN KIT.LOCATION_CODE IS  'Location of the kit';
COMMENT ON COLUMN KIT.LOGGED_IN IS  'Indicates whether there is a user logged in';
COMMENT ON COLUMN KIT.SCANNER_ID IS  'Scanner identifier';
COMMENT ON COLUMN KIT.SERIAL_NUMBER IS  'Serial number of the equipment';
COMMENT ON COLUMN KIT.TYPE IS  'Type of equipment';
COMMENT ON COLUMN KIT.USER_ID IS  'User identifier';
COMMENT ON COLUMN KIT.APPN_ROW_ID IS 'Unique sequence number for this row';
COMMENT ON COLUMN KIT.ROW_CREATE_TIME IS 'The time the row was created';
COMMENT ON COLUMN KIT.ROW_DATE_TIME IS 'The time the row was last modified';
COMMENT ON COLUMN KIT.CUSER IS 'The user who created the row';
COMMENT ON COLUMN KIT.MUSER IS 'The user who last modified the row';
COMMENT ON COLUMN KIT.MTERM IS 'The terminal from which the last modifcation to this row was made';
COMMENT ON COLUMN KIT.SYSTEM_ID IS 'The system identifier';
COMMENT ON COLUMN KIT.SOURCE IS 'The process that last amended this row ';
COMMENT ON COLUMN KIT.TO_BE_ARCHIVED IS 'Indicates that this row is to be archived or has been archived';
