

--
--    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_SYBASE.sql         *  DO NOT EDIT  *       Data Store Version: 1032
-------------------------------------------------------------------------------

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

CREATE TABLE NC_CONFIGURATION(
	PROPERTY_KEY 		VARCHAR(255) NOT NULL,
	PROPERTY_VALUE		NVARCHAR(255) NULL
) lock datarows
go

CREATE TABLE NC_CTMAP(
   OBJTYPE                       INTEGER NOT NULL,
   CLASS                         VARCHAR(200) NULL,
   TABLENAME                     VARCHAR(200) NOT NULL,
   HELPER                        VARCHAR(200) NULL,
   REMOTECLASS                   VARCHAR(200) NULL
) lock datarows
go

CREATE TABLE NC_DB_VERSION(
   DB_VERSION_ID                 INTEGER NULL,
   BUILD                         NVARCHAR(20) NULL
) lock datarows
go

CREATE TABLE NC_DELIVERYADDRESS(
   PK_DELADDRESS_ID              INTEGER NOT NULL,
   DELIVERY_ADDRESS              NVARCHAR(100) NULL,
   CHANNEL_TYPE                  INTEGER NULL,
   IS_DEFAULT                    INTEGER NOT NULL,
   FK_RECIPIENT_ID               INTEGER NULL,
   ADDRESS_TYPE                  INTEGER NULL
) lock datarows
go

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

CREATE TABLE NC_JMSQUEUE (
	QUEUE_ENTRY_ID               INTEGER NOT NULL,
	QUEUE_NAME                   NVARCHAR(50) NULL,
	QUEUE_ENTRY                  IMAGE NULL,
	SDS_INSTANCE_ID		         CHAR (32) NULL,
	DATE_ENTERED 		         NUMERIC(19) NOT NULL,
	REDELIVER_DATE 			NUMERIC(19) NULL,
   	REDELIVER_COUNT 		INTEGER DEFAULT (0)
) lock datarows
go

CREATE TABLE NC_JOBQUEUE (
    PK_RUN_ID          	CHAR (45) NOT NULL ,
	SERVICE_NAME 		CHAR (40) NULL,
	SERVER_GROUP 		CHAR (40) NULL,
    DATE_ENTERED 		NUMERIC(19) NOT NULL ,
    JOB 				IMAGE NOT NULL 
) lock datarows
go

CREATE TABLE NC_MESSAGELINE(
   FK_MESSAGESTRUCT_ID           INTEGER NOT NULL,
   LINE_NO                       INTEGER NOT NULL,
   LINE_TYPE                     INTEGER NULL
) lock datarows
go

CREATE TABLE NC_MESSAGELINE_ELEMENT(
   FK_MESSAGESTRUCT_ID           INTEGER NOT NULL,
   ELEMENT_NUMBER                INTEGER NOT NULL,
   LINE_NO                       INTEGER NOT NULL,
   TEXT                          NVARCHAR(2000) NULL,
   FK_BIE_TOPIC_ID               INTEGER NULL
) lock datarows
go

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

CREATE TABLE NC_METRICS(
   NAME 		NVARCHAR(255) 	NOT NULL,
   LASTMOD_TIME 	NUMERIC(19, 0)	DEFAULT (0) NOT NULL,
   VALUE 		NUMERIC(19, 0)	DEFAULT (0) NOT NULL,
   ACTIVE 		INTEGER 	DEFAULT (0) NOT NULL
) lock datarows
go

CREATE TABLE NC_OBJECTCATALOGUE(
   PK_OID                        INTEGER NOT NULL,
   NAME                          NVARCHAR(255) NULL,
   DESCRIPTION                   NVARCHAR(1000) NULL,
   SUBTYPE                       SMALLINT NULL,
   TYPE                          INTEGER NOT NULL,
   MODCOUNT                      INTEGER DEFAULT (-1),
   CM_VERSION                    INTEGER DEFAULT (-1)
) lock datarows
go

CREATE TABLE NC_OBJECTID(
   OBJECTID                      INTEGER NOT NULL
) lock datarows
go

CREATE TABLE NC_PERMISSION(
   PK_PERMISSION_ID              INTEGER NOT NULL,
   DESCRIPTION                   VARCHAR(30) NOT NULL
) lock datarows
go

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

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

CREATE TABLE NC_SCHEDULE_QUEUE(
    SCHEDULE_ID 		INTEGER NOT NULL,
    RUN_DATE 		 	NUMERIC(19) NULL
) lock datarows
go

CREATE TABLE NC_SDS_INSTANCE (
    PK_INSTANCE_ID 		CHAR (32) NOT NULL ,
    PK_INSTANCE_URL 		NVARCHAR (255) NOT NULL ,
    LAST_UPDATE 		NUMERIC(19) NOT NULL ,
    CLEANUP_INSTANCE_ID 	CHAR (32) NULL 
) lock datarows
go

