

--
--    Licensed Materials - Property of IBM
--    
--    BI and PM: JSM
--    
--    (c) Copyright IBM Corp. 2003, 2015.
--    
--    US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
--    


-------------------------------------------------------------------------------
-- NC_CREATE_Hsql.sql         *  DO NOT EDIT  *        Data Store Version: 1032
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
--$200-- tables create begin
-------------------------------------------------------------------------------

CREATE TABLE NC_CONFIGURATION(
   PROPERTY_KEY 		 VARCHAR(255) NOT NULL,
   PROPERTY_VALUE		 VARCHAR(255)
);

CREATE TABLE NC_CTMAP(
   OBJTYPE                       SMALLINT NOT NULL,
   CLASS                         VARCHAR(200),
   TABLENAME                     VARCHAR(200) NOT NULL,
   HELPER                        VARCHAR(200),
   REMOTECLASS                   VARCHAR(200)
);

CREATE TABLE NC_DB_VERSION(
   DB_VERSION_ID                 INTEGER,
   BUILD                         VARCHAR(20)
);

CREATE TABLE NC_DELIVERYADDRESS(
   PK_DELADDRESS_ID              INTEGER NOT NULL,
   DELIVERY_ADDRESS              VARCHAR(100),
   CHANNEL_TYPE                  INTEGER,
   IS_DEFAULT                    INTEGER NOT NULL,
   FK_RECIPIENT_ID               INTEGER,
   ADDRESS_TYPE                  INTEGER
);

CREATE TABLE NC_EVENTSTATUS(
   PK_EVENT_ID                   CHAR(45) NOT NULL,
   EVENT_STATUS                  INTEGER NOT NULL,
   CONVERSATION                  INTEGER,
   SDS_INSTANCE_ID 		 CHAR (32) 
);

CREATE TABLE NC_JMSQUEUE(
   QUEUE_ENTRY_ID                INTEGER NOT NULL, 
   QUEUE_NAME                    VARCHAR (440), 
   QUEUE_ENTRY                   LONGVARBINARY,
   SDS_INSTANCE_ID 		 CHAR (32),
   DATE_ENTERED 		 NUMERIC(14) NOT NULL,
   REDELIVER_DATE 		 NUMERIC(19),
   REDELIVER_COUNT 		 INTEGER DEFAULT 0 NOT NULL
);

CREATE TABLE NC_JOBQUEUE (
   	PK_RUN_ID 		CHAR (45) NOT NULL,
	SERVICE_NAME 	CHAR (40),
	SERVER_GROUP 	CHAR (40),
   	DATE_ENTERED 	NUMERIC(14) NOT NULL,
   	JOB 			LONGVARBINARY 	NOT NULL 
);

CREATE TABLE NC_MESSAGELINE(
   FK_MESSAGESTRUCT_ID           INTEGER NOT NULL,
   LINE_NO                       INTEGER NOT NULL,
   LINE_TYPE                     INTEGER
);

CREATE TABLE NC_MESSAGELINE_ELEMENT(
   FK_MESSAGESTRUCT_ID           INTEGER NOT NULL,
   ELEMENT_NUMBER                INTEGER NOT NULL,
   LINE_NO                       INTEGER NOT NULL,
   TEXT                          VARCHAR(3000),
   FK_BIE_TOPIC_ID               INTEGER
);

CREATE TABLE NC_MESSAGESTRUCT(
   PK_MS_ID                      INTEGER NOT NULL,
   FK_DYNREC_ID                  INTEGER,
   NAME                          VARCHAR(255),
   DESCRIPTION                   VARCHAR(1000),
   SOURCE                        VARCHAR(100),
   SUBJECT                       VARCHAR(210),
   MODCOUNT                      INTEGER DEFAULT -1,
   LASTMOD_BY                    VARCHAR(50),
   CHANNEL_TYPE                  INTEGER,
   CONTACT                       VARCHAR(50),
   CREDENTIAL			   VARCHAR(1024),
   AVOID_DUPLICATION             INTEGER DEFAULT 0 NOT NULL
);

CREATE TABLE NC_METRICS(
   NAME 			VARCHAR(255) 	NOT NULL,
   LASTMOD_TIME 		NUMERIC(19) 	DEFAULT 0 NOT NULL ,
   VALUE 			NUMERIC(19) 	DEFAULT 0 NOT NULL,
   ACTIVE 			INTEGER 	DEFAULT 0 NOT NULL
);

CREATE TABLE NC_OBJECTCATALOGUE(
   PK_OID                        INTEGER NOT NULL,
   NAME                          VARCHAR(255),
   DESCRIPTION                   VARCHAR(1000),
   SUBTYPE                       INTEGER,
   TYPE                          INTEGER NOT NULL,
   MODCOUNT                      INTEGER DEFAULT -1,
   CM_VERSION                    INTEGER DEFAULT -1 
);

CREATE TABLE NC_OBJECTID(
   OBJECTID                      INTEGER NOT NULL
);

