/*****************************************************************************
*
* Filename              - bag_group.sql
*
* Project Name          - UltraTrak Database
*
* Source Code Identifier - UAS/URBRS/SS/10127
*
* Description           - Table creation script for BAG_GROUP. 
*                         Contains bag groups that have been registered.
*                         A bag group is a collection of bags not associated
*                         with a flight (e.g. a pile of bags on the floor).
*
* Language              - Oracle PL/SQL
*
* File History          - For the development history run the Show History report in PVCS
*
* Copyright Ultra Electronics Airport Systems, 2003
*
*****************************************************************************/

PROMPT Creating table BAG_GROUP

create table bag_group (
   group_no                      varchar2(10) not null,
   no_of_bags                    number(4) not null,
   user_id                       number(10) not null,
   site_id                       number(10) not null,
   agent_code                    char(5) not null,
   group_name                    char(15) not null,
   holding_pen                   varchar(1) default 'N' 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 bag_group add ( constraint bag_group_pk primary key (appn_row_id) using index tablespace &1._indexes);

alter table bag_group add ( constraint bag_group_uk1 unique (group_no, site_id) using index tablespace &1._indexes );

alter table bag_group add constraint ck_bag_group_holding_pen check (holding_pen in ('Y','N'));

COMMENT ON TABLE BAG_GROUP IS 'This table contains bag group details';

COMMENT ON COLUMN BAG_GROUP.AGENT_CODE IS  'The agent associated with this bag group';
COMMENT ON COLUMN BAG_GROUP.GROUP_NAME IS  'The name of the bag group';
COMMENT ON COLUMN BAG_GROUP.GROUP_NO IS  'The bag group number';
COMMENT ON COLUMN BAG_GROUP.HOLDING_PEN IS  'Flag to indicate whether this group is a holding pen';
COMMENT ON COLUMN BAG_GROUP.NO_OF_BAGS IS  'Number of bags in the bag group';
COMMENT ON COLUMN BAG_GROUP.SITE_ID IS  'The site identifier';
COMMENT ON COLUMN BAG_GROUP.USER_ID IS  'The user identifier';
COMMENT ON COLUMN BAG_GROUP.APPN_ROW_ID IS 'Unique sequence number for this row';
COMMENT ON COLUMN BAG_GROUP.ROW_CREATE_TIME IS 'The time the row was created';
COMMENT ON COLUMN BAG_GROUP.ROW_DATE_TIME IS 'The time the row was last modified';
COMMENT ON COLUMN BAG_GROUP.CUSER IS 'The user who created the row';
COMMENT ON COLUMN BAG_GROUP.MUSER IS 'The user who last modified the row';
COMMENT ON COLUMN BAG_GROUP.MTERM IS 'The terminal from which the last modifcation to this row was made';
COMMENT ON COLUMN BAG_GROUP.SYSTEM_ID IS 'The system identifier';
COMMENT ON COLUMN BAG_GROUP.SOURCE IS 'The process that last amended this row ';
COMMENT ON COLUMN BAG_GROUP.TO_BE_ARCHIVED IS 'Indicates that this row is to be archived or has been archived';