CREATE TABLE NC_TASK(
   PK_TASK_ID                    INTEGER NOT NULL,
   NAME                          NVARCHAR(255) NULL,
   DESCRIPTION                   NVARCHAR(1000) NULL,
   FK_BIE_ID                     INTEGER NULL,
   THRESHOLD                     INTEGER NULL,
   WEIGHTS                       NVARCHAR(200) NULL,
   TASK_TYPE                     INTEGER NULL,
   DATEFORMAT                    CHAR(19) NULL,
   DETECTION_OPTION              INTEGER NULL,
   LASTMOD_TIME                  DATETIME DEFAULT GETDATE(),
   MODCOUNT                      INTEGER DEFAULT (-1),
   LASTMOD_BY                    CHAR(40) NULL,
   LOCATION_ROOT 		 NVARCHAR(256) NULL,
   OBJECT_CLASS 		 NVARCHAR(256) NULL,
   OWNED_BY 			 NVARCHAR(1024) NULL
) lock datarows
go


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

CREATE TABLE NC_SCHEDULED_EVENT_OVERRIDE(
    FK_TASKSCHEDULE_ID 		INTEGER NOT NULL,
    EVENT_DATE			NUMERIC(19) NOT NULL,
    DELAY_UNTIL			NUMERIC(19) NULL,
    EVENT_STATUS                INTEGER NULL,
    EVENT_PRIORITY              INTEGER NULL,
    FK_SCHEDULE_ID      	INTEGER NULL,
    CANCELLED_BY          	NVARCHAR(2000) NULL
) lock datarows
go

CREATE TABLE NC_TASK_ANCESTOR_STOREIDS(
	TASK_ID 		CHAR(45) NOT NULL,
	ANCESTOR_STORE_ID 	NVARCHAR(256) NOT NULL
) lock datarows
go

CREATE TABLE NC_TASK_HISTORY_DETAIL(
   TASK_ID	CHAR(45) NOT NULL,
   SUB_INDEX    INTEGER NOT NULL,
   SEVERITY     INTEGER NULL,
   CLASSTYPE    CHAR(128) NULL,
   TASK 	IMAGE NULL,
   STATUS 		INTEGER DEFAULT (0) NOT NULL
) lock datarows
go

CREATE TABLE NC_TASK_HISTORY_SUB_INDEX(
    TASK_ID             CHAR(45) NOT NULL,
    LAST_SUB_INDEX      INTEGER NOT NULL
) lock datarows
go

CREATE TABLE NC_TASK_PROPERTY (
	TASK_ID 			CHAR (45) NOT NULL,
	PROP_NAME			CHAR (45) NOT NULL,
	PROP_VALUE			NVARCHAR(2000) NULL
) lock datarows
go

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

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

CREATE TABLE NC_RESOURCE_LOCK (
	LOCK_RESOURCE CHAR(50) NOT NULL,
	OWNER CHAR (50) NOT NULL,
	TIMESTAMP NUMERIC(19) NOT NULL
)  lock datarows
go

CREATE TABLE R_MESSAGESTRUCT_TASK(
   FK_MESSAGESTRUCT_ID           INTEGER NOT NULL,
   FK_TASK_ID                    INTEGER NOT NULL
) lock datarows
go

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

CREATE TABLE R_NEWSITEMS_NCOBJECTS(
   NID                           CHAR(32) NOT NULL,
   FK_NCID                       INTEGER NOT NULL,
   TYPE                          SMALLINT NULL
) lock datarows
go

CREATE TABLE R_TASKSCHEDULE_SCHEDULE(
   FK_TASKSCHEDULE_ID            INTEGER NOT NULL,
   FK_SCHEDULE_ID                INTEGER NOT NULL,
   IS_ACTIVE                     INTEGER NULL,
   IS_ESCALATION                 INTEGER NULL
) lock datarows
go




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


CREATE INDEX IN_JOBQ_SELECTOR ON NC_JOBQUEUE (SERVICE_NAME, SERVER_GROUP, DATE_ENTERED)
go

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

CREATE INDEX IX_NC_JMSQUEUE1 ON NC_JMSQUEUE(QUEUE_NAME, SDS_INSTANCE_ID) 
go

CREATE INDEX I1N_MESSAGELINE ON NC_MESSAGELINE (
   FK_MESSAGESTRUCT_ID)
go

CREATE INDEX I1N_MESSAGELINE_EL ON NC_MESSAGELINE_ELEMENT (
   FK_MESSAGESTRUCT_ID)
go

CREATE INDEX I2N_MESSAGELINE_EL ON NC_MESSAGELINE_ELEMENT (
   LINE_NO,FK_MESSAGESTRUCT_ID)
go