CREATE TABLE NC_PERMISSION(
   PK_PERMISSION_ID              INTEGER NOT NULL,
   DESCRIPTION                   VARCHAR(30) NOT NULL
);

CREATE TABLE NC_RECIPIENT(
   PK_RECIPIENT_ID               INTEGER NOT NULL,
   NAME                          VARCHAR(255),
   DESCRIPTION                   VARCHAR(1000),
   LASTMOD_BY                    CHAR(40),
   LASTMOD_TIME                  TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
   MODCOUNT                      INTEGER DEFAULT -1,
   TITLE                         VARCHAR(10),
   FIRSTNAME                     VARCHAR(50),
   MIDDLENAME                    VARCHAR(50),
   LASTNAME                      VARCHAR(50),
   PHONENUMBER                   VARCHAR(50),
   JOBTITLE                      VARCHAR(50),
   COMPANY                       VARCHAR(255),
   DEPARTMENT                    VARCHAR(255),
   OFFICE                        VARCHAR(255),
   COUNTRY                       VARCHAR(50),
   TIMEZONE                      VARCHAR(50),
   TO_REDIRECT                   INTEGER NOT NULL,
   FK_REDIRECT_RID               INTEGER,
   FK_REDIRECT_RGID              INTEGER,
   IS_EXTERNAL                   INTEGER,
   IS_USEDEFAULTADDRESS          INTEGER
);

CREATE TABLE NC_SCHEDULE(
   PK_SCHEDULE_ID                INTEGER NOT NULL,
   NAME                          VARCHAR(255),
   DESCRIPTION                   VARCHAR(1000),
   LASTMOD_BY                    CHAR(40),
   LASTMOD_TIME                  TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
   MODCOUNT                      INTEGER DEFAULT -1,
   SCHEDULE_TYPE                 CHAR(6),
   TIMEZONE                      VARCHAR(100),
   START_DATE                    NUMERIC(19),
   END_DATE                      NUMERIC(19),
   REPEAT_FOREVER                INTEGER,
   ACTIVE                        INTEGER,
   VALID_SCHEDULE                INTEGER,
   USE_DAY_NUMBER                INTEGER,
   DAY_OF_MONTH                  INTEGER,
   DAY_OF_WEEK                   INTEGER,
   DAY_OF_WEEK_IN_MONTH          INTEGER,
   MONTH_OF_YEAR                 INTEGER,
   REPEAT_INTERVAL               INTEGER,
   DAYS_OF_WEEK                  INTEGER,
   FIXED_INTERVAL_TYPE           INTEGER,
   FIXED_INTERVAL_IN_MILLIS      NUMERIC(19),
   TRIGGER_ID                    VARCHAR(255),
   PERIODICAL_PRODUCER_ID        CHAR(33),
   INTERDAY_RECUR_START          INTEGER,
   INTERDAY_RECUR_END            INTEGER,
   INTERDAY_RECUR_INTERVAL       INTEGER
);

CREATE TABLE NC_SCHEDULE_QUEUE(
   SCHEDULE_ID 			 INTEGER NOT NULL,
   RUN_DATE 			 NUMERIC(19)
);

CREATE TABLE NC_SDS_INSTANCE (
   PK_INSTANCE_ID 		CHAR (32) 	NOT NULL ,
   PK_INSTANCE_URL 		VARCHAR(255) 	NOT NULL ,
   LAST_UPDATE 			NUMERIC(14) 	NOT NULL ,
   CLEANUP_INSTANCE_ID 		CHAR (32)
);

CREATE TABLE NC_TASK(
   PK_TASK_ID                    INTEGER NOT NULL,
   NAME                          VARCHAR(255),
   DESCRIPTION                   VARCHAR(1000),
   FK_BIE_ID                     INTEGER,
   THRESHOLD                     INTEGER,
   WEIGHTS                       VARCHAR(200),
   TASK_TYPE                     INTEGER,
   DATEFORMAT                    CHAR(19),
   DETECTION_OPTION              INTEGER,
   LASTMOD_TIME                  TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
   MODCOUNT                      INTEGER DEFAULT -1,
   LASTMOD_BY                    CHAR(40),
   LOCATION_ROOT 		 VARCHAR(256),
   OBJECT_CLASS 		 VARCHAR(256),
   OWNED_BY 			 VARCHAR(256)
);

CREATE TABLE NC_TASKSCHEDULE(
   PK_TASKSCHEDULE_ID            INTEGER NOT NULL,
   FK_TASK_ID                    INTEGER,
   NAME                          VARCHAR(255),
   DESCRIPTION                   VARCHAR(1000),
   LASTMOD_BY                    CHAR(40),
   MODCOUNT                      INTEGER DEFAULT -1 NOT NULL,
   RUN_REQUIREMENTS              INTEGER,
   LAST_EXECUTION_AT             NUMERIC(19),
   NEXT_EXECUTION_REQUEST        NUMERIC(19),
   SCHEDULE_DELAY                NUMERIC(19),
   DELETE_AFTER_LAST_RUN         INTEGER,
   PRIORITY			 INTEGER DEFAULT 3 NOT NULL,
   SCHEDULED_BY 		 VARCHAR(256),
   TENANT_ID			 VARCHAR(255) DEFAULT ''
);

