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

PROMPT Creating table MAIL_INDIV

create table MAIL_INDIV (
   INDIV_MSG_ID                  number(10) NOT NULL,
   MSG_ADDRESS                   char(30) NOT NULL,
   MSG_TYPE                      char(6) NOT NULL,
   MSG_TEXT                      varchar2(100) NOT NULL,
   MSG_TIME                      date NOT NULL,
   ADDRESSEE_COUNT               number(6) NOT NULL,
   ADDRESS_STAMP                 char(4),
   SEND_STATUS                   char(1),
   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 mail_indiv add ( constraint mail_indiv_pk primary key (appn_row_id) using index tablespace &1._indexes);

alter table MAIL_INDIV add ( constraint mail_indiv_uk1 unique (INDIV_MSG_ID) using index tablespace &1._indexes);

create index MAIL_INDIV_SK1 on MAIL_INDIV(MSG_TYPE) tablespace &1._indexes;
 
create index MAIL_INDIV_SK2 on MAIL_INDIV(MSG_ADDRESS) tablespace &1._indexes;
 
create index MAIL_INDIV_SK3 on MAIL_INDIV(MSG_TIME) tablespace &1._indexes;

COMMENT ON TABLE MAIL_INDIV IS 'This table contains messages to be sent out via the DCS Gateway interface';

COMMENT ON COLUMN MAIL_INDIV.ADDRESSEE_COUNT IS  'The number of addresses';
COMMENT ON COLUMN MAIL_INDIV.ADDRESS_STAMP IS  'Address stamp';
COMMENT ON COLUMN MAIL_INDIV.INDIV_MSG_ID IS  'Unique identifier';
COMMENT ON COLUMN MAIL_INDIV.MSG_ADDRESS IS  'Message address';
COMMENT ON COLUMN MAIL_INDIV.MSG_TEXT IS  'Message text';
COMMENT ON COLUMN MAIL_INDIV.MSG_TIME IS  'Message time';
COMMENT ON COLUMN MAIL_INDIV.MSG_TYPE IS  'Message type';
COMMENT ON COLUMN MAIL_INDIV.SEND_STATUS IS  'Send status';
COMMENT ON COLUMN MAIL_INDIV.APPN_ROW_ID IS 'Unique sequence number for this row';
COMMENT ON COLUMN MAIL_INDIV.ROW_CREATE_TIME IS 'The time the row was created';
COMMENT ON COLUMN MAIL_INDIV.ROW_DATE_TIME IS 'The time the row was last modified';
COMMENT ON COLUMN MAIL_INDIV.CUSER IS 'The user who created the row';
COMMENT ON COLUMN MAIL_INDIV.MUSER IS 'The user who last modified the row';
COMMENT ON COLUMN MAIL_INDIV.MTERM IS 'The terminal from which the last modifcation to this row was made';
COMMENT ON COLUMN MAIL_INDIV.SYSTEM_ID IS 'The system identifier';
COMMENT ON COLUMN MAIL_INDIV.SOURCE IS 'The process that last amended this row ';
COMMENT ON COLUMN MAIL_INDIV.TO_BE_ARCHIVED IS 'Indicates that this row is to be archived or has been archived';