CREATE INDEX I1N_MESSAGESTRUCT ON NC_MESSAGESTRUCT (
   FK_DYNREC_ID)
go

CREATE INDEX I1N_TASKSCHEDULE ON NC_TASKSCHEDULE (
   FK_TASK_ID)
go

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

CREATE INDEX I1N_TASKQUEUERESTARTID ON NC_TASK_QUEUE (
	RESTART_ID)
go

CREATE INDEX IX_NC_TSE_STATE_MAP ON NC_TSE_STATE_MAP (
	PARENT_ID, SEQ)
go

CREATE INDEX I1R_MESSAGESTRUCT_ ON R_MESSAGESTRUCT_TASK (
   FK_MESSAGESTRUCT_ID)
go

CREATE INDEX I1R_MSGSTRUCT_RECI ON R_MSGSTRUCT_RECIPIENT_DELIVINF (
   FK_MESSAGESTRUCT_ID)
go

CREATE INDEX I1R_NEWSITEMS_NCOB ON R_NEWSITEMS_NCOBJECTS (
   TYPE)
go

CREATE INDEX I2R_NEWSITEMS_NCOB ON R_NEWSITEMS_NCOBJECTS (
   FK_NCID)
go

CREATE INDEX I3R_NEWSITEMS_NCOB ON R_NEWSITEMS_NCOBJECTS (
   FK_NCID, NID)
go

CREATE INDEX I1R_TASKSCHEDULE_S ON R_TASKSCHEDULE_SCHEDULE (
   FK_TASKSCHEDULE_ID)
go

CREATE INDEX I1N_EVENT_DATES ON NC_SCHEDULED_EVENT_OVERRIDE (
   FK_TASKSCHEDULE_ID)
go

CREATE INDEX I1N_DELIV_ADR ON NC_DELIVERYADDRESS (
   FK_RECIPIENT_ID)
go


-------------------------------------------------------------------------------
--$202-- primary keys add begin
-------------------------------------------------------------------------------

ALTER TABLE NC_CONFIGURATION
	ADD CONSTRAINT PN_CONFIGURATION PRIMARY KEY (PROPERTY_KEY)
go

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

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

ALTER TABLE NC_EVENTSTATUS
   ADD CONSTRAINT PN_NC_EVENTSTATUS PRIMARY KEY (PK_EVENT_ID)
go

ALTER TABLE NC_JMSQUEUE
   ADD CONSTRAINT PN_NC_JMSQUEUE PRIMARY KEY (QUEUE_ENTRY_ID)
go

ALTER TABLE NC_JOBQUEUE
	ADD CONSTRAINT PN_JOBQUEUE PRIMARY KEY (PK_RUN_ID)
go

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

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

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

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

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

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

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

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

ALTER TABLE NC_SCHEDULE
   ADD CONSTRAINT PN_SCHEDULE PRIMARY KEY (PK_SCHEDULE_ID)
go

ALTER TABLE NC_SCHEDULE_QUEUE
   ADD CONSTRAINT PN_SCHEDULE_QUEUEI PRIMARY KEY (SCHEDULE_ID)
go

ALTER TABLE NC_SDS_INSTANCE
	ADD CONSTRAINT PN_SDS_INSTANCE PRIMARY KEY (PK_INSTANCE_ID)
go

ALTER TABLE NC_TASK
   ADD CONSTRAINT PN_TASK PRIMARY KEY (PK_TASK_ID)
go

ALTER TABLE NC_TASK_ANCESTOR_STOREIDS
   ADD CONSTRAINT PK_ANCESTOR_IDS PRIMARY KEY (TASK_ID, ANCESTOR_STORE_ID)
go

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

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

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

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

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

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

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

ALTER TABLE NC_RESOURCE_LOCK ADD CONSTRAINT PR_RESOURCE_LOCK PRIMARY KEY (LOCK_RESOURCE)
go

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

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

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

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


-------------------------------------------------------------------------------
--$240-- foreign keys add begin
-------------------------------------------------------------------------------

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

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

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

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

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

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

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

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

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



-------------------------------------------------------------------------------
--$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')
go


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


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


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


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


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


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'
)
go


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


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


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
)
go


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


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


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


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


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


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


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


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


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'
)
go


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'
)
go


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'
)
go


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'
)
go


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'
)
go


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'
)
go


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'
)
go


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


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'
)
go


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


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'
)
go


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


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
)
go


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


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


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'
)
go


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


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'
)
go


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


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


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'
)
go


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


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


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


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


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


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


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


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


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


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


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


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


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


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


INSERT INTO NC_OBJECTID (OBJECTID) VALUES(
   0
)
go


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


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


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


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


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

-------------------------------------------------------------------------------
--	END NC_CREATE_SYBASE.sql        *  DO NOT EDIT  *   version 1032
-------------------------------------------------------------------------------

