/*****************************************************************************
*
* Filename         - $Workfile:   app_priv.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 app_priv table
*
* Language         - Oracle SQL*Plus script
*
* Classification   - Commercial In Confidence
*
*          (c) Ultra Electronics Limited, 2001
*
*****************************************************************************/
/****************************************************************************
* @(#)$Workfile:   app_priv.sql  $  $Revision:   1.1  $
*
* 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/app_priv.svl  $
* 
*    Rev 1.1   21 Jun 2001 14:46:42   tagtrak
* OR:
* CR:
* Re-baseline version 4.0.0 to include patches.
* 
*    Rev 1.0   06 Mar 2001 17:29:00   tagtrak
* OR:
* CR:15398
* REV:
* DESC: New tables for privileges
*
*****************************************************************************/


PROMPT Creating table USER_ROLE_PRIV

CREATE TABLE user_role_priv (
   user_role_id                  NUMBER not null,
   app_priv_id                   NUMBER 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 user_role_priv add ( constraint user_role_priv_pk primary key (appn_row_id) using index tablespace &1._indexes);

alter table user_role_priv add ( constraint user_role_priv_uk1 unique (user_role_id,app_priv_id) using index tablespace &1._indexes);

alter table user_role_priv add constraint user_role_priv_fk_user_role foreign key (user_role_id) references user_role (user_role_id) on delete cascade;

alter table user_role_priv add constraint user_role_priv_fk_app_priv foreign key (app_priv_id) references app_priv (app_priv_id) on delete cascade;

COMMENT ON TABLE USER_ROLE_PRIV IS 'This table maps role privileges to application privileges';

COMMENT ON COLUMN USER_ROLE_PRIV.APP_PRIV_ID IS  'Application privilege identifier';
COMMENT ON COLUMN USER_ROLE_PRIV.USER_ROLE_ID IS  'User role identifier';
COMMENT ON COLUMN USER_ROLE_PRIV.APPN_ROW_ID IS 'Unique sequence number for this row';
COMMENT ON COLUMN USER_ROLE_PRIV.ROW_CREATE_TIME IS 'The time the row was created';
COMMENT ON COLUMN USER_ROLE_PRIV.ROW_DATE_TIME IS 'The time the row was last modified';
COMMENT ON COLUMN USER_ROLE_PRIV.CUSER IS 'The user who created the row';
COMMENT ON COLUMN USER_ROLE_PRIV.MUSER IS 'The user who last modified the row';
COMMENT ON COLUMN USER_ROLE_PRIV.MTERM IS 'The terminal from which the last modifcation to this row was made';
COMMENT ON COLUMN USER_ROLE_PRIV.SYSTEM_ID IS 'The system identifier';
COMMENT ON COLUMN USER_ROLE_PRIV.SOURCE IS 'The process that last amended this row ';
COMMENT ON COLUMN USER_ROLE_PRIV.TO_BE_ARCHIVED IS 'Indicates that this row is to be archived or has been archived';