CREATE TABLE NC_SCHEDULED_EVENT_OVERRIDE (
   FK_TASKSCHEDULE_ID 	 	INTEGER NOT NULL,
   EVENT_DATE	 		NUMERIC(19) NOT NULL,
   DELAY_UNTIL	 		NUMERIC(19),
   EVENT_STATUS              	INTEGER,
   EVENT_PRIORITY               INTEGER,
   FK_SCHEDULE_ID        	INTEGER,
   CANCELLED_BY            	VARCHAR(2000)
);

CREATE TABLE NC_TASK_ANCESTOR_STOREIDS(
	TASK_ID 		CHAR(45) NOT NULL,
	ANCESTOR_STORE_ID 	VARCHAR(256) NOT NULL
);

CREATE TABLE NC_TASK_HISTORY_DETAIL(
   TASK_ID	CHAR(45) NOT NULL,
   SUB_INDEX    INTEGER NOT NULL,
   SEVERITY     INTEGER,
   CLASSTYPE    CHAR(128),
   TASK 	LONGVARBINARY,
   STATUS 		INTEGER DEFAULT 0 NOT NULL
);

CREATE TABLE NC_TASK_HISTORY_SUB_INDEX(
    TASK_ID             CHAR(45) NOT NULL,
    LAST_SUB_INDEX      INTEGER NOT NULL
);

CREATE TABLE NC_TASK_PROPERTY (
	TASK_ID 			CHAR (45) NOT NULL,
	PROP_NAME			CHAR (45) NOT NULL,
	PROP_VALUE			VARCHAR(2000)
);

CREATE TABLE NC_TASK_QUEUE (
	TASK_ID 			CHAR(45) NOT NULL,
	SERVICE_NAME 		VARCHAR(40) ,
	SERVER_GROUP 		VARCHAR(40) ,
	DATE_ENTERED 		NUMERIC(19) NOT NULL,
	TASK 				LONGVARBINARY,
	STATUS 				INTEGER NOT NULL,
	PRIORITY 			INTEGER NOT NULL,
	RESTART_ID    	    	CHAR (45),
	SDS_INSTANCE_ID 	CHAR (32) ,
	HISTORY_STORE_ID 	CHAR (34) ,
	ACTUAL_EXECUTION_TIME   NUMERIC(19),
	ACTUAL_COMPLETION_TIME  NUMERIC(19),
	DISPATCHER_ID		CHAR(45),
	SCHEDULE_TRIGGER_NAME   VARCHAR(255),
	SCHEDULE_TYPE		CHAR(15),
	ACCOUNT_PATH		VARCHAR(1024),
	STOREID 		CHAR(34),
	OBJECT_CLASS 		CHAR(64),
	OWNER_STOREID 		VARCHAR(256),
	PROCESS_ID          INTEGER,
	TARGET_DISPATCHER_ID		CHAR(45),
	TENANT_ID 			VARCHAR(255) DEFAULT ''
);

CREATE TABLE NC_TSE_STATE_MAP (
	TASK_ID 			CHAR (45) NOT NULL,
	STATUS 				INTEGER ,
	SEQ 				INTEGER ,
	STEP_COUNT 			INTEGER ,
	CUR_SEQ 			INTEGER ,
	COUNT_SEQ 			INTEGER ,
	STOP_ON_ERROR 		INTEGER ,
	RUN_VIA_MS 			INTEGER ,
	STEP_FAILED 		INTEGER ,
	SEQ_ON_END 			INTEGER ,
	WRITE_ALL_HISTORIES INTEGER ,
	FAIL_STATUS 		INTEGER ,
	PARENT_ID 			CHAR(45),
	EXECUTING       	INTEGER DEFAULT 0 NOT NULL,
	MODCOUNT                INTEGER DEFAULT -1 NOT NULL
);

CREATE TABLE NC_RESOURCE_LOCK (
	LOCK_RESOURCE varchar(50) NOT NULL,
	OWNER varchar (50) NOT NULL,
	TIMESTAMP numeric (18, 0) NOT NULL
);

CREATE TABLE R_MESSAGESTRUCT_TASK(
   FK_MESSAGESTRUCT_ID           INTEGER NOT NULL,
   FK_TASK_ID                    INTEGER NOT NULL
);

CREATE TABLE R_MSGSTRUCT_RECIPIENT_DELIVINF(
   FK_MESSAGESTRUCT_ID           INTEGER NOT NULL,
   FK_DELIVERY_INFO_ID           INTEGER,
   FK_RECIPIENT_ID               INTEGER NOT NULL,
   ADDED_BY_RECIP_ID             INTEGER,
   DATE_ADDED                    NUMERIC(18)
);

