DROP TABLE IF EXISTS `sct2_concept`;
CREATE TABLE `sct2_concept` (
`id` BIGINT NOT NULL DEFAULT 0,
`effectiveTime` VARCHAR(20) NOT NULL DEFAULT '0000-00-00 00:00:00',
`active` TINYINT NOT NULL DEFAULT 0,
`moduleId` BIGINT NOT NULL DEFAULT 0,
`definitionStatusId` BIGINT NOT NULL DEFAULT 0,
PRIMARY KEY (`id`,`effectiveTime`)
);
Select 'Table sct2_concept created successfully';
CREATE INDEX ix_sct2_concept ON sct2_concept(id,active);

DROP TABLE IF EXISTS `sct2_description`;
CREATE TABLE `sct2_description` (
id BIGINT NOT NULL DEFAULT 0,
effectiveTime VARCHAR(20) NOT NULL DEFAULT '0000-00-00 00:00:00',
active TINYINT NOT NULL DEFAULT 0,
moduleId BIGINT NOT NULL DEFAULT 0,
conceptId BIGINT NOT NULL DEFAULT 0,
languageCode VARCHAR(3) NOT NULL DEFAULT '',
typeId BIGINT NOT NULL DEFAULT 0,
Term VARCHAR(4096) NOT NULL DEFAULT '',
caseSignificanceId BIGINT NOT NULL DEFAULT 0,
PRIMARY KEY (id,effectiveTime),
);
Select 'Table sct2_description created successfully';
CREATE INDEX ix_sct2_description_3 ON sct2_description(conceptId,typeId,languageCode,active);


DROP TABLE IF EXISTS sct2_relationship;
CREATE TABLE sct2_relationship (
id BIGINT NOT NULL DEFAULT 0,
effectiveTime VARCHAR(20) NOT NULL DEFAULT '0000-00-00 00:00:00',
active TINYINT NOT NULL DEFAULT 0,
moduleId BIGINT NOT NULL DEFAULT 0,
sourceId BIGINT NOT NULL DEFAULT 0,
destinationId BIGINT NOT NULL DEFAULT 0,
relationshipGroup INT NOT NULL DEFAULT 0,
typeId BIGINT NOT NULL DEFAULT 0,
characteristicTypeId BIGINT NOT NULL DEFAULT 0,
modifierId BIGINT NOT NULL DEFAULT 0,
PRIMARY KEY (id,effectiveTime),
);
Select 'Table sct2_relationship created successfully';
CREATE INDEX ix_sct2_relationship ON sct2_relationship(id);

DROP TABLE IF EXISTS der2_refset_lang;
CREATE TABLE der2_refset_lang (
id VARCHAR(36) NOT NULL DEFAULT 0,
effectiveTime VARCHAR(20) NOT NULL DEFAULT '0000-00-00 00:00:00',
active TINYINT NOT NULL DEFAULT 0,
moduleId BIGINT NOT NULL DEFAULT 0,
refsetId BIGINT NOT NULL DEFAULT 0,
referencedComponentId BIGINT NOT NULL DEFAULT 0,
acceptabilityId BIGINT NOT NULL DEFAULT 0,
PRIMARY KEY (id,effectiveTime)
);

CREATE INDEX ix_der2_refset_lang_2 ON der2_refset_lang(referencedComponentId,acceptabilityId,refsetId,active);

DROP TABLE IF EXISTS sct2_relationships_tc;
CREATE TABLE sct2_relationships_tc (
parentId BIGINT NOT NULL DEFAULT 0,
childId BIGINT NOT NULL DEFAULT 0,
countOfChildrens INT NOT NULL DEFAULT 0,
isImmediateChildren TINYINT NOT NULL DEFAULT 0
);
Select 'Table sct2_relationship_tc created successfully';
CREATE INDEX ix_sct2_relationship_tc on sct2_relationships_tc(childId);

