/*****************************************************************************
*
* Filename         - $Workfile:   pm_results.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       - 
*
* Design Spec
* Section          - 
*
* Contents         - Live Schema: PM_RESULTS table and associated items
*
* Language         - Oracle SQL*Plus script
*
* Classification   - Commercial In Confidence
*
*          (c) Ultra Electronics Limited, 2003
*
*****************************************************************************/
/****************************************************************************
* @(#)$Workfile:   $  $Revision:   $
*
* 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:   $
*
****************************************************************************/

PROMPT Creating table PM_RESULTS

create table PM_RESULTS (
   PMR_ID                        number(10) not null,
   PMR_KIT_ID                    number(10) not null,
   PMR_USER_ID                   number(10) not null,
   PMR_TIME                      number(10,3) not null,
   PMR_TIMESTAMP                 DATE 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 pm_results add ( constraint pm_results_pk primary key (appn_row_id) using index tablespace &1._indexes);

alter table PM_RESULTS add ( constraint pm_results_uk1 unique ( PMR_ID ) using index tablespace &1._indexes);

alter table PM_RESULTS add ( constraint PM_RESULTS_FK_KIT foreign key (PMR_KIT_ID) references KIT (ID) on delete cascade);

alter table PM_RESULTS add ( constraint PM_RESULTS_FK_TAGTRAK_USERS foreign key (PMR_USER_ID) references TAGTRAK_USERS (USER_ID));

CREATE INDEX pm_results_sk1 ON pm_results(pmr_kit_id) TABLESPACE &1._indexes;

CREATE INDEX pm_results_sk2 ON pm_results(pmr_user_id) TABLESPACE &1._indexes;

COMMENT ON TABLE PM_RESULTS IS 'This table contains performance monitoring results';

COMMENT ON COLUMN PM_RESULTS.PMR_ID IS  'Unique identifier';
COMMENT ON COLUMN PM_RESULTS.PMR_KIT_ID IS  'Associated Kit identifier';
COMMENT ON COLUMN PM_RESULTS.PMR_TIME IS  'The time to be stored';
COMMENT ON COLUMN PM_RESULTS.PMR_TIMESTAMP IS  'Date and time of the last insert or update';
COMMENT ON COLUMN PM_RESULTS.PMR_USER_ID IS  'Associated user identifier';
COMMENT ON COLUMN PM_RESULTS.APPN_ROW_ID IS 'Unique sequence number for this row';
COMMENT ON COLUMN PM_RESULTS.ROW_CREATE_TIME IS 'The time the row was created';
COMMENT ON COLUMN PM_RESULTS.ROW_DATE_TIME IS 'The time the row was last modified';
COMMENT ON COLUMN PM_RESULTS.CUSER IS 'The user who created the row';
COMMENT ON COLUMN PM_RESULTS.MUSER IS 'The user who last modified the row';
COMMENT ON COLUMN PM_RESULTS.MTERM IS 'The terminal from which the last modifcation to this row was made';
COMMENT ON COLUMN PM_RESULTS.SYSTEM_ID IS 'The system identifier';
COMMENT ON COLUMN PM_RESULTS.SOURCE IS 'The process that last amended this row ';
COMMENT ON COLUMN PM_RESULTS.TO_BE_ARCHIVED IS 'Indicates that this row is to be archived or has been archived';