CREATE TABLE R_NEWSITEMS_NCOBJECTS(
   NID                           CHAR(32) NOT NULL,
   FK_NCID                       INTEGER NOT NULL,
   TYPE                          SMALLINT
);

CREATE TABLE R_TASKSCHEDULE_SCHEDULE(
   FK_TASKSCHEDULE_ID            INTEGER NOT NULL,
   FK_SCHEDULE_ID                INTEGER NOT NULL,
   IS_ACTIVE                     INTEGER,
   IS_ESCALATION                 INTEGER
);


-------------------------------------------------------------------------------
--$201-- indices create begin
-------------------------------------------------------------------------------

CREATE INDEX I1N_DELIV_ADR ON NC_DELIVERYADDRESS (FK_RECIPIENT_ID);
   
CREATE INDEX IN_JOBQ_SELECTOR ON NC_JOBQUEUE (SERVICE_NAME, SERVER_GROUP, DATE_ENTERED);

CREATE INDEX IX_NC_JMSQUEUE ON NC_JMSQUEUE(QUEUE_NAME, DATE_ENTERED, SDS_INSTANCE_ID);

CREATE INDEX IX_NC_JMSQUEUE1 ON NC_JMSQUEUE(QUEUE_NAME, SDS_INSTANCE_ID);

CREATE INDEX I1N_MESSAGELINE ON NC_MESSAGELINE (FK_MESSAGESTRUCT_ID);

CREATE INDEX I1N_MESSAGELINE_EL ON NC_MESSAGELINE_ELEMENT (FK_MESSAGESTRUCT_ID);

CREATE INDEX I2N_MESSAGELINE_EL ON NC_MESSAGELINE_ELEMENT (LINE_NO,FK_MESSAGESTRUCT_ID);

CREATE INDEX I1N_MESSAGESTRUCT ON NC_MESSAGESTRUCT (FK_DYNREC_ID);

CREATE INDEX I1N_TASKHISTORYSUBINDEX ON NC_TASK_HISTORY_SUB_INDEX (TASK_ID);

CREATE INDEX I1N_TASKSCHEDULE ON NC_TASKSCHEDULE (FK_TASK_ID);

CREATE INDEX I1N_EVENT_DATE ON NC_SCHEDULED_EVENT_OVERRIDE (FK_TASKSCHEDULE_ID);

CREATE INDEX IX_NC_TSE_STE_MAP ON NC_TSE_STATE_MAP (PARENT_ID, SEQ);

CREATE INDEX IX_NC_TSK_Q_SLTR ON NC_TASK_QUEUE (STATUS, SERVICE_NAME, SERVER_GROUP, DATE_ENTERED);

CREATE INDEX I1N_TASKQUEUERESTARTID ON NC_TASK_QUEUE (RESTART_ID);

CREATE INDEX I1R_MESSAGESTRUCT_ ON R_MESSAGESTRUCT_TASK (FK_MESSAGESTRUCT_ID);

CREATE INDEX I1R_MSGSTRUCT_RECI ON R_MSGSTRUCT_RECIPIENT_DELIVINF (FK_MESSAGESTRUCT_ID);

CREATE INDEX I1R_NEWSITEMS_NCOB ON R_NEWSITEMS_NCOBJECTS (TYPE);

CREATE INDEX I2R_NEWSITEMS_NCOB ON R_NEWSITEMS_NCOBJECTS (FK_NCID);

CREATE INDEX I3R_NEWSITEMS_NCOB ON R_NEWSITEMS_NCOBJECTS (FK_NCID, NID);

CREATE INDEX I1R_TASKSCHEDULE_S ON R_TASKSCHEDULE_SCHEDULE (FK_TASKSCHEDULE_ID);

-------------------------------------------------------------------------------
--$202-- primary keys add begin
-------------------------------------------------------------------------------
 
ALTER TABLE NC_CONFIGURATION
   ADD CONSTRAINT PN_CONFIGURATION PRIMARY KEY (PROPERTY_KEY);

ALTER TABLE NC_CTMAP
   ADD CONSTRAINT PN_CTMAP PRIMARY KEY (OBJTYPE);

ALTER TABLE NC_DELIVERYADDRESS
   ADD CONSTRAINT PN_DELIVERYADDRESS PRIMARY KEY (PK_DELADDRESS_ID);

ALTER TABLE NC_EVENTSTATUS
   ADD CONSTRAINT PN_NC_EVENTSTATUS PRIMARY KEY (PK_EVENT_ID);
   
ALTER TABLE NC_JMSQUEUE
   ADD CONSTRAINT PN_NC_JMSQUEUE PRIMARY KEY (QUEUE_ENTRY_ID);
   
ALTER TABLE NC_JOBQUEUE
   ADD CONSTRAINT PN_JOBQUEUE PRIMARY KEY (PK_RUN_ID);

