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

PROMPT Creating table PAX_MATCH_ALGORITHMS

CREATE TABLE pax_match_algorithms (
   algorithm_name                VARCHAR2(30) NOT NULL,
   sequence_no                   NUMBER(10)   NOT NULL,
   rule_id                       NUMBER(10)   NOT NULL,
   next_rule_linked              CHAR(1)      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_algorithms add ( constraint pax_match_algorithms_pk primary key (appn_row_id) using index tablespace &1._indexes);

ALTER TABLE pax_match_algorithms ADD ( CONSTRAINT pax_match_algorithms_uk1 unique (algorithm_name,sequence_no) USING INDEX TABLESPACE &1._indexes);

ALTER TABLE pax_match_algorithms ADD (   CONSTRAINT pax_match_algorithms_fk_rules FOREIGN KEY ( rule_id ) REFERENCES pax_match_rules(rule_id));

ALTER TABLE pax_match_algorithms ADD (   CONSTRAINT pax_match_algorithms_linked_ch CHECK ( next_rule_linked IN ('Y','N') ));

CREATE INDEX pax_match_algorithms_sk1 ON pax_match_algorithms(rule_id) TABLESPACE &1._indexes;

COMMENT ON TABLE PAX_MATCH_ALGORITHMS IS 'This table contains the algorithms for matching passenger names, as used in incoming BMM processing and inbound flight processing';

COMMENT ON COLUMN PAX_MATCH_ALGORITHMS.ALGORITHM_NAME IS  'Name of the algorithm';
COMMENT ON COLUMN PAX_MATCH_ALGORITHMS.NEXT_RULE_LINKED IS  'the next linked rule for this algorithm';
COMMENT ON COLUMN PAX_MATCH_ALGORITHMS.RULE_ID IS  'Rule identifier';
COMMENT ON COLUMN PAX_MATCH_ALGORITHMS.SEQUENCE_NO IS  'Sequence number';
COMMENT ON COLUMN PAX_MATCH_ALGORITHMS.APPN_ROW_ID IS 'Unique sequence number for this row';
COMMENT ON COLUMN PAX_MATCH_ALGORITHMS.ROW_CREATE_TIME IS 'The time the row was created';
COMMENT ON COLUMN PAX_MATCH_ALGORITHMS.ROW_DATE_TIME IS 'The time the row was last modified';
COMMENT ON COLUMN PAX_MATCH_ALGORITHMS.CUSER IS 'The user who created the row';
COMMENT ON COLUMN PAX_MATCH_ALGORITHMS.MUSER IS 'The user who last modified the row';
COMMENT ON COLUMN PAX_MATCH_ALGORITHMS.MTERM IS 'The terminal from which the last modifcation to this row was made';
COMMENT ON COLUMN PAX_MATCH_ALGORITHMS.SYSTEM_ID IS 'The system identifier';
COMMENT ON COLUMN PAX_MATCH_ALGORITHMS.SOURCE IS 'The process that last amended this row ';
COMMENT ON COLUMN PAX_MATCH_ALGORITHMS.TO_BE_ARCHIVED IS 'Indicates that this row is to be archived or has been archived';

