/*****************************************************************************
*
* 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

CREATE TABLE user_role (
   user_role_id                  NUMBER,
   user_role_name                VARCHAR2(50) NOT NULL,
   agent_code                    CHAR(5),
   max_logins                    NUMBER(3),
   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 add ( constraint user_role_pk primary key (appn_row_id) using index tablespace &1._indexes);

alter table user_role add ( constraint user_role_uk1 unique (user_role_id) using index tablespace &1._indexes);

alter table user_role add ( constraint user_role_uk2 unique (user_role_name, agent_code) using index tablespace &1._indexes);

alter table user_role add constraint user_role_fk_agents foreign key (agent_code) references agents (agent_code);

COMMENT ON TABLE USER_ROLE IS 'This table contains details of the user roles in the system';

COMMENT ON COLUMN USER_ROLE.AGENT_CODE IS  'Agent code';
COMMENT ON COLUMN USER_ROLE.MAX_LOGINS IS  'Maximum number of logins for the role';
COMMENT ON COLUMN USER_ROLE.USER_ROLE_ID IS  'Role identifier';
COMMENT ON COLUMN USER_ROLE.USER_ROLE_NAME IS  'Role name';
COMMENT ON COLUMN USER_ROLE.APPN_ROW_ID IS 'Unique sequence number for this row';
COMMENT ON COLUMN USER_ROLE.ROW_CREATE_TIME IS 'The time the row was created';
COMMENT ON COLUMN USER_ROLE.ROW_DATE_TIME IS 'The time the row was last modified';
COMMENT ON COLUMN USER_ROLE.CUSER IS 'The user who created the row';
COMMENT ON COLUMN USER_ROLE.MUSER IS 'The user who last modified the row';
COMMENT ON COLUMN USER_ROLE.MTERM IS 'The terminal from which the last modifcation to this row was made';
COMMENT ON COLUMN USER_ROLE.SYSTEM_ID IS 'The system identifier';
COMMENT ON COLUMN USER_ROLE.SOURCE IS 'The process that last amended this row ';
COMMENT ON COLUMN USER_ROLE.TO_BE_ARCHIVED IS 'Indicates that this row is to be archived or has been archived';