ALTER TABLE NC_MESSAGELINE
   ADD CONSTRAINT PN_MESSAGELINE PRIMARY KEY (LINE_NO,FK_MESSAGESTRUCT_ID);

ALTER TABLE NC_MESSAGELINE_ELEMENT
   ADD CONSTRAINT PN_MESSAGELINE_ELE PRIMARY KEY (LINE_NO,ELEMENT_NUMBER,FK_MESSAGESTRUCT_ID);

ALTER TABLE NC_MESSAGESTRUCT
   ADD CONSTRAINT PN_MESSAGESTRUCT PRIMARY KEY (PK_MS_ID);

ALTER TABLE NC_METRICS
   ADD CONSTRAINT PN_METRICS PRIMARY KEY (NAME);

ALTER TABLE NC_OBJECTCATALOGUE
   ADD CONSTRAINT PN_OBJECTCATALOGUE PRIMARY KEY (PK_OID);

ALTER TABLE NC_OBJECTID
   ADD CONSTRAINT PN_NC_OBJECTID PRIMARY KEY (OBJECTID);

ALTER TABLE NC_PERMISSION
   ADD CONSTRAINT PN_PERMISSION PRIMARY KEY (PK_PERMISSION_ID);

ALTER TABLE NC_RECIPIENT
   ADD CONSTRAINT PN_RECIPIENT PRIMARY KEY (PK_RECIPIENT_ID);

ALTER TABLE NC_SCHEDULE
   ADD CONSTRAINT PN_SCHEDULE PRIMARY KEY (PK_SCHEDULE_ID);
   
ALTER TABLE NC_SCHEDULE_QUEUE
   ADD CONSTRAINT PN_SCHEDULE_QUEUEI PRIMARY KEY (SCHEDULE_ID);
   
ALTER TABLE NC_SDS_INSTANCE
   ADD CONSTRAINT PN_SDS_INSTANCE PRIMARY KEY (PK_INSTANCE_ID);

ALTER TABLE NC_TASK
   ADD CONSTRAINT PN_TASK PRIMARY KEY (PK_TASK_ID);
   
ALTER TABLE NC_TASK_ANCESTOR_STOREIDS
   ADD CONSTRAINT PK_ANCESTOR_IDS PRIMARY KEY (TASK_ID, ANCESTOR_STORE_ID);

ALTER TABLE NC_TASKSCHEDULE
   ADD CONSTRAINT PN_TASKSCHEDULE PRIMARY KEY (PK_TASKSCHEDULE_ID);

ALTER TABLE NC_SCHEDULED_EVENT_OVERRIDE
   ADD CONSTRAINT PN_EVENT_DATES PRIMARY KEY (FK_TASKSCHEDULE_ID, EVENT_DATE);

ALTER TABLE NC_TASK_HISTORY_DETAIL ADD CONSTRAINT PN_TASK_HD PRIMARY KEY (TASK_ID,SUB_INDEX);

ALTER TABLE NC_TASK_HISTORY_SUB_INDEX ADD CONSTRAINT PN_TASK_HS PRIMARY KEY (TASK_ID);

ALTER TABLE NC_TASK_PROPERTY ADD CONSTRAINT PN_TASK_PROPERTY PRIMARY KEY (TASK_ID,PROP_NAME);

ALTER TABLE NC_TASK_QUEUE ADD CONSTRAINT PN_TASK_QUEUE PRIMARY KEY (TASK_ID);

ALTER TABLE NC_TSE_STATE_MAP ADD CONSTRAINT PN_TSE_STATE_MAP PRIMARY KEY (TASK_ID);

ALTER TABLE R_MESSAGESTRUCT_TASK
   ADD CONSTRAINT PR_MESSAGESTRUCT_T PRIMARY KEY (FK_TASK_ID,FK_MESSAGESTRUCT_ID);

ALTER TABLE R_MSGSTRUCT_RECIPIENT_DELIVINF
   ADD CONSTRAINT PR_MSGSTRUCT_RECIP PRIMARY KEY (FK_RECIPIENT_ID,FK_MESSAGESTRUCT_ID);

ALTER TABLE R_NEWSITEMS_NCOBJECTS
   ADD CONSTRAINT PR_NEWSITEMS_NCOBJ PRIMARY KEY (NID);

ALTER TABLE R_TASKSCHEDULE_SCHEDULE
   ADD CONSTRAINT PR_TASKSCHEDULE_SC PRIMARY KEY (FK_SCHEDULE_ID,FK_TASKSCHEDULE_ID);

ALTER TABLE NC_RESOURCE_LOCK ADD CONSTRAINT PR_RESOURCE_LOCK PRIMARY KEY (LOCK_RESOURCE);
-------------------------------------------------------------------------------
--$240-- foreign keys add begin
-------------------------------------------------------------------------------