DROP TABLE IF EXISTS `sct2_textdefinition`;
CREATE TABLE `sct2_textdefinition` (
id BIGINT NOT NULL DEFAULT 0,
effectiveTime VARCHAR(20) NOT NULL DEFAULT '0000-00-00 00:00:00',
active TINYINT NOT NULL DEFAULT 0,
moduleId BIGINT NOT NULL DEFAULT 0,
conceptId BIGINT NOT NULL DEFAULT 0,
languageCode VARCHAR(3) NOT NULL DEFAULT '',
typeId BIGINT NOT NULL DEFAULT 0,
Term VARCHAR(50000) NOT NULL DEFAULT '',
caseSignificanceId BIGINT NOT NULL DEFAULT 0,
PRIMARY KEY (id,effectiveTime),

);
Select 'Table sct2_textdefinition created successfully';
CREATE INDEX ix_sct2_textdefinition ON sct2_textdefinition(id);

DROP TABLE IF EXISTS der2_refset_simplemap;
CREATE TABLE der2_refset_simplemap (
id VARCHAR(36) NOT NULL DEFAULT 0,
effectiveTime VARCHAR(20) NOT NULL DEFAULT '0000-00-00 00:00:00',
active TINYINT NOT NULL DEFAULT 0,
moduleId BIGINT NOT NULL DEFAULT 0,
refsetId BIGINT NOT NULL DEFAULT 0,
referencedComponentId BIGINT NOT NULL,
mapTarget VARCHAR(20) NOT NULL,
PRIMARY KEY (id,effectiveTime),
);

Select 'Table der2_refset_simplemap created successfully';

DROP TABLE IF EXISTS der2_crefset;
CREATE TABLE der2_crefset (
id VARCHAR(36) NOT NULL DEFAULT 0,
effectiveTime VARCHAR(20) NOT NULL DEFAULT '0000-00-00 00:00:00',
active TINYINT NOT NULL DEFAULT 0,
moduleId BIGINT NOT NULL DEFAULT 0,
refsetId BIGINT NOT NULL DEFAULT 0,
referencedComponentId BIGINT NOT NULL DEFAULT 0,
targetId BIGINT NOT NULL DEFAULT 0,
PRIMARY KEY (id,effectiveTime),
);

Select 'Table der2_crefset created successfully';

DROP TABLE IF EXISTS der2_refset;
CREATE TABLE IF NOT EXISTS `der2_refset` (
`id` varchar(36) NOT NULL DEFAULT 0,
`effectiveTime` varchar(20) NOT NULL DEFAULT '0000-00-00 00:00:00',
`active` TINYINT NOT NULL DEFAULT 0,
`moduleId` BIGINT NOT NULL DEFAULT 0,
`refsetId` BIGINT NOT NULL DEFAULT 0,
`referencedComponentId` BIGINT NOT NULL DEFAULT 0,
PRIMARY KEY (`id`,`effectiveTime`),

);

DROP TABLE IF EXISTS sct2_concrete_relationship;
CREATE TABLE sct2_concrete_relationship (
id BIGINT NOT NULL DEFAULT 0,
effectiveTime VARCHAR(20) NOT NULL DEFAULT '0000-00-00 00:00:00',
active TINYINT NOT NULL DEFAULT 0,
moduleId BIGINT NOT NULL DEFAULT 0,
sourceId BIGINT NOT NULL DEFAULT 0,
destinationValue VARCHAR(55) NOT NULL DEFAULT '',
relationshipGroup INT NOT NULL DEFAULT 0,
typeId BIGINT NOT NULL DEFAULT 0,
characteristicTypeId BIGINT NOT NULL DEFAULT 0,
modifierId BIGINT NOT NULL DEFAULT 0,
PRIMARY KEY (id,effectiveTime),
);
Select 'Table sct2_concrete_relationship created successfully';
CREATE INDEX ix_sct2_concrete_relationship ON sct2_concrete_relationship(id);

