drawdb icon indicating copy to clipboard operation
drawdb copied to clipboard

Relationships are not always imported correctly from source

Open jamaa opened this issue 1 year ago • 0 comments

When importing the following SQL, the relationships between the tables are not imported:

CREATE TABLE `Pattern` (
	`Id`	INT NOT NULL AUTO_INCREMENT,
	`Description`	VARCHAR(255),
	`IsFlexible`	BOOLEAN DEFAULT (FALSE),
	`IsInterpolated`	BOOLEAN NOT NULL DEFAULT (FALSE),
	`PatternType`	INT NOT NULL,
	`ScenarioId`	INT NOT NULL,
	CONSTRAINT `PK_Pattern` PRIMARY KEY(`Id`)
);
CREATE TABLE `PatternDateValue` (
	`PatternId`	INT NOT NULL,
	`Date`	DATETIME NOT NULL,
	`Value`	DOUBLE,
	CONSTRAINT `PK_PatternDateValue` PRIMARY KEY(`PatternId`,`Date`),
	CONSTRAINT `FK_PatternDateValue_Pattern_PatternId` FOREIGN KEY(`PatternId`) REFERENCES `Pattern`(`Id`) ON DELETE CASCADE
);
CREATE TABLE `PatternNumberValue` (
	`PatternId`	INT NOT NULL,
	`Number`	SMALLINT NOT NULL,
	`Value`	DOUBLE,
	CONSTRAINT `PK_PatternNumberValue` PRIMARY KEY(`PatternId`,`Number`),
	CONSTRAINT `FK_PatternNumberValue_Pattern_PatternId` FOREIGN KEY(`PatternId`) REFERENCES `Pattern`(`Id`) ON DELETE CASCADE
);

Other relationships work as expected though. I can't figure out why some work and some don't.

Here is one that is imported correctly:

CREATE TABLE `ScenarioGroup` (
	`Id`	INT NOT NULL AUTO_INCREMENT,
	`Description`	VARCHAR(255),
	`Name`	VARCHAR(255),
	`DateCreated`	DATETIME NOT NULL,
	CONSTRAINT `PK_ScenarioGroup` PRIMARY KEY(`Id`)
);
CREATE TABLE `Scenario` (
	`Id`	INT NOT NULL AUTO_INCREMENT,
	`ScenarioGroupId`	INT NOT NULL,
	`DateCreated`	DATETIME NOT NULL,
	`Name`	VARCHAR(255),
	`Description`	VARCHAR(255),
	`ActiveSimulationId`	INT DEFAULT (0),
	`IsUpdateActive`	BOOLEAN DEFAULT (TRUE),
	`OperationalInfo`	VARCHAR(255),
	CONSTRAINT `PK_Scenario` PRIMARY KEY(`Id`),
	CONSTRAINT `FK_Scenario_ScenarioGroup_ScenarioGroupId` FOREIGN KEY(`ScenarioGroupId`) REFERENCES `ScenarioGroup`(`Id`) ON DELETE CASCADE
);

jamaa avatar Apr 06 '24 17:04 jamaa