ALTER TABLE NC_MESSAGELINE
   ADD CONSTRAINT F1N_MESSAGELINE FOREIGN KEY (FK_MESSAGESTRUCT_ID)
      REFERENCES NC_MESSAGESTRUCT;

ALTER TABLE NC_MESSAGELINE_ELEMENT
   ADD CONSTRAINT F1N_MESSAGELINE_EL FOREIGN KEY (LINE_NO,FK_MESSAGESTRUCT_ID)
      REFERENCES NC_MESSAGELINE;

ALTER TABLE NC_TASKSCHEDULE
   ADD CONSTRAINT F1N_TASKSCHEDULE FOREIGN KEY (FK_TASK_ID)
      REFERENCES NC_TASK;

ALTER TABLE R_MESSAGESTRUCT_TASK
   ADD CONSTRAINT F2R_MESSAGESTRUCT_ FOREIGN KEY (FK_TASK_ID)
      REFERENCES NC_TASK;

ALTER TABLE R_MESSAGESTRUCT_TASK
   ADD CONSTRAINT F1R_MESSAGESTRUCT_ FOREIGN KEY (FK_MESSAGESTRUCT_ID)
      REFERENCES NC_MESSAGESTRUCT;

ALTER TABLE R_MSGSTRUCT_RECIPIENT_DELIVINF
   ADD CONSTRAINT F3R_MSGSTRUCT_RECI FOREIGN KEY (FK_RECIPIENT_ID)
      REFERENCES NC_RECIPIENT;

ALTER TABLE R_MSGSTRUCT_RECIPIENT_DELIVINF
   ADD CONSTRAINT F1R_MSGSTRUCT_RECI FOREIGN KEY (FK_MESSAGESTRUCT_ID)
      REFERENCES NC_MESSAGESTRUCT;

ALTER TABLE R_TASKSCHEDULE_SCHEDULE
   ADD CONSTRAINT F2R_TASKSCHEDULE_S FOREIGN KEY (FK_SCHEDULE_ID)
      REFERENCES NC_SCHEDULE;

ALTER TABLE R_TASKSCHEDULE_SCHEDULE
   ADD CONSTRAINT F1R_TASKSCHEDULE_S FOREIGN KEY (FK_TASKSCHEDULE_ID)
      REFERENCES NC_TASKSCHEDULE;


-------------------------------------------------------------------------------
--$210-- views create begin
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
--$220-- server data inserts begin
-------------------------------------------------------------------------------

INSERT INTO NC_CONFIGURATION(PROPERTY_KEY,PROPERTY_VALUE) 
   VALUES ('scheduler.queue.factory.class','noticecast.scheduling.core.persistqueue.PersistQueueFactory'
);

INSERT INTO NC_CONFIGURATION(PROPERTY_KEY,PROPERTY_VALUE) 
   VALUES ('scheduler.queue.loadonstart','true'
);

INSERT INTO NC_CONFIGURATION(PROPERTY_KEY,PROPERTY_VALUE) 
   VALUES ('scheduler.queue.poll.interval.seconds','30'
);

INSERT INTO NC_CONFIGURATION(PROPERTY_KEY,PROPERTY_VALUE) 
	VALUES ('job.queue.factory.class','com.cognos.js2.PersistedJobQueueFactory');

INSERT INTO NC_CONFIGURATION(PROPERTY_KEY,PROPERTY_VALUE) 
	VALUES ('job.queue.poll.interval.seconds','30');

