/*****************************************************************************
*
* Filename         - $Workfile:   pax_match_rules.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: pax_match_rules table and associated items
*
* Language         - Oracle SQL*Plus script
*
* Classification   - Commercial In Confidence
*
*          (c) Ultra Electronics Limited, 2006
*
*****************************************************************************/

PROMPT Creating table PAX_MATCH_RULES

CREATE TABLE pax_match_rules (
   rule_id                       NUMBER(10)   NOT NULL,
   table_name                    VARCHAR2(30) NOT NULL,
   column_name                   VARCHAR2(30) NOT NULL,
   test_if                       VARCHAR2(6),
   fatal                         CHAR(1),
   limit                         CHAR(1),
   lower_limit                   VARCHAR2(100),
   upper_limit                   VARCHAR2(100),
   operator                      CHAR(1),
   return_on_positive            NUMBER(10)  NOT NULL,
   return_on_negative            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 pax_match_rules add ( constraint pax_match_rules_pk primary key (appn_row_id) using index tablespace &1._indexes);

ALTER TABLE pax_match_rules ADD ( CONSTRAINT pax_match_rules_uk1 unique (rule_id) USING INDEX TABLESPACE &1._indexes);

ALTER TABLE pax_match_rules ADD (   CONSTRAINT pax_match_rules_test_if_ch CHECK ( test_if IN ('EITHER','BOTH','ANY') ));

ALTER TABLE pax_match_rules ADD (   CONSTRAINT pax_match_rules_fatal_ch CHECK ( fatal IN ('Y','N') ));

ALTER TABLE pax_match_rules ADD (   CONSTRAINT pax_match_rules_limit_ch CHECK ( limit IN ('Y','N') ));

ALTER TABLE pax_match_rules ADD (   CONSTRAINT pax_match_rules_operator_ch CHECK ( operator IN ('E','I','C','B','O','S') ));

COMMENT ON TABLE PAX_MATCH_RULES IS 'This table contains passenger matching rules, as used in incoming BMM processing and inbound flight processing';

COMMENT ON COLUMN PAX_MATCH_RULES.COLUMN_NAME IS  'Column name to match on';
COMMENT ON COLUMN PAX_MATCH_RULES.FATAL IS  'Fatal indicator';
COMMENT ON COLUMN PAX_MATCH_RULES.LIMIT IS  'Limit indicator';
COMMENT ON COLUMN PAX_MATCH_RULES.LOWER_LIMIT IS  'Lower limit';
COMMENT ON COLUMN PAX_MATCH_RULES.OPERATOR IS  'Operator';
COMMENT ON COLUMN PAX_MATCH_RULES.RETURN_ON_NEGATIVE IS  'Return on negative';
COMMENT ON COLUMN PAX_MATCH_RULES.RETURN_ON_POSITIVE IS  'Return on positive';
COMMENT ON COLUMN PAX_MATCH_RULES.RULE_ID IS  'Rule identifier';
COMMENT ON COLUMN PAX_MATCH_RULES.TABLE_NAME IS  'Table name';
COMMENT ON COLUMN PAX_MATCH_RULES.TEST_IF IS  'One of EITHER NOT NULL, BOTH NOT NULL, ANY NULL';
COMMENT ON COLUMN PAX_MATCH_RULES.UPPER_LIMIT IS  'Upper limit';
COMMENT ON COLUMN PAX_MATCH_RULES.APPN_ROW_ID IS 'Unique sequence number for this row';
COMMENT ON COLUMN PAX_MATCH_RULES.ROW_CREATE_TIME IS 'The time the row was created';
COMMENT ON COLUMN PAX_MATCH_RULES.ROW_DATE_TIME IS 'The time the row was last modified';
COMMENT ON COLUMN PAX_MATCH_RULES.CUSER IS 'The user who created the row';
COMMENT ON COLUMN PAX_MATCH_RULES.MUSER IS 'The user who last modified the row';
COMMENT ON COLUMN PAX_MATCH_RULES.MTERM IS 'The terminal from which the last modifcation to this row was made';
COMMENT ON COLUMN PAX_MATCH_RULES.SYSTEM_ID IS 'The system identifier';
COMMENT ON COLUMN PAX_MATCH_RULES.SOURCE IS 'The process that last amended this row ';
COMMENT ON COLUMN PAX_MATCH_RULES.TO_BE_ARCHIVED IS 'Indicates that this row is to be archived or has been archived';
