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

PROMPT Creating table LOCATION_GROUP

create table LOCATION_GROUP (
   SITE_ID                       number(10) NOT NULL,
   NAME                          varchar2(10) NOT NULL,
   DESCRIPTION                   varchar2(8) NOT NULL,
   LAST_USER                     number(10) NOT NULL,
   ARCHIVE_FLAG                  number(10) 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 location_group ADD ( constraint location_group_pk primary key (appn_row_id) using index tablespace &1._indexes);
ALTER TABLE location_group ADD ( constraint location_group_uk1 unique (SITE_ID, NAME) using index tablespace &1._indexes);
ALTER TABLE location_group ADD ( constraint location_group_fk1_site_info FOREIGN KEY (site_id) REFERENCES site_info (site_id));
ALTER TABLE location_group ADD ( constraint location_group_chk_description check (DESCRIPTION in ('LOCAL','TRANSFER')));

COMMENT ON TABLE LOCATION_GROUP IS 'This table contains a list of the location groups';

COMMENT ON COLUMN LOCATION_GROUP.SITE_ID IS  'The site ID the location group exists at';
COMMENT ON COLUMN LOCATION_GROUP.ARCHIVE_FLAG IS  'This field is not used';
COMMENT ON COLUMN LOCATION_GROUP.DESCRIPTION IS  'Location group description';
COMMENT ON COLUMN LOCATION_GROUP.LAST_USER IS  'User identifier of the last user to update this row';
COMMENT ON COLUMN LOCATION_GROUP.NAME IS  'Location group name';
COMMENT ON COLUMN LOCATION_GROUP.APPN_ROW_ID IS 'Unique sequence number for this row';
COMMENT ON COLUMN LOCATION_GROUP.ROW_CREATE_TIME IS 'The time the row was created';
COMMENT ON COLUMN LOCATION_GROUP.ROW_DATE_TIME IS 'The time the row was last modified';
COMMENT ON COLUMN LOCATION_GROUP.CUSER IS 'The user who created the row';
COMMENT ON COLUMN LOCATION_GROUP.MUSER IS 'The user who last modified the row';
COMMENT ON COLUMN LOCATION_GROUP.MTERM IS 'The terminal from which the last modifcation to this row was made';
COMMENT ON COLUMN LOCATION_GROUP.SYSTEM_ID IS 'The system identifier';
COMMENT ON COLUMN LOCATION_GROUP.SOURCE IS 'The process that last amended this row ';
COMMENT ON COLUMN LOCATION_GROUP.TO_BE_ARCHIVED IS 'Indicates that this row is to be archived or has been archived';