INSERT INTO NC_CONFIGURATION(PROPERTY_KEY,PROPERTY_VALUE) 
	VALUES ('sds.instance.update.interval.seconds','30');

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   110,
   'noticecast.logictier.datasource.JDBCDataSourceImpl',
   'NC_CONFIG_DS',
   'noticecast.datatier.datasource.JDBCDhJDBCDataSourceImpl',
   'noticecast.logictier.datasource.JDBCDataSourceRImpl'
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   111,
   'noticecast.logictier.datasource.MachineImpl',
   'NC_MACHINE_CONFIG',
   'noticecast.datatier.datasource.JDBCDhMachine',
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   112,
   'noticecast.logictier.datasource.DsPool',
   'NC_DSPOOL',
   'noticecast.datatier.datasource.JDBCDhDsPool',
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   115,
   'noticecast.logictier.datasource.cognos.CognosDataSourceImpl',
   'NC_COGNOS_DS',
   'noticecast.datatier.datasource.cognos.JDBCDhCognosDataSource',
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   200,
   'noticecast.logictier.datamapping.JDBCDataMappingImpl',
   'NCDataMapping',
   'noticecast.datatier.datamapping.JDBCDhJDBCDataMapping',
   'noticecast.logictier.datamapping.JDBCDataMappingRImpl'
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   210,
   'noticecast.logictier.datamapping.JDBCDataMappingTopicImpl',
   'NC_DMTOPIC',
   'noticecast.datatier.datamapping.JDBCDhJDBCDataMappingTopic',
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   220,
   'noticecast.logictier.datamapping.powerplay.PPDataMappingImpl',
   'NC_DATAMAPPING',
   'noticecast.datatier.datamapping.powerplay.JDBCDhPPDataMapping',
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   221,
   'noticecast.logictier.datamapping.powerplay.PPCellImpl',
   'NC_DMTOPIC',
   'noticecast.datatier.datamapping.powerplay.JDBCDhPPDataMappingTopic',
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   222,
   'noticecast.logictier.datamapping.powerplay.PPCellImpl',
   'NC_DMTOPIC',
   'noticecast.datatier.datamapping.powerplay.JDBCDhPPDataMappingTopic',
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   223,
   'noticecast.logictier.datamapping.powerplay.PPTopicImpl',
   'NC_DMTOPIC',
   'noticecast.datatier.datamapping.powerplay.JDBCDhPPDataMappingTopic',
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   230,
   'noticecast.logictier.datamapping.cognosquery.CQDataMappingImpl',
   'NC_DATAMAPPING',
   'noticecast.datatier.datamapping.cognosquery.JDBCDhCQDataMapping',
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   231,
   'noticecast.logictier.datamapping.cognosquery.CQTopicImpl',
   'NC_DMTOPIC',
   'noticecast.datatier.datamapping.cognosquery.JDBCDhCQDataMappingTopic',
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   300,
   'noticecast.logictier.bie.BusinessInfoEntityImpl',
   'NC_BIE',
   'noticecast.datatier.bie.JDBCDhBusinessInfoEntityImpl',
   'noticecast.logictier.bie.BusinessInfoEntityRImpl'
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   301,
   'noticecast.logictier.bie.BusinessInfoEntityImpl',
   'NC_COGNOS_BIE',
   'noticecast.datatier.bie.JDBCDhBusinessInfoEntityImpl',
   'noticecast.logictier.bie.BusinessInfoEntityRImpl'
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   311,
   'noticecast.logictier.bie.BIETopicImpl',
   'NC_BIETopic',
   'noticecast.datatier.bie.JDBCDhBIETopicImpl',
   'noticecast.logictier.bie.BIETopicRImpl'
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   320,
   'noticecast.logictier.bie.calculation.CalculationImpl',
   'NC_CALCULATION',
   'noticecast.datatier.bie.calculation.JDBCDhCalculationImpl',
   'noticecast.logictier.bie.calculation.CalculationRImpl'
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   330,
   'noticecast.logictier.bie.rules.FilterRuleImpl',
   'NC_FILTER_RULE',
   'noticecast.datatier.bie.rules.JDBCDhFilterRuleImpl',
   'noticecast.logictier.bie.rules.FilterRuleRImpl'
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   340,
   'noticecast.logictier.bie.rules.AggregateRuleImpl',
   'NC_AGGREGATE_RULE',
   'noticecast.datatier.bie.rules.JDBCDhAggregateRuleImpl',
   'noticecast.logictier.bie.rules.AggregateRuleRImpl'
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   350,
   'noticecast.logictier.bie.rules.ComparativeRuleImpl',
   'NC_COMPARATIVE_RULE',
   'noticecast.datatier.bie.rules.JDBCDhComparativeRuleImpl',
   'noticecast.logictier.bie.rules.ComparativeRuleRImpl'
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   360,
   NULL,
   'NC_RULE',
   'noticecast.datatier.bie.rules.JDBCDhRuleImpl',
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   700,
   'noticecast.logictier.recipient.RecipientImpl',
   'NC_RECIPIENT',
   'noticecast.datatier.recipient.JDBCDhRecipientImpl',
   'noticecast.logictier.recipient.RecipientRImpl'
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   721,
   'noticecast.logictier.message.attachment.MessageAttachment',
   'NC_MESSAGE_ATTACHMENT',
   NULL,
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   740,
   'noticecast.logictier.message.MessageStructImpl',
   'NC_MESSAGESTRUCT',
   'noticecast.datatier.message.JDBCDhJDBCMessageStruct',
   'noticecast.logictier.message.MessageStructRImpl'
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   741,
   'noticecast.logictier.dynamicrecipient.DynamicRecipientStructImpl',
   'NC_DYNAMIC_RECIPIENT_STRUCT',
   'noticecast.datatier.dynamicrecipient.JDBCDhDynamicRecipientStructImpl',
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   742,
   'noticecast.logictier.dynamicrecipient.DynamicDeliveryInformationStructImpl',
   'NC_DYN_DELIVERY_INFO_STRUCT',
   'noticecast.datatier.dynamicrecipient.JDBCDhDynamicDeliveryInfoStructImpl',
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   745,
   'noticecast.logictier.recipient.RecipientDeliveryScheduleImpl',
   'NC_RECIPIENTSCHEDULE',
   NULL,
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   746,
   'noticecast.logictier.recipient.DeliveryAddressImpl',
   'NC_DELIVERYADDRESS',
   NULL,
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   900,
   'noticecast.logictier.agent.TaskImpl',
   'NC_TASK',
   'noticecast.datatier.task.JDBCDhJDBCTask',
   'noticecast.logictier.agent.TaskRImpl'
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   901,
   'noticecast.logictier.agent.TaskImpl',
   'NC_TASK',
   'noticecast.datatier.task.JDBCDhJDBCTask',
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   902,
   'noticecast.scheduling.nc.TaskScheduleImpl',
   'NC_TASK_SCHEDULE',
   'noticecast.datatier.scheduling.JDBCDhTaskScheduleImpl',
   'noticecast.scheduling.nc.TaskScheduleRImpl'
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   905,
   'noticecast.logictier.agent.TaskImpl',
   'NC_TASK',
   'noticecast.datatier.task.JDBCDhJDBCTask',
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   906,
   'noticecast.logictier.agent.TaskImpl',
   'NC_TASK',
   'noticecast.datatier.task.JDBCDhJDBCTask',
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   907,
   'noticecast.logictier.agent.TaskImpl',
   'NC_TASK',
   'noticecast.datatier.task.JDBCDhJDBCTask',
   'noticecast.logictier.agent.TaskRImpl'
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   908,
   'noticecast.logictier.agent.TaskImpl',
   'NC_TASK',
   'noticecast.datatier.task.JDBCDhJDBCTask',
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   909,
   'noticecast.logictier.executable.ExecutableImpl',
   'NC_EXECUTABLE',
   'noticecast.datatier.executable.JDBCDhJDBCExecuteable',
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   1000,
   'noticecast.scheduling.schedules.YearlySchedule',
   'NC_SCHEDULE',
   'noticecast.datatier.scheduling.JDBCDhScheduleImpl',
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   1001,
   'noticecast.scheduling.schedules.MonthlySchedule',
   'NC_SCHEDULE',
   'noticecast.datatier.scheduling.JDBCDhScheduleImpl',
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   1002,
   'noticecast.scheduling.schedules.WeeklySchedule',
   'NC_SCHEDULE',
   'noticecast.datatier.scheduling.JDBCDhScheduleImpl',
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   1003,
   'noticecast.scheduling.schedules.DailySchedule',
   'NC_SCHEDULE',
   'noticecast.datatier.scheduling.JDBCDhScheduleImpl',
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   1004,
   'noticecast.scheduling.schedules.FixedIntervalSchedule',
   'NC_SCHEDULE',
   'noticecast.datatier.scheduling.JDBCDhScheduleImpl',
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   1005,
   'noticecast.scheduling.schedules.ISchedule',
   'NC_SCHEDULE',
   'noticecast.datatier.scheduling.JDBCDhScheduleImpl',
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   1020,
   'noticecast.scheduling.schedules.ISchedule',
   'NC_SCHEDULE',
   'noticecast.datatier.scheduling.JDBCDhScheduleImpl',
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   1021,
   'noticecast.scheduling.schedules.ISchedule',
   'NC_SCHEDULE',
   'noticecast.datatier.scheduling.JDBCDhScheduleImpl',
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   1022,
   'noticecast.scheduling.schedules.ISchedule',
   'NC_SCHEDULE',
   'noticecast.datatier.scheduling.JDBCDhScheduleImpl',
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   1023,
   'noticecast.scheduling.schedules.ISchedule',
   'NC_SCHEDULE',
   'noticecast.datatier.scheduling.JDBCDhScheduleImpl',
   NULL
);

INSERT INTO NC_CTMAP (OBJTYPE,CLASS,TABLENAME,HELPER,REMOTECLASS) VALUES(
   1024,
   'noticecast.scheduling.nc.NcScheduleWrapper',
   'NC_SCHEDULE',
   'noticecast.datatier.scheduling.JDBCDhScheduleImpl',
   NULL
);

INSERT INTO NC_DB_VERSION (DB_VERSION_ID,BUILD) VALUES(
   1032,
   'build no.'
);

INSERT INTO NC_OBJECTID (OBJECTID) VALUES(
   0
);

INSERT INTO NC_PERMISSION (PK_PERMISSION_ID,DESCRIPTION) VALUES(
   1,
   'Create'
);

INSERT INTO NC_PERMISSION (PK_PERMISSION_ID,DESCRIPTION) VALUES(
   2,
   'Read'
);

INSERT INTO NC_PERMISSION (PK_PERMISSION_ID,DESCRIPTION) VALUES(
   3,
   'Update'
);

INSERT INTO NC_PERMISSION (PK_PERMISSION_ID,DESCRIPTION) VALUES(
   4,
   'Delete'
);

INSERT INTO NC_PERMISSION (PK_PERMISSION_ID,DESCRIPTION) VALUES(
   5,
   'Execute'
);


-------------------------------------------------------------------------------
--	END NC_CREATE_Hsql.sql        *  DO NOT EDIT  *
-------------------------------------------------------------------------------

