/* ---------------------------------------------------- */
/*  Generated by Enterprise Architect Version 12.0 		*/
/*  Created On : 10-jan-2019 12:58:49 				*/
/*  DBMS       : SQLite 								*/
/* ---------------------------------------------------- */

/* Drop Tables */

DROP TABLE IF EXISTS 'VersionEntity'
;

DROP TABLE IF EXISTS 'GrassCoverErosionInwardsDikeHeightOutputEntity'
;

DROP TABLE IF EXISTS 'ProjectEntity'
;

DROP TABLE IF EXISTS 'MacroStabilityInwardsFailureMechanismMetaEntity'
;

DROP TABLE IF EXISTS 'AssessmentSectionEntity'
;

DROP TABLE IF EXISTS 'MacroStabilityOutwardsFailureMechanismMetaEntity'
;

DROP TABLE IF EXISTS 'FailureMechanismSectionEntity'
;

DROP TABLE IF EXISTS 'FailureMechanismEntity'
;

DROP TABLE IF EXISTS 'StabilityPointStructuresCalculationEntity'
;

DROP TABLE IF EXISTS 'ClosingStructuresFailureMechanismMetaEntity'
;

DROP TABLE IF EXISTS 'PipingFailureMechanismMetaEntity'
;

DROP TABLE IF EXISTS 'StabilityStoneCoverFailureMechanismMetaEntity'
;

DROP TABLE IF EXISTS 'CalculationGroupEntity'
;

DROP TABLE IF EXISTS 'HydraulicLocationEntity'
;

DROP TABLE IF EXISTS 'PipingCalculationEntity'
;

DROP TABLE IF EXISTS 'GrassCoverErosionInwardsFailureMechanismMetaEntity'
;

DROP TABLE IF EXISTS 'StabilityPointStructuresFailureMechanismMetaEntity'
;

DROP TABLE IF EXISTS 'GrassCoverErosionInwardsCalculationEntity'
;

DROP TABLE IF EXISTS 'DuneErosionFailureMechanismMetaEntity'
;

DROP TABLE IF EXISTS 'GrassCoverErosionOutwardsFailureMechanismMetaEntity'
;

DROP TABLE IF EXISTS 'PipingSoilLayerEntity'
;

DROP TABLE IF EXISTS 'HeightStructuresFailureMechanismMetaEntity'
;

DROP TABLE IF EXISTS 'PipingSoilProfileEntity'
;

DROP TABLE IF EXISTS 'PipingStochasticSoilProfileEntity'
;

DROP TABLE IF EXISTS 'StochasticSoilModelEntity'
;

DROP TABLE IF EXISTS 'SurfaceLineEntity'
;

DROP TABLE IF EXISTS 'PipingCharacteristicPointEntity'
;

DROP TABLE IF EXISTS 'PipingCalculationOutputEntity'
;

DROP TABLE IF EXISTS 'PipingStructureFailureMechanismMetaEntity'
;

DROP TABLE IF EXISTS 'PipingSectionResultEntity'
;

DROP TABLE IF EXISTS 'GrassCoverErosionInwardsSectionResultEntity'
;

DROP TABLE IF EXISTS 'HeightStructuresSectionResultEntity'
;

DROP TABLE IF EXISTS 'StrengthStabilityLengthwiseConstructionSectionResultEntity'
;

DROP TABLE IF EXISTS 'TechnicalInnovationSectionResultEntity'
;

DROP TABLE IF EXISTS 'WaterPressureAsphaltCoverSectionResultEntity'
;

DROP TABLE IF EXISTS 'ClosingStructuresSectionResultEntity'
;

DROP TABLE IF EXISTS 'GrassCoverErosionOutwardsSectionResultEntity'
;

DROP TABLE IF EXISTS 'GrassCoverSlipOffInwardsSectionResultEntity'
;

DROP TABLE IF EXISTS 'GrassCoverSlipOffOutwardsSectionResultEntity'
;

DROP TABLE IF EXISTS 'MacroStabilityInwardsSectionResultEntity'
;

DROP TABLE IF EXISTS 'MacroStabilityOutwardsSectionResultEntity'
;

DROP TABLE IF EXISTS 'WaveImpactAsphaltCoverFailureMechanismMetaEntity'
;

DROP TABLE IF EXISTS 'WaveImpactAsphaltCoverSectionResultEntity'
;

DROP TABLE IF EXISTS 'MicrostabilitySectionResultEntity'
;

DROP TABLE IF EXISTS 'PipingStructureSectionResultEntity'
;

DROP TABLE IF EXISTS 'DuneErosionSectionResultEntity'
;

DROP TABLE IF EXISTS 'StabilityStoneCoverSectionResultEntity'
;

DROP TABLE IF EXISTS 'StabilityPointStructuresSectionResultEntity'
;

DROP TABLE IF EXISTS 'DikeProfileEntity'
;

DROP TABLE IF EXISTS 'GrassCoverErosionInwardsOutputEntity'
;

DROP TABLE IF EXISTS 'ForeshoreProfileEntity'
;

DROP TABLE IF EXISTS 'StabilityStoneCoverWaveConditionsCalculationEntity'
;

DROP TABLE IF EXISTS 'StabilityStoneCoverWaveConditionsOutputEntity'
;

DROP TABLE IF EXISTS 'WaveImpactAsphaltCoverWaveConditionsCalculationEntity'
;

DROP TABLE IF EXISTS 'WaveImpactAsphaltCoverWaveConditionsOutputEntity'
;

DROP TABLE IF EXISTS 'GrassCoverErosionOutwardsWaveConditionsCalculationEntity'
;

DROP TABLE IF EXISTS 'GrassCoverErosionOutwardsWaveConditionsOutputEntity'
;

DROP TABLE IF EXISTS 'HeightStructuresOutputEntity'
;

DROP TABLE IF EXISTS 'HeightStructureEntity'
;

DROP TABLE IF EXISTS 'HeightStructuresCalculationEntity'
;

DROP TABLE IF EXISTS 'ClosingStructureEntity'
;

DROP TABLE IF EXISTS 'ClosingStructuresCalculationEntity'
;

DROP TABLE IF EXISTS 'ClosingStructuresOutputEntity'
;

DROP TABLE IF EXISTS 'StabilityPointStructureEntity'
;

DROP TABLE IF EXISTS 'StabilityPointStructuresOutputEntity'
;

DROP TABLE IF EXISTS 'HydraulicLocationOutputEntity'
;

DROP TABLE IF EXISTS 'DuneLocationEntity'
;

DROP TABLE IF EXISTS 'DuneLocationCalculationOutputEntity'
;

DROP TABLE IF EXISTS 'BackgroundDataEntity'
;

DROP TABLE IF EXISTS 'BackgroundDataMetaEntity'
;

DROP TABLE IF EXISTS 'GrassCoverErosionInwardsOvertoppingRateOutputEntity'
;

DROP TABLE IF EXISTS 'GeneralResultSubMechanismIllustrationPointEntity'
;

DROP TABLE IF EXISTS 'SubMechanismIllustrationPointEntity'
;

DROP TABLE IF EXISTS 'IllustrationPointResultEntity'
;

DROP TABLE IF EXISTS 'StochastEntity'
;

DROP TABLE IF EXISTS 'GeneralResultSubMechanismIllustrationPointStochastEntity'
;

DROP TABLE IF EXISTS 'GeneralResultFaultTreeIllustrationPointEntity'
;

DROP TABLE IF EXISTS 'FaultTreeIllustrationPointEntity'
;

DROP TABLE IF EXISTS 'FaultTreeIllustrationPointStochastEntity'
;

DROP TABLE IF EXISTS 'GeneralResultFaultTreeIllustrationPointStochastEntity'
;

DROP TABLE IF EXISTS 'TopLevelSubMechanismIllustrationPointEntity'
;

DROP TABLE IF EXISTS 'TopLevelFaultTreeIllustrationPointEntity'
;

DROP TABLE IF EXISTS 'SubMechanismIllustrationPointStochastEntity'
;

DROP TABLE IF EXISTS 'FaultTreeSubmechanismIllustrationPointEntity'
;

DROP TABLE IF EXISTS 'MacroStabilityInwardsCalculationEntity'
;

DROP TABLE IF EXISTS 'MacroStabilityInwardsCalculationOutputEntity'
;

DROP TABLE IF EXISTS 'MacroStabilityInwardsCharacteristicPointEntity'
;

DROP TABLE IF EXISTS 'MacroStabilityInwardsSoilLayerOneDEntity'
;

DROP TABLE IF EXISTS 'MacroStabilityInwardsSoilProfileOneDEntity'
;

DROP TABLE IF EXISTS 'MacroStabilityInwardsSoilLayerTwoDEntity'
;

DROP TABLE IF EXISTS 'MacroStabilityInwardsSoilProfileTwoDEntity'
;

DROP TABLE IF EXISTS 'MacroStabilityInwardsStochasticSoilProfileEntity'
;

DROP TABLE IF EXISTS 'MacroStabilityInwardsPreconsolidationStressEntity'
;

DROP TABLE IF EXISTS 'MacroStabilityInwardsSoilProfileTwoDSoilLayerTwoDEntity'
;

DROP TABLE IF EXISTS 'HydraulicLocationCalculationEntity'
;

DROP TABLE IF EXISTS 'HydraulicLocationCalculationCollectionEntity'
;

DROP TABLE IF EXISTS 'DuneLocationCalculationCollectionEntity'
;

DROP TABLE IF EXISTS 'DuneLocationCalculationEntity'
;

DROP TABLE IF EXISTS 'HydraulicBoundaryDatabaseEntity'
;

/* Create Tables with Primary and Foreign Keys, Check and Unique Constraints */

CREATE TABLE 'VersionEntity'
(
	'VersionId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'Version' VARCHAR (20) NOT NULL,
	'Timestamp' DATETIME NOT NULL,
	'FingerPrint' BLOB NOT NULL
)
;

CREATE TABLE 'GrassCoverErosionInwardsDikeHeightOutputEntity'
(
	'GrassCoverErosionInwardsDikeHeightOutputEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'GrassCoverErosionInwardsOutputEntityId' INTEGER NOT NULL,
	'GeneralResultFaultTreeIllustrationPointEntityId' INTEGER,
	'DikeHeight' REAL,
	'TargetProbability' REAL,
	'TargetReliability' REAL,
	'CalculatedProbability' REAL,
	'CalculatedReliability' REAL,
	'CalculationConvergence' TINYINT (1) NOT NULL, -- Enum: 1 = NotCalculated, 2 = CalculationNotConverged, 3 = CalculationConverged
	CONSTRAINT 'FK_GrassCoverErosionInwardsDikeHeightOutputEntity_GeneralResultFaultTreeIllustrationPointEntity' FOREIGN KEY ('GeneralResultFaultTreeIllustrationPointEntityId') REFERENCES 'GeneralResultFaultTreeIllustrationPointEntity' ('GeneralResultFaultTreeIllustrationPointEntityId') ON DELETE Set Null ON UPDATE Cascade,
	CONSTRAINT 'FK_GrassCoverErosionInwardsDikeHeightOutputEntity_GrassCoverErosionInwardsOutputEntity' FOREIGN KEY ('GrassCoverErosionInwardsOutputEntityId') REFERENCES 'GrassCoverErosionInwardsOutputEntity' ('GrassCoverErosionInwardsOutputEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'U_GrassCoverErosionInwardsOutputEntity' UNIQUE ('GrassCoverErosionInwardsOutputEntityId')
)
;

CREATE TABLE 'ProjectEntity'
(
	'ProjectEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'Description' VARCHAR (260)
)
;

CREATE TABLE 'MacroStabilityInwardsFailureMechanismMetaEntity'
(
	'MacroStabilityInwardsFailureMechanismMetaEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismEntityId' INTEGER NOT NULL,
	'A' REAL NOT NULL,
	'StochasticSoilModelCollectionSourcePath' TEXT,
	'SurfaceLineCollectionSourcePath' TEXT,
	CONSTRAINT 'FK_MacroStabilityInwardsFailureMechanismMetaEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'AssessmentSectionEntity'
(
	'AssessmentSectionEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'ProjectEntityId' INTEGER NOT NULL,
	'HydraulicLocationCalculationCollectionEntity1Id' INTEGER NOT NULL, -- Represents the design water level factorized signaling norm
	'HydraulicLocationCalculationCollectionEntity2Id' INTEGER NOT NULL, -- Represents the design water level signaling norm
	'HydraulicLocationCalculationCollectionEntity3Id' INTEGER NOT NULL, -- Represents the design water level lower limit norm
	'HydraulicLocationCalculationCollectionEntity4Id' INTEGER NOT NULL, -- Represents the design water level factorized lower limit norm
	'HydraulicLocationCalculationCollectionEntity5Id' INTEGER NOT NULL, -- Represents the wave height factorized signaling norm
	'HydraulicLocationCalculationCollectionEntity6Id' INTEGER NOT NULL, -- Represents the wave height signaling norm
	'HydraulicLocationCalculationCollectionEntity7Id' INTEGER NOT NULL, -- Represents the wave height lower limit norm
	'HydraulicLocationCalculationCollectionEntity8Id' INTEGER NOT NULL, -- Represents the wave height factorized lower limit norm
	'Id' TEXT,
	'Name' VARCHAR (260),
	'Comments' TEXT,
	'LowerLimitNorm' REAL NOT NULL,
	'SignalingNorm' REAL NOT NULL,
	'NormativeNormType' TINYINT (1) NOT NULL, -- EnumType: 1 = LowerLimit, 2 = Signaling
	'Composition' TINYINT (1) NOT NULL, -- Enum: 1 = Dike, 2 = Dune, 3 = DikeAndDune
	'ReferenceLinePointXml' TEXT,
	'Order' INT (4) NOT NULL,
	CONSTRAINT 'FK_AssessmentSectionEntity_HydraulicLocationCalculationCollectionEntity1' FOREIGN KEY ('HydraulicLocationCalculationCollectionEntity1Id') REFERENCES 'HydraulicLocationCalculationCollectionEntity' ('HydraulicLocationCalculationCollectionEntityId') ON DELETE No Action ON UPDATE Cascade,
	CONSTRAINT 'FK_AssessmentSectionEntity_HydraulicLocationCalculationCollectionEntity2' FOREIGN KEY ('HydraulicLocationCalculationCollectionEntity2Id') REFERENCES 'HydraulicLocationCalculationCollectionEntity' ('HydraulicLocationCalculationCollectionEntityId') ON DELETE No Action ON UPDATE Cascade,
	CONSTRAINT 'FK_AssessmentSectionEntity_HydraulicLocationCalculationCollectionEntity3' FOREIGN KEY ('HydraulicLocationCalculationCollectionEntity3Id') REFERENCES 'HydraulicLocationCalculationCollectionEntity' ('HydraulicLocationCalculationCollectionEntityId') ON DELETE No Action ON UPDATE Cascade,
	CONSTRAINT 'FK_AssessmentSectionEntity_HydraulicLocationCalculationCollectionEntity4' FOREIGN KEY ('HydraulicLocationCalculationCollectionEntity4Id') REFERENCES 'HydraulicLocationCalculationCollectionEntity' ('HydraulicLocationCalculationCollectionEntityId') ON DELETE No Action ON UPDATE Cascade,
	CONSTRAINT 'FK_AssessmentSectionEntity_HydraulicLocationCalculationCollectionEntity5' FOREIGN KEY ('HydraulicLocationCalculationCollectionEntity5Id') REFERENCES 'HydraulicLocationCalculationCollectionEntity' ('HydraulicLocationCalculationCollectionEntityId') ON DELETE No Action ON UPDATE Cascade,
	CONSTRAINT 'FK_AssessmentSectionEntity_HydraulicLocationCalculationCollectionEntity6' FOREIGN KEY ('HydraulicLocationCalculationCollectionEntity6Id') REFERENCES 'HydraulicLocationCalculationCollectionEntity' ('HydraulicLocationCalculationCollectionEntityId') ON DELETE No Action ON UPDATE Cascade,
	CONSTRAINT 'FK_AssessmentSectionEntity_HydraulicLocationCalculationCollectionEntity7' FOREIGN KEY ('HydraulicLocationCalculationCollectionEntity7Id') REFERENCES 'HydraulicLocationCalculationCollectionEntity' ('HydraulicLocationCalculationCollectionEntityId') ON DELETE No Action ON UPDATE Cascade,
	CONSTRAINT 'FK_AssessmentSectionEntity_HydraulicLocationCalculationCollectionEntity8' FOREIGN KEY ('HydraulicLocationCalculationCollectionEntity8Id') REFERENCES 'HydraulicLocationCalculationCollectionEntity' ('HydraulicLocationCalculationCollectionEntityId') ON DELETE No Action ON UPDATE Cascade,
	CONSTRAINT 'FK_AssessmentSectionEntity_ProjectEntity' FOREIGN KEY ('ProjectEntityId') REFERENCES 'ProjectEntity' ('ProjectEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'U_HydraulicLocationCalculationCollectionEntity1Id' UNIQUE ('HydraulicLocationCalculationCollectionEntity1Id'),
	CONSTRAINT 'U_HydraulicLocationCalculationCollectionEntity2Id' UNIQUE ('HydraulicLocationCalculationCollectionEntity2Id'),
	CONSTRAINT 'U_HydraulicLocationCalculationCollectionEntity3Id' UNIQUE ('HydraulicLocationCalculationCollectionEntity3Id'),
	CONSTRAINT 'U_HydraulicLocationCalculationCollectionEntity4Id' UNIQUE ('HydraulicLocationCalculationCollectionEntity4Id'),
	CONSTRAINT 'U_HydraulicLocationCalculationCollectionEntity5Id' UNIQUE ('HydraulicLocationCalculationCollectionEntity5Id'),
	CONSTRAINT 'U_HydraulicLocationCalculationCollectionEntity6Id' UNIQUE ('HydraulicLocationCalculationCollectionEntity6Id'),
	CONSTRAINT 'U_HydraulicLocationCalculationCollectionEntity7Id' UNIQUE ('HydraulicLocationCalculationCollectionEntity7Id'),
	CONSTRAINT 'U_HydraulicLocationCalculationCollectionEntity8Id' UNIQUE ('HydraulicLocationCalculationCollectionEntity8Id')
)
;

CREATE TABLE 'MacroStabilityOutwardsFailureMechanismMetaEntity'
(
	'MacroStabilityOutwardsFailureMechanismMetaEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismEntityId' INTEGER NOT NULL,
	'A' REAL NOT NULL,
	CONSTRAINT 'FK_MacroStabilityOutwardsFailureMechanismMetaEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'FailureMechanismSectionEntity'
(
	'FailureMechanismSectionEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismEntityId' INTEGER NOT NULL,
	'Name' VARCHAR (260) NOT NULL,
	'FailureMechanismSectionPointXml' TEXT NOT NULL,
	CONSTRAINT 'FK_FailureMechanismSectionEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'FailureMechanismEntity'
(
	'FailureMechanismEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'AssessmentSectionEntityId' INTEGER NOT NULL,
	'CalculationGroupEntityId' INTEGER,
	'FailureMechanismType' SMALLINT NOT NULL, -- Enum: 1 = Piping, 2 = Macrostabiliteit binnenwaarts, 3= Golfklappen op asfaltbekleding, 4= Grasbekleding erosie buitentalud, 5 = Grasbekleding afschuiven buitentalud, 6 = Grasbekleding erosie kruin en binnentalud, 7 = Stabiliteit steenzetting, 8 = Duinafslag, 9 = Hoogte kunstwerk, 10 = Betrouwbaarheid sluiten kunstwerk, 11 = Piping bij kunstwerk, 12 = Sterkte en stabiliteit puntconstructires, 13 = Macrostabiliteit buitenwaarts, 14 = Microstabiliteit, 15 = Wateroverdruk bij asfaltbekleding, 16 = Grasbekleding afschuiven binnentalud, 17 = Sterkte en stabiliteit langsconstructires, 18 = Technische innovaties
	'IsRelevant' TINYINT (1) NOT NULL, -- true or false
	'FailureMechanismSectionCollectionSourcePath' TEXT,
	'InputComments' TEXT,
	'OutputComments' TEXT,
	'NotRelevantComments' TEXT,
	CONSTRAINT 'FK_FailureMechanismEntity_AssessmentSectionEntity' FOREIGN KEY ('AssessmentSectionEntityId') REFERENCES 'AssessmentSectionEntity' ('AssessmentSectionEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'FK_FailureMechanismEntity_CalculationGroupEntity' FOREIGN KEY ('CalculationGroupEntityId') REFERENCES 'CalculationGroupEntity' ('CalculationGroupEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'UI_AssessmentSectionEntityId_FailureMechanismType' UNIQUE ('AssessmentSectionEntityId','FailureMechanismType')
)
;

CREATE TABLE 'StabilityPointStructuresCalculationEntity'
(
	'StabilityPointStructuresCalculationEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'CalculationGroupEntityId' INTEGER NOT NULL,
	'ForeshoreProfileEntityId' INTEGER,
	'HydraulicLocationEntityId' INTEGER,
	'StabilityPointStructureEntityId' INTEGER,
	'Order' INT (4) NOT NULL,
	'Name' VARCHAR (260),
	'Comments' TEXT,
	'UseBreakWater' TINYINT (1) NOT NULL, -- true or false
	'BreakWaterType' TINYINT (1) NOT NULL, -- Enum: 1 = Wall, 2 = Caisson, 3 = Dam
	'BreakWaterHeight' REAL,
	'UseForeshore' TINYINT (1) NOT NULL, -- true or false
	'StructureNormalOrientation' REAL,
	'StorageStructureAreaMean' REAL,
	'StorageStructureAreaCoefficientOfVariation' REAL,
	'AllowedLevelIncreaseStorageMean' REAL,
	'AllowedLevelIncreaseStorageStandardDeviation' REAL,
	'WidthFlowAperturesMean' REAL,
	'WidthFlowAperturesStandardDeviation' REAL,
	'InsideWaterLevelMean' REAL,
	'InsideWaterLevelStandardDeviation' REAL,
	'ThresholdHeightOpenWeirMean' REAL,
	'ThresholdHeightOpenWeirStandardDeviation' REAL,
	'CriticalOvertoppingDischargeMean' REAL,
	'CriticalOvertoppingDischargeCoefficientOfVariation' REAL,
	'FlowWidthAtBottomProtectionMean' REAL,
	'FlowWidthAtBottomProtectionStandardDeviation' REAL,
	'ConstructiveStrengthLinearLoadModelMean' REAL,
	'ConstructiveStrengthLinearLoadModelCoefficientOfVariation' REAL,
	'ConstructiveStrengthQuadraticLoadModelMean' REAL,
	'ConstructiveStrengthQuadraticLoadModelCoefficientOfVariation' REAL,
	'BankWidthMean' REAL,
	'BankWidthStandardDeviation' REAL,
	'InsideWaterLevelFailureConstructionMean' REAL,
	'InsideWaterLevelFailureConstructionStandardDeviation' REAL,
	'EvaluationLevel' REAL,
	'LevelCrestStructureMean' REAL,
	'LevelCrestStructureStandardDeviation' REAL,
	'VerticalDistance' REAL,
	'FailureProbabilityRepairClosure' REAL NOT NULL,
	'FailureCollisionEnergyMean' REAL,
	'FailureCollisionEnergyCoefficientOfVariation' REAL,
	'ShipMassMean' REAL,
	'ShipMassCoefficientOfVariation' REAL,
	'ShipVelocityMean' REAL,
	'ShipVelocityCoefficientOfVariation' REAL,
	'LevellingCount' INT (4) NOT NULL,
	'ProbabilityCollisionSecondaryStructure' REAL NOT NULL,
	'FlowVelocityStructureClosableMean' REAL,
	'StabilityLinearLoadModelMean' REAL,
	'StabilityLinearLoadModelCoefficientOfVariation' REAL,
	'StabilityQuadraticLoadModelMean' REAL,
	'StabilityQuadraticLoadModelCoefficientOfVariation' REAL,
	'AreaFlowAperturesMean' REAL,
	'AreaFlowAperturesStandardDeviation' REAL,
	'InflowModelType' TINYINT (1) NOT NULL, -- Enum: 1 = VerticalWall, 2 = LowSill, 3 = FloodedCulvert
	'LoadSchematizationType' TINYINT (1) NOT NULL, -- Enum: 1 = Linear, 2 = Quadratic
	'VolumicWeightWater' REAL,
	'StormDurationMean' REAL,
	'FactorStormDurationOpenStructure' REAL,
	'DrainCoefficientMean' REAL,
	'FailureProbabilityStructureWithErosion' REAL NOT NULL,
	'ShouldIllustrationPointsBeCalculated' TINYINT (1) NOT NULL, -- true or false
	CONSTRAINT 'FK_StabilityPointStructuresCalculationEntity_CalculationGroupEntity' FOREIGN KEY ('CalculationGroupEntityId') REFERENCES 'CalculationGroupEntity' ('CalculationGroupEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'FK_StabilityPointStructuresCalculationEntity_ForeshoreProfileEntity' FOREIGN KEY ('ForeshoreProfileEntityId') REFERENCES 'ForeshoreProfileEntity' ('ForeshoreProfileEntityId') ON DELETE Set Null ON UPDATE Cascade,
	CONSTRAINT 'FK_StabilityPointStructuresCalculationEntity_HydraulicLocationEntity' FOREIGN KEY ('HydraulicLocationEntityId') REFERENCES 'HydraulicLocationEntity' ('HydraulicLocationEntityId') ON DELETE Set Null ON UPDATE Cascade,
	CONSTRAINT 'FK_StabilityPointStructuresCalculationEntity_StabilityPointStructureEntity' FOREIGN KEY ('StabilityPointStructureEntityId') REFERENCES 'StabilityPointStructureEntity' ('StabilityPointStructureEntityId') ON DELETE Set Null ON UPDATE Cascade
)
;

CREATE TABLE 'ClosingStructuresFailureMechanismMetaEntity'
(
	'ClosingStructuresFailureMechanismMetaEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismEntityId' INTEGER NOT NULL,
	'N2A' INT (4) NOT NULL,
	'ClosingStructureCollectionSourcePath' TEXT,
	'ForeshoreProfileCollectionSourcePath' TEXT,
	CONSTRAINT 'FK_ClosingStructuresFailureMechanismMetaEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'PipingFailureMechanismMetaEntity'
(
	'PipingFailureMechanismMetaEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismEntityId' INTEGER NOT NULL,
	'A' REAL NOT NULL,
	'WaterVolumetricWeight' REAL NOT NULL,
	'StochasticSoilModelCollectionSourcePath' TEXT,
	'SurfaceLineCollectionSourcePath' TEXT,
	CONSTRAINT 'FK_PipingFailureMechanismMetaEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'StabilityStoneCoverFailureMechanismMetaEntity'
(
	'StabilityStoneCoverFailureMechanismMetaEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismEntityId' INTEGER NOT NULL,
	'ForeshoreProfileCollectionSourcePath' TEXT,
	'N' REAL NOT NULL,
	CONSTRAINT 'FK_StabilityStoneCoverFailureMechanismMetaEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'CalculationGroupEntity'
(
	'CalculationGroupEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'ParentCalculationGroupEntityId' INTEGER,
	'Name' VARCHAR (260),
	'Order' INT (4) NOT NULL,
	CONSTRAINT 'FK_CalculationGroupEntity_CalculationGroupEntity' FOREIGN KEY ('ParentCalculationGroupEntityId') REFERENCES 'CalculationGroupEntity' ('CalculationGroupEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'HydraulicLocationEntity'
(
	'HydraulicLocationEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'AssessmentSectionEntityId' INTEGER NOT NULL,
	'LocationId' INTEGER NOT NULL,
	'Name' VARCHAR (260) NOT NULL,
	'LocationX' REAL,
	'LocationY' REAL,
	'Order' INT (4) NOT NULL,
	CONSTRAINT 'FK_HydraulicLocationEntity_AssessmentSectionEntity' FOREIGN KEY ('AssessmentSectionEntityId') REFERENCES 'AssessmentSectionEntity' ('AssessmentSectionEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'PipingCalculationEntity'
(
	'PipingCalculationEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'CalculationGroupEntityId' INTEGER NOT NULL,
	'SurfaceLineEntityId' INTEGER,
	'PipingStochasticSoilProfileEntityId' INTEGER,
	'HydraulicLocationEntityId' INTEGER,
	'Order' INT (4) NOT NULL,
	'Name' VARCHAR (260),
	'Comments' TEXT,
	'EntryPointL' REAL,
	'ExitPointL' REAL,
	'PhreaticLevelExitMean' REAL,
	'PhreaticLevelExitStandardDeviation' REAL,
	'DampingFactorExitMean' REAL,
	'DampingFactorExitStandardDeviation' REAL,
	'RelevantForScenario' TINYINT (1) NOT NULL, -- true or false
	'ScenarioContribution' REAL,
	'AssessmentLevel' REAL,
	'UseAssessmentLevelManualInput' TINYINT (1) NOT NULL, -- true or false
	CONSTRAINT 'FK_PipingCalculationEntity_CalculationGroupEntity' FOREIGN KEY ('CalculationGroupEntityId') REFERENCES 'CalculationGroupEntity' ('CalculationGroupEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'FK_PipingCalculationEntity_HydraulicLocationEntity' FOREIGN KEY ('HydraulicLocationEntityId') REFERENCES 'HydraulicLocationEntity' ('HydraulicLocationEntityId') ON DELETE Set Null ON UPDATE Cascade,
	CONSTRAINT 'FK_PipingCalculationEntity_PipingStochasticSoilProfileEntity' FOREIGN KEY ('PipingStochasticSoilProfileEntityId') REFERENCES 'PipingStochasticSoilProfileEntity' ('PipingStochasticSoilProfileEntityId') ON DELETE Set Null ON UPDATE Cascade,
	CONSTRAINT 'FK_PipingCalculationEntity_SurfaceLineEntity' FOREIGN KEY ('SurfaceLineEntityId') REFERENCES 'SurfaceLineEntity' ('SurfaceLineEntityId') ON DELETE Set Null ON UPDATE Cascade
)
;

CREATE TABLE 'GrassCoverErosionInwardsFailureMechanismMetaEntity'
(
	'GrassCoverErosionInwardsFailureMechanismMetaEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismEntityId' INTEGER NOT NULL,
	'N' REAL NOT NULL,
	'DikeProfileCollectionSourcePath' TEXT,
	CONSTRAINT 'FK_GrassCoverErosionInwardsFailureMechanismMetaEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'StabilityPointStructuresFailureMechanismMetaEntity'
(
	'StabilityPointStructuresFailureMechanismMetaEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismEntityId' INTEGER NOT NULL,
	'N' REAL NOT NULL,
	'ForeshoreProfileCollectionSourcePath' TEXT,
	'StabilityPointStructureCollectionSourcePath' TEXT,
	CONSTRAINT 'FK_StrengthStabilityPointConstructionFailureMechanismMetaEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'GrassCoverErosionInwardsCalculationEntity'
(
	'GrassCoverErosionInwardsCalculationEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'CalculationGroupEntityId' INTEGER NOT NULL,
	'HydraulicLocationEntityId' INTEGER,
	'DikeProfileEntityId' INTEGER,
	'Order' INT (4) NOT NULL,
	'Name' VARCHAR (260),
	'Comments' TEXT,
	'Orientation' REAL,
	'CriticalFlowRateMean' REAL,
	'CriticalFlowRateStandardDeviation' REAL,
	'UseForeshore' TINYINT (1) NOT NULL, -- true or false
	'DikeHeightCalculationType' TINYINT (1) NOT NULL, -- Enum: 1 = NoCalculation, 2 = CalculateByAssessmentSectionNorm, 3 = CalculateByProfileSpecificRequiredProbability
	'DikeHeight' REAL,
	'UseBreakWater' TINYINT (1) NOT NULL, -- true or false
	'BreakWaterType' TINYINT (1) NOT NULL, -- Enum: 1 = Wall, 2 = Caisson, 3 = Dam
	'BreakWaterHeight' REAL,
	'OvertoppingRateCalculationType' TINYINT (1) NOT NULL, -- Enum: 1 = NoCalculation, 2 = CalculateByAssessmentSectionNorm, 3 = CalculateByProfileSpecificRequiredProbability
	'ShouldDikeHeightIllustrationPointsBeCalculated' TINYINT (1) NOT NULL, -- true or false
	'ShouldOvertoppingRateIllustrationPointsBeCalculated' TINYINT (1) NOT NULL, -- true or false
	'ShouldOvertoppingOutputIllustrationPointsBeCalculated' TINYINT (1) NOT NULL, -- true or false
	CONSTRAINT 'FK_GrassCoverErosionInwardsCalculationEntity_CalculationGroupEntity' FOREIGN KEY ('CalculationGroupEntityId') REFERENCES 'CalculationGroupEntity' ('CalculationGroupEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'FK_GrassCoverErosionInwardsCalculationEntity_DikeProfileEntity' FOREIGN KEY ('DikeProfileEntityId') REFERENCES 'DikeProfileEntity' ('DikeProfileEntityId') ON DELETE Set Null ON UPDATE Cascade,
	CONSTRAINT 'FK_GrassCoverErosionInwardsCalculationEntity_HydraulicLocationEntity' FOREIGN KEY ('HydraulicLocationEntityId') REFERENCES 'HydraulicLocationEntity' ('HydraulicLocationEntityId') ON DELETE Set Null ON UPDATE Cascade
)
;

CREATE TABLE 'DuneErosionFailureMechanismMetaEntity'
(
	'DuneErosionFailureMechanismMetaEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismEntityId' INTEGER NOT NULL,
	'DuneLocationCalculationCollectionEntity1Id' INTEGER NOT NULL, -- Represents the calculations for the failure mechanism specific factorized signaling norm
	'DuneLocationCalculationCollectionEntity2Id' INTEGER NOT NULL, -- Represents the calculations for the failure mechanism specific signaling norm
	'DuneLocationCalculationCollectionEntity3Id' INTEGER NOT NULL, -- Represents the calculations for the failure mechanism specific lower limit norm
	'DuneLocationCalculationCollectionEntity4Id' INTEGER NOT NULL, -- Represents the calculations for the lower limit norm
	'DuneLocationCalculationCollectionEntity5Id' INTEGER NOT NULL, -- Represents the calculations for the factorized lower limit norm
	'N' REAL NOT NULL,
	CONSTRAINT 'FK_DuneErosionFailureMechanismMetaEntity_DuneLocationCalculationCollectionEntity1' FOREIGN KEY ('DuneLocationCalculationCollectionEntity1Id') REFERENCES 'DuneLocationCalculationCollectionEntity' ('DuneLocationCalculationCollectionEntityId') ON DELETE No Action ON UPDATE Cascade,
	CONSTRAINT 'FK_DuneErosionFailureMechanismMetaEntity_DuneLocationCalculationCollectionEntity2' FOREIGN KEY ('DuneLocationCalculationCollectionEntity2Id') REFERENCES 'DuneLocationCalculationCollectionEntity' ('DuneLocationCalculationCollectionEntityId') ON DELETE No Action ON UPDATE Cascade,
	CONSTRAINT 'FK_DuneErosionFailureMechanismMetaEntity_DuneLocationCalculationCollectionEntity3' FOREIGN KEY ('DuneLocationCalculationCollectionEntity3Id') REFERENCES 'DuneLocationCalculationCollectionEntity' ('DuneLocationCalculationCollectionEntityId') ON DELETE No Action ON UPDATE Cascade,
	CONSTRAINT 'FK_DuneErosionFailureMechanismMetaEntity_DuneLocationCalculationCollectionEntity4' FOREIGN KEY ('DuneLocationCalculationCollectionEntity4Id') REFERENCES 'DuneLocationCalculationCollectionEntity' ('DuneLocationCalculationCollectionEntityId') ON DELETE No Action ON UPDATE Cascade,
	CONSTRAINT 'FK_DuneErosionFailureMechanismMetaEntity_DuneLocationCalculationCollectionEntity5' FOREIGN KEY ('DuneLocationCalculationCollectionEntity5Id') REFERENCES 'DuneLocationCalculationCollectionEntity' ('DuneLocationCalculationCollectionEntityId') ON DELETE No Action ON UPDATE Cascade,
	CONSTRAINT 'FK_DuneErosionFailureMechanismMetaEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'GrassCoverErosionOutwardsFailureMechanismMetaEntity'
(
	'GrassCoverErosionOutwardsFailureMechanismMetaEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismEntityId' INTEGER NOT NULL,
	'HydraulicLocationCalculationCollectionEntity1Id' INTEGER NOT NULL, -- Represents the design water level failure mechanism specific factorized signaling norm
	'HydraulicLocationCalculationCollectionEntity2Id' INTEGER NOT NULL, -- Represents the design water level failure mechanism specific signaling norm
	'HydraulicLocationCalculationCollectionEntity3Id' INTEGER NOT NULL, -- Represents the design water level failure mechanism specific lower limit norm
	'HydraulicLocationCalculationCollectionEntity4Id' INTEGER NOT NULL, -- Represents the wave height failure mechanism specific factorized signaling norm
	'HydraulicLocationCalculationCollectionEntity5Id' INTEGER NOT NULL, -- Represents the wave height failure mechanism specific signaling norm
	'HydraulicLocationCalculationCollectionEntity6Id' INTEGER NOT NULL, -- Represents the wave height failure mechanism specific lower limit norm
	'N' REAL NOT NULL,
	'ForeshoreProfileCollectionSourcePath' TEXT,
	CONSTRAINT 'FK_GrassCoverErosionOutwardsFailureMechanismMetaEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'FK_GrassCoverErosionOutwardsFailureMechanismMetaEntity_HydraulicLocationCalculationCollectionEntity1' FOREIGN KEY ('HydraulicLocationCalculationCollectionEntity1Id') REFERENCES 'HydraulicLocationCalculationCollectionEntity' ('HydraulicLocationCalculationCollectionEntityId') ON DELETE No Action ON UPDATE Cascade,
	CONSTRAINT 'FK_GrassCoverErosionOutwardsFailureMechanismMetaEntity_HydraulicLocationCalculationCollectionEntity2' FOREIGN KEY ('HydraulicLocationCalculationCollectionEntity2Id') REFERENCES 'HydraulicLocationCalculationCollectionEntity' ('HydraulicLocationCalculationCollectionEntityId') ON DELETE No Action ON UPDATE Cascade,
	CONSTRAINT 'FK_GrassCoverErosionOutwardsFailureMechanismMetaEntity_HydraulicLocationCalculationCollectionEntity3' FOREIGN KEY ('HydraulicLocationCalculationCollectionEntity3Id') REFERENCES 'HydraulicLocationCalculationCollectionEntity' ('HydraulicLocationCalculationCollectionEntityId') ON DELETE No Action ON UPDATE Cascade,
	CONSTRAINT 'FK_GrassCoverErosionOutwardsFailureMechanismMetaEntity_HydraulicLocationCalculationCollectionEntity4' FOREIGN KEY ('HydraulicLocationCalculationCollectionEntity4Id') REFERENCES 'HydraulicLocationCalculationCollectionEntity' ('HydraulicLocationCalculationCollectionEntityId') ON DELETE No Action ON UPDATE Cascade,
	CONSTRAINT 'FK_GrassCoverErosionOutwardsFailureMechanismMetaEntity_HydraulicLocationCalculationCollectionEntity5' FOREIGN KEY ('HydraulicLocationCalculationCollectionEntity5Id') REFERENCES 'HydraulicLocationCalculationCollectionEntity' ('HydraulicLocationCalculationCollectionEntityId') ON DELETE No Action ON UPDATE Cascade,
	CONSTRAINT 'FK_GrassCoverErosionOutwardsFailureMechanismMetaEntity_HydraulicLocationCalculationCollectionEntity6' FOREIGN KEY ('HydraulicLocationCalculationCollectionEntity6Id') REFERENCES 'HydraulicLocationCalculationCollectionEntity' ('HydraulicLocationCalculationCollectionEntityId') ON DELETE No Action ON UPDATE Cascade,
	CONSTRAINT 'U_HydraulicLocationCalculationCollectionEntity1Id' UNIQUE ('HydraulicLocationCalculationCollectionEntity1Id'),
	CONSTRAINT 'U_HydraulicLocationCalculationCollectionEntity2Id' UNIQUE ('HydraulicLocationCalculationCollectionEntity2Id'),
	CONSTRAINT 'U_HydraulicLocationCalculationCollectionEntity3Id' UNIQUE ('HydraulicLocationCalculationCollectionEntity3Id'),
	CONSTRAINT 'U_HydraulicLocationCalculationCollectionEntity4Id' UNIQUE ('HydraulicLocationCalculationCollectionEntity4Id'),
	CONSTRAINT 'U_HydraulicLocationCalculationCollectionEntity5Id' UNIQUE ('HydraulicLocationCalculationCollectionEntity5Id'),
	CONSTRAINT 'U_HydraulicLocationCalculationCollectionEntity6Id' UNIQUE ('HydraulicLocationCalculationCollectionEntity6Id')
)
;

CREATE TABLE 'PipingSoilLayerEntity'
(
	'PipingSoilLayerEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'PipingSoilProfileEntityId' INTEGER NOT NULL,
	'Top' REAL,
	'IsAquifer' TINYINT (1) NOT NULL, -- true or false
	'Color' INTEGER, -- ARGB value of Color.
	'MaterialName' TEXT NOT NULL,
	'BelowPhreaticLevelMean' REAL,
	'BelowPhreaticLevelDeviation' REAL,
	'BelowPhreaticLevelShift' REAL,
	'DiameterD70Mean' REAL,
	'DiameterD70CoefficientOfVariation' REAL,
	'PermeabilityMean' REAL,
	'PermeabilityCoefficientOfVariation' REAL,
	'Order' INT (4) NOT NULL,
	CONSTRAINT 'FK_PipingSoilLayerEntity_SoilProfileEntity' FOREIGN KEY ('PipingSoilProfileEntityId') REFERENCES 'PipingSoilProfileEntity' ('PipingSoilProfileEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'HeightStructuresFailureMechanismMetaEntity'
(
	'HeightStructuresFailureMechanismMetaEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismEntityId' INTEGER NOT NULL,
	'N' REAL NOT NULL,
	'HeightStructureCollectionSourcePath' TEXT,
	'ForeshoreProfileCollectionSourcePath' TEXT,
	CONSTRAINT 'FK_HeightStructuresFailureMechanismMetaEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'PipingSoilProfileEntity'
(
	'PipingSoilProfileEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'Bottom' REAL,
	'Name' TEXT NOT NULL,
	'SourceType' TINYINT (1) NOT NULL -- Enum: 1 = SoilProfile1D,  2 = SoilProfile2D
)
;

CREATE TABLE 'PipingStochasticSoilProfileEntity'
(
	'PipingStochasticSoilProfileEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'PipingSoilProfileEntityId' INTEGER NOT NULL,
	'StochasticSoilModelEntityId' INTEGER NOT NULL,
	'Probability' REAL NOT NULL,
	'Order' INT (4) NOT NULL,
	CONSTRAINT 'FK_PipingStochasticSoilProfileEntity_SoilProfileEntity' FOREIGN KEY ('PipingSoilProfileEntityId') REFERENCES 'PipingSoilProfileEntity' ('PipingSoilProfileEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'FK_PipingStochasticSoilProfileEntity_StochasticSoilModelEntity' FOREIGN KEY ('StochasticSoilModelEntityId') REFERENCES 'StochasticSoilModelEntity' ('StochasticSoilModelEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'StochasticSoilModelEntity'
(
	'StochasticSoilModelEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismEntityId' INTEGER NOT NULL,
	'Name' TEXT NOT NULL,
	'StochasticSoilModelSegmentPointXml' TEXT NOT NULL,
	'Order' INT (4) NOT NULL,
	CONSTRAINT 'FK_StochasticSoilModelEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'UQ_StochasticSoilModelEntity_NameFailureMechanismEntityId' UNIQUE ('Name','FailureMechanismEntityId')
)
;

CREATE TABLE 'SurfaceLineEntity'
(
	'SurfaceLineEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismEntityId' INTEGER NOT NULL,
	'Name' VARCHAR (260) NOT NULL,
	'ReferenceLineIntersectionX' REAL,
	'ReferenceLineIntersectionY' REAL,
	'PointsXml' TEXT NOT NULL,
	'Order' INT (4) NOT NULL,
	CONSTRAINT 'FK_SurfaceLineEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'UQ_SurfaceLineEntity_NameFailureMechanismEntityId' UNIQUE ('Name','FailureMechanismEntityId')
)
;

CREATE TABLE 'PipingCharacteristicPointEntity'
(
	'PipingCharacteristicPointEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'SurfaceLineEntityId' INTEGER NOT NULL,
	'Type' TINYINT (1) NOT NULL, -- Enum: 1 = DikeToeAtRiver, 2 = DikeToeAtPolder, 3 = DitchDikeSide, 4 = BottomDitchDikeSide, 5 = BottomDitchPolderSide, 6 = DitchPolderSide
	'X' REAL,
	'Y' REAL,
	'Z' REAL,
	CONSTRAINT 'FK_SurfaceLinePointEntity_SurfaceLineEntity' FOREIGN KEY ('SurfaceLineEntityId') REFERENCES 'SurfaceLineEntity' ('SurfaceLineEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'PipingCalculationOutputEntity'
(
	'PipingCalculationOutputEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'PipingCalculationEntityId' INTEGER NOT NULL,
	'Order' INT (4) NOT NULL,
	'HeaveFactorOfSafety' REAL,
	'HeaveZValue' REAL,
	'UpliftFactorOfSafety' REAL,
	'UpliftZValue' REAL,
	'SellmeijerFactorOfSafety' REAL,
	'SellmeijerZValue' REAL,
	'UpliftEffectiveStress' REAL,
	'HeaveGradient' REAL,
	'SellmeijerCreepCoefficient' REAL,
	'SellmeijerCriticalFall' REAL,
	'SellmeijerReducedFall' REAL,
	CONSTRAINT 'FK_PipingCalculationOutputEntity_PipingCalculationEntity' FOREIGN KEY ('PipingCalculationEntityId') REFERENCES 'PipingCalculationEntity' ('PipingCalculationEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'U_PipingCalculationEntity' UNIQUE ('PipingCalculationEntityId')
)
;

CREATE TABLE 'PipingStructureFailureMechanismMetaEntity'
(
	'PipingStructureFailureMechanismMetaEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismEntityId' INTEGER NOT NULL,
	'N' REAL NOT NULL,
	CONSTRAINT 'FK_PipingStructureFailureMechanismMetaEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'PipingSectionResultEntity'
(
	'PipingSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismSectionEntityId' INTEGER NOT NULL,
	'SimpleAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = NotApplicable, 3 = ProbabilityNegligible, 4 = AssessFurther
	'DetailedAssessmentResult' TINYINT (1) NOT NULL, -- Enum:  1 = Probability, 2 = NotAssessed
	'TailorMadeAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = ProbabilityNegligible, 3 = Probability, 4 = NotAssessed
	'TailorMadeAssessmentProbability' REAL,
	'UseManualAssembly' TINYINT (1) NOT NULL, -- true or false
	'ManualAssemblyProbability' REAL,
	CONSTRAINT 'FK_PipingSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'GrassCoverErosionInwardsSectionResultEntity'
(
	'GrassCoverErosionInwardsSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismSectionEntityId' INTEGER NOT NULL,
	'GrassCoverErosionInwardsCalculationEntityId' INTEGER,
	'SimpleAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = NotApplicable, 3 = Applicable
	'DetailedAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = Probability, 2 = NotAssessed
	'TailorMadeAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = ProbabilityNegligible, 3 = Probability, 4 = NotAssessed
	'TailorMadeAssessmentProbability' REAL,
	'UseManualAssembly' TINYINT (1) NOT NULL, -- true or false
	'ManualAssemblyProbability' REAL,
	CONSTRAINT 'FK_GrassCoverErosionInwardsSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'FK_GrassCoverErosionInwardsSectionResultEntity_GrassCoverErosionInwardsCalculationEntity' FOREIGN KEY ('GrassCoverErosionInwardsCalculationEntityId') REFERENCES 'GrassCoverErosionInwardsCalculationEntity' ('GrassCoverErosionInwardsCalculationEntityId') ON DELETE Set Null ON UPDATE Cascade
)
;

CREATE TABLE 'HeightStructuresSectionResultEntity'
(
	'HeightStructuresSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismSectionEntityId' INTEGER NOT NULL,
	'HeightStructuresCalculationEntityId' INTEGER,
	'SimpleAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = NotApplicable, 3 = ProbabilityNegligible 4 = AssessFurther
	'DetailedAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = Probability 2 = NotAssessed
	'TailorMadeAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None 2 = ProbabilityNegligible 3 = Probability 4 = NotAssessed
	'TailorMadeAssessmentProbability' REAL,
	'UseManualAssembly' TINYINT (1) NOT NULL, -- true or false
	'ManualAssemblyProbability' REAL,
	CONSTRAINT 'FK_HeightStructuresSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'FK_HeightStructuresSectionResultEntity_HeightStructuresCalculationEntity' FOREIGN KEY ('HeightStructuresCalculationEntityId') REFERENCES 'HeightStructuresCalculationEntity' ('HeightStructuresCalculationEntityId') ON DELETE Set Null ON UPDATE Cascade
)
;

CREATE TABLE 'StrengthStabilityLengthwiseConstructionSectionResultEntity'
(
	'StrengthStabilityLengthwiseConstructionSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismSectionEntityId' INTEGER NOT NULL,
	'SimpleAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = NotApplicable, 3 = ProbabilityNegligible, 4 = AssessFurther
	'TailorMadeAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = ProbabilityNegligible, 3 = Sufficient, 4 = Insufficient, 5 = NotAssessed
	'UseManualAssembly' TINYINT (1) NOT NULL, -- true or false
	'ManualAssemblyCategoryGroup' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = NotApplicable, 3 = Iv, 4 = IIv, 5 = Vv, 6 = VIIv   
	CONSTRAINT 'FK_StrengthStabilityLengthwiseConstructionSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'TechnicalInnovationSectionResultEntity'
(
	'TechnicalInnovationSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismSectionEntityId' INTEGER NOT NULL,
	'SimpleAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = NotApplicable, 3 = ProbabilityNegligible, 4 = AssessFurther
	'TailorMadeAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = ProbabilityNegligible, 3 = Sufficient, 4 = Insufficient, 5 = NotAssessed
	'UseManualAssembly' TINYINT (1) NOT NULL, -- true or false
	'ManualAssemblyCategoryGroup' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = NotApplicable, 3 = Iv, 4 = IIv, 5 = Vv, 6 = VIIv 
	CONSTRAINT 'FK_TechnicalInnovationSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'WaterPressureAsphaltCoverSectionResultEntity'
(
	'WaterPressureAsphaltCoverSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismSectionEntityId' INTEGER NOT NULL,
	'SimpleAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = NotApplicable, 3 = ProbabilityNegligible, 4 = AssessFurther
	'TailorMadeAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = ProbabilityNegligible, 3 = Sufficient, 4 = Insufficient, 5 = NotAssessed
	'UseManualAssembly' TINYINT (1) NOT NULL, -- true or false
	'ManualAssemblyCategoryGroup' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = NotApplicable, 3 = Iv, 4 = IIv, 5 = Vv, 6 = VIIv  
	CONSTRAINT 'FK_WaterPressureAsphaltCoverSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'ClosingStructuresSectionResultEntity'
(
	'ClosingStructuresSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismSectionEntityId' INTEGER NOT NULL,
	'ClosingStructuresCalculationEntityId' INTEGER,
	'SimpleAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = NotApplicable, 3 = ProbabilityNegligible, 4 = AssessFurther
	'DetailedAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = Probability, 2 = NotAssessed
	'TailorMadeAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = ProbabilityNegligible, 3 = Probability, 4 = NotAssessed
	'TailorMadeAssessmentProbability' REAL,
	'UseManualAssembly' TINYINT (1) NOT NULL, -- true or false
	'ManualAssemblyProbability' REAL,
	CONSTRAINT 'FK_ClosingStructuresSectionResultEntity_ClosingStructuresCalculationEntity' FOREIGN KEY ('ClosingStructuresCalculationEntityId') REFERENCES 'ClosingStructuresCalculationEntity' ('ClosingStructuresCalculationEntityId') ON DELETE Set Null ON UPDATE Cascade,
	CONSTRAINT 'FK_ClosingStructuresSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'GrassCoverErosionOutwardsSectionResultEntity'
(
	'GrassCoverErosionOutwardsSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismSectionEntityId' INTEGER NOT NULL,
	'SimpleAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = NotApplicable, 3 = ProbabilityNegligible, 4 = AssessFurther
	'DetailedAssessmentResultForFactorizedSignalingNorm' TINYINT (1) NOT NULL, -- Detailed result Enum: 1 = None, 2 = Sufficient, 3 = Insufficient, 4 = NotAssessed
	'DetailedAssessmentResultForSignalingNorm' TINYINT (1) NOT NULL, -- Detailed result Enum: 1 = None, 2 = Sufficient, 3 = Insufficient, 4 = NotAssessed
	'DetailedAssessmentResultForMechanismSpecificLowerLimitNorm' TINYINT (1) NOT NULL, -- Detailed result Enum: 1 = None, 2 = Sufficient, 3 = Insufficient, 4 = NotAssessed
	'DetailedAssessmentResultForLowerLimitNorm' TINYINT (1) NOT NULL, -- Detailed result Enum: 1 = None, 2 = Sufficient, 3 = Insufficient, 4 = NotAssessed
	'DetailedAssessmentResultForFactorizedLowerLimitNorm' TINYINT (1) NOT NULL, -- Detailed result Enum: 1 = None, 2 = Sufficient, 3 = Insufficient, 4 = NotAssessed
	'TailorMadeAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = Iv, 3 = IIv, 4 = IIIv, 5 = IVv, 6 = Vv, 7 = VIv, 8 = VIIv
	'UseManualAssembly' TINYINT (1) NOT NULL, -- true or false
	'ManualAssemblyCategoryGroup' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = NotApplicable 3 = Iv, 4 = IIv, 5 = IIIv, 6 = IVv, 7 = Vv, 8 = VIv, 9 = VIIv
	CONSTRAINT 'FK_GrassCoverErosionOutwardsSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'GrassCoverSlipOffInwardsSectionResultEntity'
(
	'GrassCoverSlipOffInwardsSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismSectionEntityId' INTEGER NOT NULL,
	'SimpleAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = NotAssessed, 2 = Sufficient, 3 = NoVerdict
	'DetailedAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = Sufficient, 3 = Insufficient, 4 = NotAssessed
	'TailorMadeAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = ProbabilityNegligible, 3 = Sufficient, 4 = Insufficient, 5 = NotAssessed
	'UseManualAssembly' TINYINT (1) NOT NULL, -- true or false
	'ManualAssemblyCategoryGroup' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = NotApplicable, 3 = Iv, 4 = IIv, 5 = Vv, 6 = VIIv  
	CONSTRAINT 'FK_GrassCoverSlipOffInwardsSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'GrassCoverSlipOffOutwardsSectionResultEntity'
(
	'GrassCoverSlipOffOutwardsSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismSectionEntityId' INTEGER NOT NULL,
	'SimpleAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = NotAssessed, 2 = Sufficient, 3 = NoVerdict
	'DetailedAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = Sufficient, 3 = Insufficient, 4 = NotAssessed
	'TailorMadeAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = ProbabilityNegligible, 3 = Sufficient, 4 = Insufficient, 5 = NotAssessed
	'UseManualAssembly' TINYINT (1) NOT NULL, -- true or false
	'ManualAssemblyCategoryGroup' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = NotApplicable, 3 = Iv, 4 = IIv, 5 = Vv, 6 = VIIv 
	CONSTRAINT 'FK_GrassCoverSlipOffOutwardsSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'MacroStabilityInwardsSectionResultEntity'
(
	'MacroStabilityInwardsSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismSectionEntityId' INTEGER NOT NULL,
	'SimpleAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = NotApplicable, 3 = ProbabilityNegligible, 4 = AssessFurther
	'DetailedAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = Probability, 2 = NotAssessed
	'TailorMadeAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = ProbabilityNegligible, 3 = Probability, 4 = NotAssessed
	'TailorMadeAssessmentProbability' REAL,
	'UseManualAssembly' TINYINT (1) NOT NULL, -- true or false
	'ManualAssemblyProbability' REAL,
	CONSTRAINT 'FK_MacroStabilityInwardsSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'MacroStabilityOutwardsSectionResultEntity'
(
	'MacroStabilityOutwardsSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismSectionEntityId' INTEGER NOT NULL,
	'SimpleAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = NotApplicable, 3 = ProbabilityNegligible, 4 = AssessFurther
	'DetailedAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = Probability, 2 = NotAssessed
	'DetailedAssessmentProbability' REAL,
	'TailorMadeAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = ProbabilityNegligible, 3 = Probability, 4 = Sufficient, 5 = Insufficient, 6 = NotAssessed
	'TailorMadeAssessmentProbability' REAL,
	'UseManualAssembly' TINYINT (1) NOT NULL, -- true or false
	'ManualAssemblyCategoryGroup' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = NotApplicable, 3 = Iv, 4 = IIv, 5 = Vv, 6 = VIIv
	CONSTRAINT 'FK_MacroStabilityOutwardsSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'WaveImpactAsphaltCoverFailureMechanismMetaEntity'
(
	'WaveImpactAsphaltCoverFailureMechanismMetaEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismEntityId' INTEGER NOT NULL,
	'ForeshoreProfileCollectionSourcePath' TEXT,
	'DeltaL' REAL NOT NULL,
	CONSTRAINT 'FK_WaveImpactAsphaltCoverFailureMechanismMetaEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'WaveImpactAsphaltCoverSectionResultEntity'
(
	'WaveImpactAsphaltCoverSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismSectionEntityId' INTEGER NOT NULL,
	'SimpleAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = NotApplicable, 3 = ProbabilityNegligible, 4 = AssessFurther
	'DetailedAssessmentResultForFactorizedSignalingNorm' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = Sufficient, 3 = Insufficient, 4 = NotAssessed
	'DetailedAssessmentResultForSignalingNorm' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = Sufficient, 3 = Insufficient, 4 = NotAssessed
	'DetailedAssessmentResultForMechanismSpecificLowerLimitNorm' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = Sufficient, 3 = Insufficient, 4 = NotAssessed
	'DetailedAssessmentResultForLowerLimitNorm' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = Sufficient, 3 = Insufficient, 4 = NotAssessed
	'DetailedAssessmentResultForFactorizedLowerLimitNorm' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = Sufficient, 3 = Insufficient, 4 = NotAssessed
	'TailorMadeAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = Iv, 3 = IIv, 4 = IIIv, 5 = IVv, 6 = Vv, 7 = VIv, 8 = VIIv
	'UseManualAssembly' TINYINT (1) NOT NULL, -- true or false
	'ManualAssemblyCategoryGroup' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = NotApplicable 3 = Iv, 4 = IIv, 5 = IIIv, 6 = IVv, 7 = Vv, 8 = VIv, 9 = VIIv
	CONSTRAINT 'FK_WaveImpactAsphaltCoverSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'MicrostabilitySectionResultEntity'
(
	'MicrostabilitySectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismSectionEntityId' INTEGER NOT NULL,
	'SimpleAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = NotAssessed, 2 = Sufficient, 3 = NoVerdict
	'DetailedAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = Sufficient, 3 = Insufficient, 4 = NotAssessed
	'TailorMadeAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = ProbabilityNegligible, 3 = Sufficient, 4 = Insufficient, 5 = NotAssessed
	'UseManualAssembly' TINYINT (1) NOT NULL, -- true or false
	'ManualAssemblyCategoryGroup' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = NotApplicable, 3 = Iv, 4 = IIv, 5 = Vv, 6 = VIIv 
	CONSTRAINT 'FK_MicrostabilitySectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'PipingStructureSectionResultEntity'
(
	'PipingStructureSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismSectionEntityId' INTEGER NOT NULL,
	'SimpleAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = NotAssessed, 2 = Sufficient, 3 = NoVerdict
	'DetailedAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = Sufficient, 3 = Insufficient, 4 = NotAssessed
	'TailorMadeAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = ProbabilityNegligible, 3 = Sufficient, 4 = Insufficient, 5 = NotAssessed
	'UseManualAssembly' TINYINT (1) NOT NULL, -- true or false
	'ManualAssemblyCategoryGroup' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = NotApplicable, 3 = Iv, 4 = IIv, 5 = Vv, 6 = VIIv  
	CONSTRAINT 'FK_PipingStructureSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'DuneErosionSectionResultEntity'
(
	'DuneErosionSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismSectionEntityId' INTEGER NOT NULL,
	'SimpleAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = NotApplicable, 3 = Applicable
	'DetailedAssessmentResultForFactorizedSignalingNorm' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = Sufficient 3 = Insufficient, 4 = NotAssessed
	'DetailedAssessmentResultForSignalingNorm' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = Sufficient 3 = Insufficient, 4 = NotAssessed
	'DetailedAssessmentResultForMechanismSpecificLowerLimitNorm' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = Sufficient 3 = Insufficient, 4 = NotAssessed
	'DetailedAssessmentResultForLowerLimitNorm' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = Sufficient 3 = Insufficient, 4 = NotAssessed
	'DetailedAssessmentResultForFactorizedLowerLimitNorm' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = Sufficient 3 = Insufficient, 4 = NotAssessed
	'TailorMadeAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = Iv, 3 = IIv, 4 = IIIv, 5 = IVv, 6 = Vv, 7 = VIv, 8 = VIIv
	'UseManualAssembly' TINYINT (1) NOT NULL, -- true or false
	'ManualAssemblyCategoryGroup' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = NotApplicable 3 = Iv, 4 = IIv, 5 = IIIv, 6 = IVv, 7 = Vv, 8 = VIv, 9 = VIIv
	CONSTRAINT 'FK_DuneErosionSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'StabilityStoneCoverSectionResultEntity'
(
	'StabilityStoneCoverSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismSectionEntityId' INTEGER NOT NULL,
	'SimpleAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = NotApplicable, 3 = Applicable
	'DetailedAssessmentResultForFactorizedSignalingNorm' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = Sufficient, 3 = Insufficient, 4 = NotAssessed
	'DetailedAssessmentResultForSignalingNorm' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = Sufficient, 3 = Insufficient, 4 = NotAssessed
	'DetailedAssessmentResultForMechanismSpecificLowerLimitNorm' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = Sufficient, 3 = Insufficient, 4 = NotAssessed
	'DetailedAssessmentResultForLowerLimitNorm' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = Sufficient, 3 = Insufficient, 4 = NotAssessed
	'DetailedAssessmentResultForFactorizedLowerLimitNorm' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = Sufficient, 3 = Insufficient, 4 = NotAssessed
	'TailorMadeAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = Iv, 3 = IIv, 4 = IIIv, 5 = IVv, 6 = Vv, 7 = VIv, 8 = VIIv
	'UseManualAssembly' TINYINT (1) NOT NULL, -- true or false
	'ManualAssemblyCategoryGroup' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = NotApplicable 3 = Iv, 4 = IIv, 5 = IIIv, 6 = IVv, 7 = Vv, 8 = VIv, 9 = VIIv
	CONSTRAINT 'FK_StabilityStoneCoverSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'StabilityPointStructuresSectionResultEntity'
(
	'StabilityPointStructuresSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismSectionEntityId' INTEGER NOT NULL,
	'StabilityPointStructuresCalculationEntityId' INTEGER,
	'SimpleAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = NotApplicable, 3 = Applicable
	'DetailedAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = Probability, 2 = NotAssessed
	'TailorMadeAssessmentResult' TINYINT (1) NOT NULL, -- Enum: 1 = None, 2 = ProbabilityNegligible, 3 = Probability, 4 = NotAssessed
	'TailorMadeAssessmentProbability' REAL,
	'UseManualAssembly' TINYINT (1) NOT NULL, -- true or false
	'ManualAssemblyProbability' REAL,
	CONSTRAINT 'FK_StabilityPointStructuresSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'FK_StabilityPointStructuresSectionResultEntity_StabilityPointStructuresCalculationEntity' FOREIGN KEY ('StabilityPointStructuresCalculationEntityId') REFERENCES 'StabilityPointStructuresCalculationEntity' ('StabilityPointStructuresCalculationEntityId') ON DELETE Set Null ON UPDATE Cascade
)
;

CREATE TABLE 'DikeProfileEntity'
(
	'DikeProfileEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismEntityId' INTEGER NOT NULL,
	'Id' VARCHAR (260) NOT NULL,
	'Name' VARCHAR (260) NOT NULL,
	'Orientation' REAL,
	'BreakWaterType' TINYINT (1), -- Enum: 1 = Wall 2 = Caisson 3 = Dam
	'BreakWaterHeight' REAL,
	'ForeshoreXml' TEXT NOT NULL,
	'DikeGeometryXml' TEXT NOT NULL,
	'DikeHeight' REAL,
	'X' REAL,
	'Y' REAL,
	'X0' REAL,
	'Order' INT (4) NOT NULL,
	CONSTRAINT 'FK_DikeProfileEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'UQ_DikeProfileEntity_IdFailureMechanismEntityId' UNIQUE ('Id','FailureMechanismEntityId')
)
;

CREATE TABLE 'GrassCoverErosionInwardsOutputEntity'
(
	'GrassCoverErosionInwardsOutputEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'GrassCoverErosionInwardsCalculationEntityId' INTEGER NOT NULL,
	'GeneralResultFaultTreeIllustrationPointEntityId' INTEGER,
	'Order' INT (4) NOT NULL,
	'IsOvertoppingDominant' TINYINT (1) NOT NULL, -- true or false
	'WaveHeight' REAL,
	'Reliability' REAL,
	CONSTRAINT 'FK_GrassCoverErosionInwardsOutputEntity_GeneralResultFaultTreeIllustrationPointEntity' FOREIGN KEY ('GeneralResultFaultTreeIllustrationPointEntityId') REFERENCES 'GeneralResultFaultTreeIllustrationPointEntity' ('GeneralResultFaultTreeIllustrationPointEntityId') ON DELETE Set Null ON UPDATE Cascade,
	CONSTRAINT 'FK_GrassCoverErosionInwardsOutputEntity_GrassCoverErosionInwardsCalculationEntity' FOREIGN KEY ('GrassCoverErosionInwardsCalculationEntityId') REFERENCES 'GrassCoverErosionInwardsCalculationEntity' ('GrassCoverErosionInwardsCalculationEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'U_GrassCoverErosionInwardsCalculationEntity' UNIQUE ('GrassCoverErosionInwardsCalculationEntityId')
)
;

CREATE TABLE 'ForeshoreProfileEntity'
(
	'ForeshoreProfileEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismEntityId' INTEGER NOT NULL,
	'Id' VARCHAR (260) NOT NULL,
	'Name' VARCHAR (260) NOT NULL,
	'Orientation' REAL,
	'BreakWaterType' TINYINT (1), -- Enum: 1 = Wall, 2 = Caisson, 3 = Dam
	'BreakWaterHeight' REAL,
	'GeometryXml' TEXT NOT NULL,
	'X' REAL,
	'Y' REAL,
	'X0' REAL,
	'Order' INT (4) NOT NULL,
	CONSTRAINT 'FK_ForeshoreProfileEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'UQ_ForeshoreProfileEntity_IdFailureMechanismEntityId' UNIQUE ('Id','FailureMechanismEntityId')
)
;

CREATE TABLE 'StabilityStoneCoverWaveConditionsCalculationEntity'
(
	'StabilityStoneCoverWaveConditionsCalculationEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'CalculationGroupEntityId' INTEGER NOT NULL,
	'ForeshoreProfileEntityId' INTEGER,
	'HydraulicLocationEntityId' INTEGER,
	'Order' INT (4) NOT NULL,
	'Name' VARCHAR (260),
	'Comments' TEXT,
	'UseBreakWater' TINYINT (1) NOT NULL, -- true or false
	'BreakWaterType' TINYINT (1) NOT NULL, -- Enum: 1 = Wall, 2 = Caisson, 3 = Dam
	'BreakWaterHeight' REAL,
	'UseForeshore' TINYINT (1) NOT NULL, -- true or false
	'Orientation' REAL,
	'UpperBoundaryRevetment' REAL,
	'LowerBoundaryRevetment' REAL,
	'UpperBoundaryWaterLevels' REAL,
	'LowerBoundaryWaterLevels' REAL,
	'StepSize' TINYINT (1) NOT NULL, -- Enum: 1 = 0.5, 2 = 1.0, 3 = 2.0
	'CategoryType' TINYINT (1) NOT NULL, -- Enum:  1 = FactorizedSignalingNorm, 2 = SignalingNorm, 3 = LowerLimitNorm,  4 = FactorizedLowerLimitNorm
	CONSTRAINT 'FK_StabilityStoneCoverWaveConditionsCalculationEntity_CalculationGroupEntity' FOREIGN KEY ('CalculationGroupEntityId') REFERENCES 'CalculationGroupEntity' ('CalculationGroupEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'FK_StabilityStoneCoverWaveConditionsCalculationEntity_ForeshoreProfileEntity' FOREIGN KEY ('ForeshoreProfileEntityId') REFERENCES 'ForeshoreProfileEntity' ('ForeshoreProfileEntityId') ON DELETE Set Null ON UPDATE Cascade,
	CONSTRAINT 'FK_StabilityStoneCoverWaveConditionsCalculationEntity_HydraulicLocationEntity' FOREIGN KEY ('HydraulicLocationEntityId') REFERENCES 'HydraulicLocationEntity' ('HydraulicLocationEntityId') ON DELETE Set Null ON UPDATE Cascade
)
;

CREATE TABLE 'StabilityStoneCoverWaveConditionsOutputEntity'
(
	'StabilityStoneCoverWaveConditionsOutputEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'StabilityStoneCoverWaveConditionsCalculationEntityId' INTEGER NOT NULL,
	'Order' INT (4) NOT NULL,
	'OutputType' TINYINT (1) NOT NULL, -- Enum: 1 = Column, 2 = Block
	'WaterLevel' REAL,
	'WaveHeight' REAL,
	'WavePeakPeriod' REAL,
	'WaveAngle' REAL,
	'WaveDirection' REAL,
	'TargetProbability' REAL,
	'TargetReliability' REAL,
	'CalculatedProbability' REAL,
	'CalculatedReliability' REAL,
	'CalculationConvergence' TINYINT (1) NOT NULL, -- Enum: 1 = NotCalculated, 2 = CalculationNotConverged, 3 = CalculationConverged
	CONSTRAINT 'FK_StabilityStoneCoverWaveConditionsOutputEntity_StabilityStoneCoverWaveConditionsCalculationEntity' FOREIGN KEY ('StabilityStoneCoverWaveConditionsCalculationEntityId') REFERENCES 'StabilityStoneCoverWaveConditionsCalculationEntity' ('StabilityStoneCoverWaveConditionsCalculationEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'WaveImpactAsphaltCoverWaveConditionsCalculationEntity'
(
	'WaveImpactAsphaltCoverWaveConditionsCalculationEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'CalculationGroupEntityId' INTEGER NOT NULL,
	'ForeshoreProfileEntityId' INTEGER,
	'HydraulicLocationEntityId' INTEGER,
	'Order' INT (4) NOT NULL,
	'Name' VARCHAR (260),
	'Comments' TEXT,
	'UseBreakWater' TINYINT (1) NOT NULL, -- true or false
	'BreakWaterType' TINYINT (1) NOT NULL, -- Enum: 1 = Wall, 2 = Caisson, 3 = Dam
	'BreakWaterHeight' REAL,
	'UseForeshore' TINYINT (1) NOT NULL, -- true or false
	'Orientation' REAL,
	'UpperBoundaryRevetment' REAL,
	'LowerBoundaryRevetment' REAL,
	'UpperBoundaryWaterLevels' REAL,
	'LowerBoundaryWaterLevels' REAL,
	'StepSize' TINYINT (1) NOT NULL, -- Enum: 1 = 0.5, 2 = 1.0, 3 = 2.0
	'CategoryType' TINYINT (1) NOT NULL, -- Enum:  1 = FactorizedSignalingNorm, 2 = SignalingNorm, 3 = LowerLimitNorm,  4 = FactorizedLowerLimitNorm 
	CONSTRAINT 'FK_WaveImpactAsphaltCoverWaveConditionsCalculationEntity_CalculationGroupEntity' FOREIGN KEY ('CalculationGroupEntityId') REFERENCES 'CalculationGroupEntity' ('CalculationGroupEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'FK_WaveImpactAsphaltCoverWaveConditionsCalculationEntity_ForeshoreProfileEntity' FOREIGN KEY ('ForeshoreProfileEntityId') REFERENCES 'ForeshoreProfileEntity' ('ForeshoreProfileEntityId') ON DELETE Set Null ON UPDATE Cascade,
	CONSTRAINT 'FK_WaveImpactAsphaltCoverWaveConditionsCalculationEntity_HydraulicLocationEntity' FOREIGN KEY ('HydraulicLocationEntityId') REFERENCES 'HydraulicLocationEntity' ('HydraulicLocationEntityId') ON DELETE Set Null ON UPDATE Cascade
)
;

CREATE TABLE 'WaveImpactAsphaltCoverWaveConditionsOutputEntity'
(
	'WaveImpactAsphaltCoverWaveConditionsOutputEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'WaveImpactAsphaltCoverWaveConditionsCalculationEntityId' INTEGER NOT NULL,
	'Order' INT (4) NOT NULL,
	'WaterLevel' REAL,
	'WaveHeight' REAL,
	'WavePeakPeriod' REAL,
	'WaveAngle' REAL,
	'WaveDirection' REAL,
	'TargetProbability' REAL,
	'TargetReliability' REAL,
	'CalculatedProbability' REAL,
	'CalculatedReliability' REAL,
	'CalculationConvergence' TINYINT (1) NOT NULL, -- Enum: 1 = NotCalculated, 2 = CalculationNotConverged, 3 = CalculationConverged
	CONSTRAINT 'FK_WaveImpactAsphaltCoverWaveConditionsOutputEntity_WaveImpactAsphaltCoverWaveConditionsCalculationEntity' FOREIGN KEY ('WaveImpactAsphaltCoverWaveConditionsCalculationEntityId') REFERENCES 'WaveImpactAsphaltCoverWaveConditionsCalculationEntity' ('WaveImpactAsphaltCoverWaveConditionsCalculationEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'GrassCoverErosionOutwardsWaveConditionsCalculationEntity'
(
	'GrassCoverErosionOutwardsWaveConditionsCalculationEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'CalculationGroupEntityId' INTEGER NOT NULL,
	'ForeshoreProfileEntityId' INTEGER,
	'HydraulicLocationEntityId' INTEGER,
	'Order' INT (4) NOT NULL,
	'Name' VARCHAR (260),
	'Comments' TEXT,
	'UseBreakWater' TINYINT (1) NOT NULL, -- true or false
	'BreakWaterType' TINYINT (1) NOT NULL, -- Enum: 1 = Wall, 2 = Caisson, 3 = Dam
	'BreakWaterHeight' REAL,
	'UseForeshore' TINYINT (1) NOT NULL, -- true or false
	'Orientation' REAL,
	'UpperBoundaryRevetment' REAL,
	'LowerBoundaryRevetment' REAL,
	'UpperBoundaryWaterLevels' REAL,
	'LowerBoundaryWaterLevels' REAL,
	'StepSize' TINYINT (1) NOT NULL, -- Enum: 1 = 0.5, 2 = 1.0, 3 = 2.0
	'CategoryType' TINYINT (1) NOT NULL, -- Enum: 1 = MechanismSpecificFactorizedSignalingNorm, 2 = MechanismSpecificSignalingNorm, 3 = MechanismSpecificLowerLimitNorm, 4 = LowerLimitNorm, 5 = FactorizedLowerLimitNorm
	CONSTRAINT 'FK_GrassCoverErosionOutwardsWaveConditionsCalculationEntity_CalculationGroupEntity' FOREIGN KEY ('CalculationGroupEntityId') REFERENCES 'CalculationGroupEntity' ('CalculationGroupEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'FK_GrassCoverErosionOutwardsWaveConditionsCalculationEntity_ForeshoreProfileEntity' FOREIGN KEY ('ForeshoreProfileEntityId') REFERENCES 'ForeshoreProfileEntity' ('ForeshoreProfileEntityId') ON DELETE Set Null ON UPDATE Cascade,
	CONSTRAINT 'FK_GrassCoverErosionOutwardsWaveConditionsCalculationEntity_HydraulicLocationEntity' FOREIGN KEY ('HydraulicLocationEntityId') REFERENCES 'HydraulicLocationEntity' ('HydraulicLocationEntityId') ON DELETE Set Null ON UPDATE Cascade
)
;

CREATE TABLE 'GrassCoverErosionOutwardsWaveConditionsOutputEntity'
(
	'GrassCoverErosionOutwardsWaveConditionsOutputEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'GrassCoverErosionOutwardsWaveConditionsCalculationEntityId' INTEGER NOT NULL,
	'Order' INT (4) NOT NULL,
	'WaterLevel' REAL,
	'WaveHeight' REAL,
	'WavePeakPeriod' REAL,
	'WaveAngle' REAL,
	'WaveDirection' REAL,
	'TargetProbability' REAL,
	'TargetReliability' REAL,
	'CalculatedProbability' REAL,
	'CalculatedReliability' REAL,
	'CalculationConvergence' TINYINT (1) NOT NULL, -- Enum: 1 = NotCalculated, 2 = CalculationNotConverged, 3 = CalculationConverged
	CONSTRAINT 'FK_GrassCoverErosionOutwardsWaveConditionsOutputEntity_GrassCoverErosionOutwardsWaveConditionsCalculationEntity' FOREIGN KEY ('GrassCoverErosionOutwardsWaveConditionsCalculationEntityId') REFERENCES 'GrassCoverErosionOutwardsWaveConditionsCalculationEntity' ('GrassCoverErosionOutwardsWaveConditionsCalculationEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'HeightStructuresOutputEntity'
(
	'HeightStructuresOutputEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'HeightStructuresCalculationEntityId' INTEGER NOT NULL,
	'GeneralResultFaultTreeIllustrationPointEntityId' INTEGER,
	'Reliability' REAL,
	CONSTRAINT 'FK_HeightStructuresOutputEntity_GeneralResultFaultTreeIllustrationPointEntity' FOREIGN KEY ('GeneralResultFaultTreeIllustrationPointEntityId') REFERENCES 'GeneralResultFaultTreeIllustrationPointEntity' ('GeneralResultFaultTreeIllustrationPointEntityId') ON DELETE Set Null ON UPDATE Cascade,
	CONSTRAINT 'FK_HeightStructuresOutputEntity_HeightStructuresCalculationEntity' FOREIGN KEY ('HeightStructuresCalculationEntityId') REFERENCES 'HeightStructuresCalculationEntity' ('HeightStructuresCalculationEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'U_HeightStructuresCalculationEntity' UNIQUE ('HeightStructuresCalculationEntityId')
)
;

CREATE TABLE 'HeightStructureEntity'
(
	'HeightStructureEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismEntityId' INTEGER NOT NULL,
	'Order' INT (4) NOT NULL,
	'Name' VARCHAR (260) NOT NULL,
	'Id' VARCHAR (260) NOT NULL,
	'X' REAL,
	'Y' REAL,
	'StructureNormalOrientation' REAL,
	'LevelCrestStructureMean' REAL,
	'LevelCrestStructureStandardDeviation' REAL,
	'FlowWidthAtBottomProtectionMean' REAL,
	'FlowWidthAtBottomProtectionStandardDeviation' REAL,
	'CriticalOvertoppingDischargeMean' REAL,
	'CriticalOvertoppingDischargeCoefficientOfVariation' REAL,
	'WidthFlowAperturesMean' REAL,
	'WidthFlowAperturesStandardDeviation' REAL,
	'FailureProbabilityStructureWithErosion' REAL,
	'StorageStructureAreaMean' REAL,
	'StorageStructureAreaCoefficientOfVariation' REAL,
	'AllowedLevelIncreaseStorageMean' REAL,
	'AllowedLevelIncreaseStorageStandardDeviation' REAL,
	CONSTRAINT 'FK_HeightStructure_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'U_Id_FailureMechanismEntityId' UNIQUE ('FailureMechanismEntityId','Id')
)
;

CREATE TABLE 'HeightStructuresCalculationEntity'
(
	'HeightStructuresCalculationEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'CalculationGroupEntityId' INTEGER NOT NULL,
	'HydraulicLocationEntityId' INTEGER,
	'HeightStructureEntityId' INTEGER,
	'ForeshoreProfileEntityId' INTEGER,
	'Order' INT (4) NOT NULL,
	'Name' VARCHAR (260),
	'Comments' TEXT,
	'ModelFactorSuperCriticalFlowMean' REAL,
	'StructureNormalOrientation' REAL,
	'AllowedLevelIncreaseStorageMean' REAL,
	'AllowedLevelIncreaseStorageStandardDeviation' REAL,
	'StorageStructureAreaMean' REAL,
	'StorageStructureAreaCoefficientOfVariation' REAL,
	'FlowWidthAtBottomProtectionMean' REAL,
	'FlowWidthAtBottomProtectionStandardDeviation' REAL,
	'CriticalOvertoppingDischargeMean' REAL,
	'CriticalOvertoppingDischargeCoefficientOfVariation' REAL,
	'FailureProbabilityStructureWithErosion' REAL NOT NULL,
	'WidthFlowAperturesMean' REAL,
	'WidthFlowAperturesStandardDeviation' REAL,
	'StormDurationMean' REAL,
	'LevelCrestStructureMean' REAL,
	'LevelCrestStructureStandardDeviation' REAL,
	'DeviationWaveDirection' REAL,
	'UseBreakWater' TINYINT (1) NOT NULL, -- true or false
	'UseForeshore' TINYINT (1) NOT NULL, -- true or false
	'BreakWaterType' TINYINT (1) NOT NULL, -- Enum: 1 = Wall, 2 = Caisson, 3 = Dam
	'BreakWaterHeight' REAL,
	'ShouldIllustrationPointsBeCalculated' TINYINT (1) NOT NULL, -- true or false
	CONSTRAINT 'FK_HeightStructuresCalculationEntity_CalculationGroupEntity' FOREIGN KEY ('CalculationGroupEntityId') REFERENCES 'CalculationGroupEntity' ('CalculationGroupEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'FK_HeightStructuresCalculationEntity_ForeshoreProfileEntity' FOREIGN KEY ('ForeshoreProfileEntityId') REFERENCES 'ForeshoreProfileEntity' ('ForeshoreProfileEntityId') ON DELETE Set Null ON UPDATE Cascade,
	CONSTRAINT 'FK_HeightStructuresCalculationEntity_HeightStructureEntity' FOREIGN KEY ('HeightStructureEntityId') REFERENCES 'HeightStructureEntity' ('HeightStructureEntityId') ON DELETE Set Null ON UPDATE Cascade,
	CONSTRAINT 'FK_HeightStructuresCalculationEntity_HydraulicLocationEntity' FOREIGN KEY ('HydraulicLocationEntityId') REFERENCES 'HydraulicLocationEntity' ('HydraulicLocationEntityId') ON DELETE Set Null ON UPDATE Cascade
)
;

CREATE TABLE 'ClosingStructureEntity'
(
	'ClosingStructureEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismEntityId' INTEGER NOT NULL,
	'Order' INT (4) NOT NULL,
	'Name' VARCHAR (260) NOT NULL,
	'Id' VARCHAR (260) NOT NULL,
	'X' REAL,
	'Y' REAL,
	'StructureNormalOrientation' REAL,
	'StorageStructureAreaMean' REAL,
	'StorageStructureAreaCoefficientOfVariation' REAL,
	'AllowedLevelIncreaseStorageMean' REAL,
	'AllowedLevelIncreaseStorageStandardDeviation' REAL,
	'WidthFlowAperturesMean' REAL,
	'WidthFlowAperturesStandardDeviation' REAL,
	'LevelCrestStructureNotClosingMean' REAL,
	'LevelCrestStructureNotClosingStandardDeviation' REAL,
	'InsideWaterLevelMean' REAL,
	'InsideWaterLevelStandardDeviation' REAL,
	'ThresholdHeightOpenWeirMean' REAL,
	'ThresholdHeightOpenWeirStandardDeviation' REAL,
	'AreaFlowAperturesMean' REAL,
	'AreaFlowAperturesStandardDeviation' REAL,
	'CriticalOvertoppingDischargeMean' REAL,
	'CriticalOvertoppingDischargeCoefficientOfVariation' REAL,
	'FlowWidthAtBottomProtectionMean' REAL,
	'FlowWidthAtBottomProtectionStandardDeviation' REAL,
	'ProbabilityOpenStructureBeforeFlooding' REAL,
	'FailureProbabilityOpenStructure' REAL,
	'IdenticalApertures' INT (4) NOT NULL,
	'FailureProbabilityReparation' REAL,
	'InflowModelType' TINYINT (1) NOT NULL, -- Enum: 1 = VerticalWall, 2 = LowSill, 3 = FloodedCulvert
	CONSTRAINT 'FK_ClosingStructureEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'U_Id_FailureMechanismEntityId' UNIQUE ('FailureMechanismEntityId','Id')
)
;

CREATE TABLE 'ClosingStructuresCalculationEntity'
(
	'ClosingStructuresCalculationEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'CalculationGroupEntityId' INTEGER NOT NULL,
	'ForeshoreProfileEntityId' INTEGER,
	'HydraulicLocationEntityId' INTEGER,
	'ClosingStructureEntityId' INTEGER,
	'Order' INT (4) NOT NULL,
	'Name' VARCHAR (255),
	'Comments' TEXT,
	'UseBreakWater' TINYINT (1) NOT NULL, -- true or false
	'BreakWaterType' TINYINT (1) NOT NULL, -- Enum: 1 = Wall, 2 = Caisson, 3 = Dam
	'BreakWaterHeight' REAL,
	'UseForeshore' TINYINT (1) NOT NULL, -- true or false
	'Orientation' REAL,
	'StructureNormalOrientation' REAL,
	'StorageStructureAreaMean' REAL,
	'StorageStructureAreaCoefficientOfVariation' REAL,
	'AllowedLevelIncreaseStorageMean' REAL,
	'AllowedLevelIncreaseStorageStandardDeviation' REAL,
	'WidthFlowAperturesMean' REAL,
	'WidthFlowAperturesStandardDeviation' REAL,
	'LevelCrestStructureNotClosingMean' REAL,
	'LevelCrestStructureNotClosingStandardDeviation' REAL,
	'InsideWaterLevelMean' REAL,
	'InsideWaterLevelStandardDeviation' REAL,
	'ThresholdHeightOpenWeirMean' REAL,
	'ThresholdHeightOpenWeirStandardDeviation' REAL,
	'AreaFlowAperturesMean' REAL,
	'AreaFlowAperturesStandardDeviation' REAL,
	'CriticalOvertoppingDischargeMean' REAL,
	'CriticalOvertoppingDischargeCoefficientOfVariation' REAL,
	'FlowWidthAtBottomProtectionMean' REAL,
	'FlowWidthAtBottomProtectionStandardDeviation' REAL,
	'ProbabilityOpenStructureBeforeFlooding' REAL NOT NULL,
	'FailureProbabilityOpenStructure' REAL NOT NULL,
	'IdenticalApertures' INT (4) NOT NULL,
	'FailureProbabilityReparation' REAL NOT NULL,
	'InflowModelType' TINYINT (1) NOT NULL, -- Enum: 1 = VerticalWall, 2 = LowSill, 3 = FloodedCulvert
	'FailureProbabilityStructureWithErosion' REAL NOT NULL,
	'DeviationWaveDirection' REAL,
	'DrainCoefficientMean' REAL,
	'ModelFactorSuperCriticalFlowMean' REAL,
	'StormDurationMean' REAL,
	'FactorStormDurationOpenStructure' REAL,
	'ShouldIllustrationPointsBeCalculated' TINYINT (1) NOT NULL, -- true or false
	CONSTRAINT 'FK_ClosingStructuresCalculationEntity_CalculationGroupEntity' FOREIGN KEY ('CalculationGroupEntityId') REFERENCES 'CalculationGroupEntity' ('CalculationGroupEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'FK_ClosingStructuresCalculationEntity_ClosingStructureEntity' FOREIGN KEY ('ClosingStructureEntityId') REFERENCES 'ClosingStructureEntity' ('ClosingStructureEntityId') ON DELETE Set Null ON UPDATE Cascade,
	CONSTRAINT 'FK_ClosingStructuresCalculationEntity_ForeshoreProfileEntity' FOREIGN KEY ('ForeshoreProfileEntityId') REFERENCES 'ForeshoreProfileEntity' ('ForeshoreProfileEntityId') ON DELETE Set Null ON UPDATE Cascade,
	CONSTRAINT 'FK_ClosingStructuresCalculationEntity_HydraulicLocationEntity' FOREIGN KEY ('HydraulicLocationEntityId') REFERENCES 'HydraulicLocationEntity' ('HydraulicLocationEntityId') ON DELETE Set Null ON UPDATE Cascade
)
;

CREATE TABLE 'ClosingStructuresOutputEntity'
(
	'ClosingStructuresOutputEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'ClosingStructuresCalculationEntityId' INTEGER NOT NULL,
	'GeneralResultFaultTreeIllustrationPointEntityId' INTEGER,
	'Reliability' REAL,
	CONSTRAINT 'FK_ClosingStructuresOutputEntity_ClosingStructuresCalculationEntity' FOREIGN KEY ('ClosingStructuresCalculationEntityId') REFERENCES 'ClosingStructuresCalculationEntity' ('ClosingStructuresCalculationEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'FK_ClosingStructuresOutputEntity_GeneralResultFaultTreeIllustrationPointEntity' FOREIGN KEY ('GeneralResultFaultTreeIllustrationPointEntityId') REFERENCES 'GeneralResultFaultTreeIllustrationPointEntity' ('GeneralResultFaultTreeIllustrationPointEntityId') ON DELETE Set Null ON UPDATE Cascade,
	CONSTRAINT 'U_ClosingStructuresCalculationEntity' UNIQUE ('ClosingStructuresCalculationEntityId')
)
;

CREATE TABLE 'StabilityPointStructureEntity'
(
	'StabilityPointStructureEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismEntityId' INTEGER NOT NULL,
	'Order' INT (4) NOT NULL,
	'Name' VARCHAR (260) NOT NULL,
	'Id' VARCHAR (260) NOT NULL,
	'X' REAL,
	'Y' REAL,
	'StructureNormalOrientation' REAL,
	'StorageStructureAreaMean' REAL,
	'StorageStructureAreaCoefficientOfVariation' REAL,
	'AllowedLevelIncreaseStorageMean' REAL,
	'AllowedLevelIncreaseStorageStandardDeviation' REAL,
	'WidthFlowAperturesMean' REAL,
	'WidthFlowAperturesStandardDeviation' REAL,
	'InsideWaterLevelMean' REAL,
	'InsideWaterLevelStandardDeviation' REAL,
	'ThresholdHeightOpenWeirMean' REAL,
	'ThresholdHeightOpenWeirStandardDeviation' REAL,
	'CriticalOvertoppingDischargeMean' REAL,
	'CriticalOvertoppingDischargeCoefficientOfVariation' REAL,
	'FlowWidthAtBottomProtectionMean' REAL,
	'FlowWidthAtBottomProtectionStandardDeviation' REAL,
	'ConstructiveStrengthLinearLoadModelMean' REAL,
	'ConstructiveStrengthLinearLoadModelCoefficientOfVariation' REAL,
	'ConstructiveStrengthQuadraticLoadModelMean' REAL,
	'ConstructiveStrengthQuadraticLoadModelCoefficientOfVariation' REAL,
	'BankWidthMean' REAL,
	'BankWidthStandardDeviation' REAL,
	'InsideWaterLevelFailureConstructionMean' REAL,
	'InsideWaterLevelFailureConstructionStandardDeviation' REAL,
	'EvaluationLevel' REAL,
	'LevelCrestStructureMean' REAL,
	'LevelCrestStructureStandardDeviation' REAL,
	'VerticalDistance' REAL,
	'FailureProbabilityRepairClosure' REAL,
	'FailureCollisionEnergyMean' REAL,
	'FailureCollisionEnergyCoefficientOfVariation' REAL,
	'ShipMassMean' REAL,
	'ShipMassCoefficientOfVariation' REAL,
	'ShipVelocityMean' REAL,
	'ShipVelocityCoefficientOfVariation' REAL,
	'LevellingCount' INT (4) NOT NULL,
	'ProbabilityCollisionSecondaryStructure' REAL,
	'FlowVelocityStructureClosableMean' REAL,
	'StabilityLinearLoadModelMean' REAL,
	'StabilityLinearLoadModelCoefficientOfVariation' REAL,
	'StabilityQuadraticLoadModelMean' REAL,
	'StabilityQuadraticLoadModelCoefficientOfVariation' REAL,
	'AreaFlowAperturesMean' REAL,
	'AreaFlowAperturesStandardDeviation' REAL,
	'InflowModelType' TINYINT (1) NOT NULL, -- Enum: 1 = LowSill, 2 = FloodedCulvert
	CONSTRAINT 'FK_StabilityPointStructureEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'U_Id_FailureMechanismEntityId' UNIQUE ('FailureMechanismEntityId','Id')
)
;

CREATE TABLE 'StabilityPointStructuresOutputEntity'
(
	'StabilityPointStructuresOutputEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'StabilityPointStructuresCalculationEntityId' INTEGER NOT NULL,
	'GeneralResultFaultTreeIllustrationPointEntityId' INTEGER,
	'Reliability' REAL,
	CONSTRAINT 'FK_StabilityPointStructuresOutputEntity_GeneralResultFaultTreeIllustrationPointEntity' FOREIGN KEY ('GeneralResultFaultTreeIllustrationPointEntityId') REFERENCES 'GeneralResultFaultTreeIllustrationPointEntity' ('GeneralResultFaultTreeIllustrationPointEntityId') ON DELETE Set Null ON UPDATE Cascade,
	CONSTRAINT 'FK_StabilityPointStructuresOutputEntity_StabilityPointStructuresCalculationEntity' FOREIGN KEY ('StabilityPointStructuresCalculationEntityId') REFERENCES 'StabilityPointStructuresCalculationEntity' ('StabilityPointStructuresCalculationEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'U_StabilityPointStructuresCalculationEntity' UNIQUE ('StabilityPointStructuresCalculationEntityId')
)
;

CREATE TABLE 'HydraulicLocationOutputEntity'
(
	'HydraulicLocationOutputEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'HydraulicLocationCalculationEntityId' INTEGER,
	'GeneralResultSubMechanismIllustrationPointEntityId' INTEGER,
	'Result' REAL,
	'TargetProbability' REAL,
	'TargetReliability' REAL,
	'CalculatedProbability' REAL,
	'CalculatedReliability' REAL,
	'CalculationConvergence' TINYINT (1) NOT NULL, -- Enum: 1 = NotCalculated, 2 = CalculatedNotConverged, 3 = CalculatedConverged
	CONSTRAINT 'FK_HydraulicLocationOutputEntity_GeneralResultSubMechanismIllustrationPointEntity' FOREIGN KEY ('GeneralResultSubMechanismIllustrationPointEntityId') REFERENCES 'GeneralResultSubMechanismIllustrationPointEntity' ('GeneralResultSubMechanismIllustrationPointEntityId') ON DELETE Set Null ON UPDATE Cascade,
	CONSTRAINT 'FK_HydraulicLocationOutputEntity_HydraulicLocationCalculationEntity' FOREIGN KEY ('HydraulicLocationCalculationEntityId') REFERENCES 'HydraulicLocationCalculationEntity' ('HydraulicLocationCalculationEntityId') ON DELETE Set Null ON UPDATE Cascade
)
;

CREATE TABLE 'DuneLocationEntity'
(
	'DuneLocationEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FailureMechanismEntityId' INTEGER NOT NULL,
	'LocationId' INTEGER NOT NULL,
	'Name' VARCHAR (260) NOT NULL,
	'LocationX' REAL,
	'LocationY' REAL,
	'CoastalAreaId' INT (4) NOT NULL,
	'Offset' REAL,
	'Orientation' REAL,
	'D50' REAL,
	'Order' INT (4) NOT NULL,
	CONSTRAINT 'FK_DuneLocationEntity_FailureMechanismEntity' FOREIGN KEY ('FailureMechanismEntityId') REFERENCES 'FailureMechanismEntity' ('FailureMechanismEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'DuneLocationCalculationOutputEntity'
(
	'DuneLocationCalculationOutputEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'DuneLocationCalculationEntityId' INTEGER NOT NULL,
	'WaterLevel' REAL,
	'WaveHeight' REAL,
	'WavePeriod' REAL,
	'TargetProbability' REAL,
	'TargetReliability' REAL,
	'CalculatedProbability' REAL,
	'CalculatedReliability' REAL,
	'CalculationConvergence' TINYINT (1) NOT NULL, -- Enum: 1 = NotCalculated, 2 = CalculatedNotConverged, 3 = CalculatedConverged
	CONSTRAINT 'FK_DuneLocationCalculationOutputEntity_DuneLocationCalculationEntity' FOREIGN KEY ('DuneLocationCalculationEntityId') REFERENCES 'DuneLocationCalculationEntity' ('DuneLocationCalculationEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'BackgroundDataEntity'
(
	'BackgroundDataEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'AssessmentSectionEntityId' INTEGER NOT NULL,
	'Name' TEXT NOT NULL,
	'IsVisible' TINYINT (1) NOT NULL, -- true or false
	'Transparency' REAL NOT NULL,
	'BackgroundDataType' TINYINT (1) NOT NULL, -- Enum: 1 = Wmts, 2 = WellKnown
	CONSTRAINT 'FK_BackgroundDataEntity_AssessmentSectionEntity' FOREIGN KEY ('AssessmentSectionEntityId') REFERENCES 'AssessmentSectionEntity' ('AssessmentSectionEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'BackgroundDataMetaEntity'
(
	'BackgroundDataMetaEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'BackgroundDataEntityId' INTEGER NOT NULL,
	'Key' TEXT NOT NULL,
	'Value' TEXT NOT NULL,
	CONSTRAINT 'FK_BackgroundDataMetaEntity_BackgroundDataEntity' FOREIGN KEY ('BackgroundDataEntityId') REFERENCES 'BackgroundDataEntity' ('BackgroundDataEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'U_BackgroundDataEntityId_Key' UNIQUE ('BackgroundDataEntityId','Key')
)
;

CREATE TABLE 'GrassCoverErosionInwardsOvertoppingRateOutputEntity'
(
	'GrassCoverErosionInwardsOvertoppingRateOutputEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'GrassCoverErosionInwardsOutputEntityId' INTEGER NOT NULL,
	'GeneralResultFaultTreeIllustrationPointEntityId' INTEGER,
	'OvertoppingRate' REAL,
	'TargetProbability' REAL,
	'TargetReliability' REAL,
	'CalculatedProbability' REAL,
	'CalculatedReliability' REAL,
	'CalculationConvergence' TINYINT (1) NOT NULL, -- Enum: 1 = NotCalculated, 2 = CalculationNotConverged, 3 = CalculationConverged
	CONSTRAINT 'FK_GrassCoverErosionInwardsOvertoppingRateOutputEntity_GeneralResultFaultTreeIllustrationPointEntity' FOREIGN KEY ('GeneralResultFaultTreeIllustrationPointEntityId') REFERENCES 'GeneralResultFaultTreeIllustrationPointEntity' ('GeneralResultFaultTreeIllustrationPointEntityId') ON DELETE Set Null ON UPDATE Cascade,
	CONSTRAINT 'FK_GrassCoverErosionInwardsOvertoppingRateOutputEntity_GrassCoverErosionInwardsOutputEntity' FOREIGN KEY ('GrassCoverErosionInwardsOutputEntityId') REFERENCES 'GrassCoverErosionInwardsOutputEntity' ('GrassCoverErosionInwardsOutputEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'U_GrassCoverErosionInwardsOutputEntity' UNIQUE ('GrassCoverErosionInwardsOutputEntityId')
)
;

CREATE TABLE 'GeneralResultSubMechanismIllustrationPointEntity'
(
	'GeneralResultSubMechanismIllustrationPointEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'GoverningWindDirectionName' TEXT NOT NULL,
	'GoverningWindDirectionAngle' REAL NOT NULL
)
;

CREATE TABLE 'SubMechanismIllustrationPointEntity'
(
	'SubMechanismIllustrationPointEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'Name' TEXT NOT NULL,
	'Beta' REAL NOT NULL,
	'Order' INT (4) NOT NULL
)
;

CREATE TABLE 'IllustrationPointResultEntity'
(
	'IllustrationPointResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'SubMechanismIllustrationPointEntityId' INTEGER NOT NULL,
	'Description' TEXT NOT NULL,
	'Value' REAL NOT NULL,
	'Order' INT (4) NOT NULL,
	CONSTRAINT 'FK_IllustrationPointResultEntity_SubMechanismIllustrationPointEntity' FOREIGN KEY ('SubMechanismIllustrationPointEntityId') REFERENCES 'SubMechanismIllustrationPointEntity' ('SubMechanismIllustrationPointEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'StochastEntity'
(
	'StochastEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'Name' TEXT NOT NULL,
	'Duration' REAL NOT NULL,
	'Alpha' REAL NOT NULL,
	'Order' INT (4) NOT NULL
)
;

CREATE TABLE 'GeneralResultSubMechanismIllustrationPointStochastEntity'
(
	'GeneralResultSubMechanismIllustrationPointEntityId' INTEGER NOT NULL,
	'StochastEntityId' INTEGER NOT NULL,
	CONSTRAINT 'PK_GeneralResultSubMechanismIllustrationPointStochastEntity' PRIMARY KEY ('GeneralResultSubMechanismIllustrationPointEntityId','StochastEntityId'),
	CONSTRAINT 'FK_GeneralResultSubMechanisIllustrationPointStochastEntity_GeneralResultSubMechanismIllustrationPointEntity' FOREIGN KEY ('GeneralResultSubMechanismIllustrationPointEntityId') REFERENCES 'GeneralResultSubMechanismIllustrationPointEntity' ('GeneralResultSubMechanismIllustrationPointEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'FK_GeneralResultSubMechanismIllustrationPointStochastEntity_StochastEntity' FOREIGN KEY ('StochastEntityId') REFERENCES 'StochastEntity' ('StochastEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'GeneralResultFaultTreeIllustrationPointEntity'
(
	'GeneralResultFaultTreeIllustrationPointEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'GoverningWindDirectionName' TEXT NOT NULL,
	'GoverningWindDirectionAngle' REAL NOT NULL
)
;

CREATE TABLE 'FaultTreeIllustrationPointEntity'
(
	'FaultTreeIllustrationPointEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'ParentFaultTreeIllustrationPointEntityId' INTEGER,
	'Name' TEXT NOT NULL,
	'Beta' REAL NOT NULL,
	'CombinationType' TINYINT (1) NOT NULL, -- Enum: 1 = Or, 2 = And
	'Order' INT (4) NOT NULL,
	CONSTRAINT 'FK_FaultTreeIllustrationPoint_FaultTreeIllustrationPoint' FOREIGN KEY ('ParentFaultTreeIllustrationPointEntityId') REFERENCES 'FaultTreeIllustrationPointEntity' ('FaultTreeIllustrationPointEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'FaultTreeIllustrationPointStochastEntity'
(
	'FaultTreeIllustrationPointEntityId' INTEGER NOT NULL,
	'StochastEntityId' INTEGER NOT NULL,
	CONSTRAINT 'PK_FaultTreeIllustrationPointStochastEntity' PRIMARY KEY ('FaultTreeIllustrationPointEntityId','StochastEntityId'),
	CONSTRAINT 'FK_FaultTreeIllustrationPointStochastEntity_FaultTreeIllustrationPoint' FOREIGN KEY ('FaultTreeIllustrationPointEntityId') REFERENCES 'FaultTreeIllustrationPointEntity' ('FaultTreeIllustrationPointEntityId') ON DELETE No Action ON UPDATE No Action,
	CONSTRAINT 'FK_FaultTreeIllustrationPointStochastEntity_StochastEntity' FOREIGN KEY ('StochastEntityId') REFERENCES 'StochastEntity' ('StochastEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'GeneralResultFaultTreeIllustrationPointStochastEntity'
(
	'GeneralResultFaultTreeIllustrationPointEntityId' INTEGER NOT NULL,
	'StochastEntityId' INTEGER NOT NULL,
	CONSTRAINT 'PK_GeneralResultFaultTreeIllustrationPointStochastEntity' PRIMARY KEY ('GeneralResultFaultTreeIllustrationPointEntityId','StochastEntityId'),
	CONSTRAINT 'FK_GeneralResultFaultTreeIllustrationPointStochastEntity_GeneralResultFaultTreeIllustrationPointEntity' FOREIGN KEY ('GeneralResultFaultTreeIllustrationPointEntityId') REFERENCES 'GeneralResultFaultTreeIllustrationPointEntity' ('GeneralResultFaultTreeIllustrationPointEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'FK_GeneralResultFaultTreeIllustrationPointStochastEntity_StochastEntity' FOREIGN KEY ('StochastEntityId') REFERENCES 'StochastEntity' ('StochastEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'TopLevelSubMechanismIllustrationPointEntity'
(
	'TopLevelSubMechanismIllustrationPointEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'GeneralResultSubMechanismIllustrationPointEntityId' INTEGER NOT NULL,
	'SubMechanismIllustrationPointEntityId' INTEGER NOT NULL,
	'ClosingSituation' TEXT NOT NULL,
	'WindDirectionName' TEXT NOT NULL,
	'WindDirectionAngle' REAL NOT NULL,
	'Order' INT (4) NOT NULL,
	CONSTRAINT 'FK_TopLevelSubMechanismIllustrationPointEntity_GeneralResultSubMechanismIllustrationPointEntity' FOREIGN KEY ('GeneralResultSubMechanismIllustrationPointEntityId') REFERENCES 'GeneralResultSubMechanismIllustrationPointEntity' ('GeneralResultSubMechanismIllustrationPointEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'FK_TopLevelSubMechanismIllustrationPointEntity_SubMechanismIllustrationPointEntity' FOREIGN KEY ('SubMechanismIllustrationPointEntityId') REFERENCES 'SubMechanismIllustrationPointEntity' ('SubMechanismIllustrationPointEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'TopLevelFaultTreeIllustrationPointEntity'
(
	'TopLevelFaultTreeIllustrationPointEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'FaultTreeIllustrationPointEntityId' INTEGER NOT NULL,
	'GeneralResultFaultTreeIllustrationPointEntityId' INTEGER NOT NULL,
	'ClosingSituation' TEXT NOT NULL,
	'WindDirectionName' TEXT NOT NULL,
	'WindDirectionAngle' REAL NOT NULL,
	'Order' INT (4) NOT NULL,
	CONSTRAINT 'FK_TopLevelFaultTreeIllustrationPointEntity_FaultTreeIllustrationPointEntity' FOREIGN KEY ('FaultTreeIllustrationPointEntityId') REFERENCES 'FaultTreeIllustrationPointEntity' ('FaultTreeIllustrationPointEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'FK_TopLevelFaultTreeIllustrationPointEntity_GeneralResultFaultTreeIllustrationPointEntity' FOREIGN KEY ('GeneralResultFaultTreeIllustrationPointEntityId') REFERENCES 'GeneralResultFaultTreeIllustrationPointEntity' ('GeneralResultFaultTreeIllustrationPointEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'SubMechanismIllustrationPointStochastEntity'
(
	'SubMechanismIllustrationPointStochastEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'SubMechanismIllustrationPointEntityId' INTEGER NOT NULL,
	'Name' TEXT NOT NULL,
	'Duration' REAL NOT NULL,
	'Alpha' REAL NOT NULL,
	'Realization' REAL NOT NULL,
	'Order' INT (4) NOT NULL,
	CONSTRAINT 'FK_SubMechanismIllustrationPointStochast_SubMechanismIllustrationPointEntity' FOREIGN KEY ('SubMechanismIllustrationPointEntityId') REFERENCES 'SubMechanismIllustrationPointEntity' ('SubMechanismIllustrationPointEntityId') ON DELETE No Action ON UPDATE No Action
)
;

CREATE TABLE 'FaultTreeSubmechanismIllustrationPointEntity'
(
	'SubMechanismIllustrationPointEntityId' INTEGER NOT NULL,
	'FaultTreeIllustrationPointEntityId' INTEGER NOT NULL,
	CONSTRAINT 'PK_FaultTreeSubMechanismIllustrationPointEntityId' PRIMARY KEY ('SubMechanismIllustrationPointEntityId','FaultTreeIllustrationPointEntityId'),
	CONSTRAINT 'FK_FaultTreeIllustrationPointEntity_FaultTreeIllustrationPointEntity' FOREIGN KEY ('FaultTreeIllustrationPointEntityId') REFERENCES 'FaultTreeIllustrationPointEntity' ('FaultTreeIllustrationPointEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'FK_FaultTreeIllustrationPointEntity_SubMechanismIllustrationPointEntity' FOREIGN KEY ('SubMechanismIllustrationPointEntityId') REFERENCES 'SubMechanismIllustrationPointEntity' ('SubMechanismIllustrationPointEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'MacroStabilityInwardsCalculationEntity'
(
	'MacroStabilityInwardsCalculationEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'CalculationGroupEntityId' INTEGER NOT NULL,
	'SurfaceLineEntityId' INTEGER,
	'MacroStabilityInwardsStochasticSoilProfileEntityId' INTEGER,
	'HydraulicLocationEntityId' INTEGER,
	'Order' INT (4) NOT NULL,
	'Name' VARCHAR (260),
	'Comment' TEXT,
	'RelevantForScenario' TINYINT (1) NOT NULL, -- true or false
	'ScenarioContribution' REAL,
	'AssessmentLevel' REAL,
	'UseAssessmentLevelManualInput' TINYINT (1) NOT NULL, -- true or false
	'SlipPlaneMinimumDepth' REAL,
	'SlipPlaneMinimumLength' REAL,
	'MaximumSliceWidth' REAL,
	'MoveGrid' TINYINT (1) NOT NULL, -- true or false
	'GridDeterminationType' TINYINT (1) NOT NULL, -- Enumtype: 1 = Automatic, 2 = Manual
	'TangentLineDeterminationType' TINYINT (1) NOT NULL, -- Enumtype: 1 = Specified, 2 = LayerSeparated
	'TangentLineZTop' REAL,
	'TangentLineZBottom' REAL,
	'TangentLineNumber' INT (4) NOT NULL,
	'LeftGridXLeft' REAL,
	'LeftGridXRight' REAL,
	'LeftGridNrOfHorizontalPoints' INT (4) NOT NULL,
	'LeftGridZTop' REAL,
	'LeftGridZBottom' REAL,
	'LeftGridNrOfVerticalPoints' INT (4) NOT NULL,
	'RightGridXLeft' REAL,
	'RightGridXRight' REAL,
	'RightGridNrOfHorizontalPoints' INT (4) NOT NULL,
	'RightGridZTop' REAL,
	'RightGridZBottom' REAL,
	'RightGridNrOfVerticalPoints' INT (4) NOT NULL,
	'DikeSoilScenario' TINYINT (1) NOT NULL, -- Enumtype: 1 = ClayDikeOnClay, 2 = SandDikeOnClay, 3 = ClayDikeOnSand, 4 = SandDikeOnSand
	'WaterLevelRiverAverage' REAL,
	'DrainageConstructionPresent' TINYINT (1) NOT NULL, -- true or false
	'DrainageConstructionCoordinateX' REAL,
	'DrainageConstructionCoordinateZ' REAL,
	'MinimumLevelPhreaticLineAtDikeTopRiver' REAL,
	'MinimumLevelPhreaticLineAtDikeTopPolder' REAL,
	'AdjustPhreaticLine3And4ForUplift' TINYINT (1) NOT NULL, -- true or false
	'LeakageLengthOutwardsPhreaticLine3' REAL,
	'LeakageLengthInwardsPhreaticLine3' REAL,
	'LeakageLengthOutwardsPhreaticLine4' REAL,
	'LeakageLengthInwardsPhreaticLine4' REAL,
	'PiezometricHeadPhreaticLine2Outwards' REAL,
	'PiezometricHeadPhreaticLine2Inwards' REAL,
	'LocationInputExtremeWaterLevelPolder' REAL,
	'LocationInputExtremeUseDefaultOffsets' TINYINT (1) NOT NULL, -- true or false
	'LocationInputExtremePhreaticLineOffsetBelowDikeTopAtRiver' REAL,
	'LocationInputExtremePhreaticLineOffsetBelowDikeTopAtPolder' REAL,
	'LocationInputExtremePhreaticLineOffsetBelowShoulderBaseInside' REAL,
	'LocationInputExtremePhreaticLineOffsetDikeToeAtPolder' REAL,
	'LocationInputExtremePenetrationLength' REAL,
	'LocationInputDailyWaterLevelPolder' REAL,
	'LocationInputDailyUseDefaultOffsets' TINYINT (1) NOT NULL, -- true or false
	'LocationInputDailyPhreaticLineOffsetBelowDikeTopAtRiver' REAL,
	'LocationInputDailyPhreaticLineOffsetBelowDikeTopAtPolder' REAL,
	'LocationInputDailyPhreaticLineOffsetBelowShoulderBaseInside' REAL,
	'LocationInputDailyPhreaticLineOffsetDikeToeAtPolder' REAL,
	'CreateZones' TINYINT (1) NOT NULL, -- true or false
	'ZoningBoundariesDeterminationType' TINYINT (1) NOT NULL, -- Enumtype: 1 = Automatic 2 = Manual
	'ZoneBoundaryLeft' REAL,
	'ZoneBoundaryRight' REAL,
	CONSTRAINT 'FK_MacroStabilityInwardsCalculationEntity_CalculationGroupEntity' FOREIGN KEY ('CalculationGroupEntityId') REFERENCES 'CalculationGroupEntity' ('CalculationGroupEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'FK_MacroStabilityInwardsCalculationEntity_HydraulicLocationEntity' FOREIGN KEY ('HydraulicLocationEntityId') REFERENCES 'HydraulicLocationEntity' ('HydraulicLocationEntityId') ON DELETE Set Null ON UPDATE Cascade,
	CONSTRAINT 'FK_MacroStabilityInwardsCalculationEntity_MacroStabilityInwardsStochasticSoilProfileEntity' FOREIGN KEY ('MacroStabilityInwardsStochasticSoilProfileEntityId') REFERENCES 'MacroStabilityInwardsStochasticSoilProfileEntity' ('MacroStabilityInwardsStochasticSoilProfileEntityId') ON DELETE Set Null ON UPDATE Cascade,
	CONSTRAINT 'FK_MacroStabilityInwardsCalculationEntity_SurfaceLineEntity' FOREIGN KEY ('SurfaceLineEntityId') REFERENCES 'SurfaceLineEntity' ('SurfaceLineEntityId') ON DELETE Set Null ON UPDATE Cascade
)
;

CREATE TABLE 'MacroStabilityInwardsCalculationOutputEntity'
(
	'MacroStabilityInwardsCalculationOutputEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'MacroStabilityInwardsCalculationEntityId' INTEGER NOT NULL,
	'FactorOfStability' REAL,
	'ZValue' REAL,
	'ForbiddenZonesXEntryMin' REAL,
	'ForbiddenZonesXEntryMax' REAL,
	'SlidingCurveLeftSlidingCircleCenterX' REAL,
	'SlidingCurveLeftSlidingCircleCenterY' REAL,
	'SlidingCurveLeftSlidingCircleRadius' REAL,
	'SlidingCurveLeftSlidingCircleIsActive' TINYINT (1) NOT NULL, -- true or false
	'SlidingCurveLeftSlidingCircleNonIteratedForce' REAL,
	'SlidingCurveLeftSlidingCircleIteratedForce' REAL,
	'SlidingCurveLeftSlidingCircleDrivingMoment' REAL,
	'SlidingCurveLeftSlidingCircleResistingMoment' REAL,
	'SlidingCurveRightSlidingCircleCenterX' REAL,
	'SlidingCurveRightSlidingCircleCenterY' REAL,
	'SlidingCurveRightSlidingCircleRadius' REAL,
	'SlidingCurveRightSlidingCircleIsActive' TINYINT (1) NOT NULL, -- true or false
	'SlidingCurveRightSlidingCircleNonIteratedForce' REAL,
	'SlidingCurveRightSlidingCircleIteratedForce' REAL,
	'SlidingCurveRightSlidingCircleDrivingMoment' REAL,
	'SlidingCurveRightSlidingCircleResistingMoment' REAL,
	'SlidingCurveNonIteratedHorizontalForce' REAL,
	'SlidingCurveIteratedHorizontalForce' REAL,
	'SlidingCurveSliceXML' TEXT NOT NULL, -- XML representation of MacroStabilityInwardsSlice
	'SlipPlaneLeftGridXLeft' REAL,
	'SlipPlaneLeftGridXRight' REAL,
	'SlipPlaneLeftGridNrOfHorizontalPoints' INT (4) NOT NULL,
	'SlipPlaneLeftGridZTop' REAL,
	'SlipPlaneLeftGridZBottom' REAL,
	'SlipPlaneLeftGridNrOfVerticalPoints' INT (4) NOT NULL,
	'SlipPlaneRightGridXLeft' REAL,
	'SlipPlaneRightGridXRight' REAL,
	'SlipPlaneRightGridNrOfHorizontalPoints' INT (4) NOT NULL,
	'SlipPlaneRightGridZTop' REAL,
	'SlipPlaneRightGridZBottom' REAL,
	'SlipPlaneRightGridNrOfVerticalPoints' INT (4) NOT NULL,
	'SlipPlaneTangentLinesXml' TEXT NOT NULL, -- XML representation of TangentLines
	CONSTRAINT 'FK_MacroStabilityInwardsCalculationOutput_MacroStabilityInwardsCalculationEntity' FOREIGN KEY ('MacroStabilityInwardsCalculationEntityId') REFERENCES 'MacroStabilityInwardsCalculationEntity' ('MacroStabilityInwardsCalculationEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'MacroStabilityInwardsCharacteristicPointEntity'
(
	'MacroStabilityInwardsCharacteristicPointEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'SurfaceLineEntityId' INTEGER NOT NULL,
	'Type' SMALLINT NOT NULL, -- Enumtype: 1 = SurfaceLevelOutside 2 = DikeTopAtRiver 3 = DikeToeAtRiver 4 = DikeTopAtPolder 5 = ShoulderBaseInside 6 = ShoulderTopInside 7 = DikeToeAtPolder 8 = DitchDikeSide 9 = BottomDitchDikeSide 10 = BottomDitchPolderSide 11 = DitchPolderSide 12 = SurfaceLevelInside
	'X' REAL,
	'Y' REAL,
	'Z' REAL,
	CONSTRAINT 'FK_MacroStabilityInwardsCharacteristicPointEntity_SurfaceLineEntity' FOREIGN KEY ('SurfaceLineEntityId') REFERENCES 'SurfaceLineEntity' ('SurfaceLineEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'MacroStabilityInwardsSoilLayerOneDEntity'
(
	'MacroStabilityInwardsSoilLayerOneDEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'MacroStabilityInwardsSoilProfileOneDEntityId' INTEGER NOT NULL,
	'Top' REAL,
	'IsAquifer' TINYINT (1) NOT NULL, -- true or false
	'Color' INTEGER, -- ARGB value of Color.
	'MaterialName' TEXT NOT NULL,
	'ShearStrengthModel' TINYINT (1) NOT NULL, -- Enumtype: 1 = SuCalculated, 2 = CPhi, 3 = CPhiOrSuCalculated
	'UsePop' TINYINT (1) NOT NULL, -- true of false
	'AbovePhreaticLevelMean' REAL,
	'AbovePhreaticLevelCoefficientOfVariation' REAL,
	'AbovePhreaticLevelShift' REAL,
	'BelowPhreaticLevelMean' REAL,
	'BelowPhreaticLevelCoefficientOfVariation' REAL,
	'BelowPhreaticLevelShift' REAL,
	'CohesionMean' REAL,
	'CohesionCoefficientOfVariation' REAL,
	'FrictionAngleMean' REAL,
	'FrictionAngleCoefficientOfVariation' REAL,
	'ShearStrengthRatioMean' REAL,
	'ShearStrengthRatioCoefficientOfVariation' REAL,
	'StrengthIncreaseExponentMean' REAL,
	'StrengthIncreaseExponentCoefficientOfVariation' REAL,
	'PopMean' REAL,
	'PopCoefficientOfVariation' REAL,
	'Order' INT (4) NOT NULL,
	CONSTRAINT 'FK_MacroStabilityInwardsSoilLayerOneDEntity_MacroStabilityInwardsSoilProfileOneDEntity' FOREIGN KEY ('MacroStabilityInwardsSoilProfileOneDEntityId') REFERENCES 'MacroStabilityInwardsSoilProfileOneDEntity' ('MacroStabilityInwardsSoilProfileOneDEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'MacroStabilityInwardsSoilProfileOneDEntity'
(
	'MacroStabilityInwardsSoilProfileOneDEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'Name' TEXT NOT NULL,
	'Bottom' REAL
)
;

CREATE TABLE 'MacroStabilityInwardsSoilLayerTwoDEntity'
(
	'MacroStabilityInwardsSoilLayerTwoDEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'ParentMacroStabilityInwardsSoilLayerTwoDEntityId' INTEGER,
	'IsAquifer' TINYINT (1) NOT NULL, -- true or false
	'Color' INTEGER, -- ARGB value of Color.
	'MaterialName' TEXT NOT NULL,
	'ShearStrengthModel' TINYINT (1) NOT NULL, -- Enumtype: 1 = SuCalculated, 2 = CPhi, 3 = CPhiOrSuCalculated
	'UsePop' TINYINT (1) NOT NULL, -- true of false
	'AbovePhreaticLevelMean' REAL,
	'AbovePhreaticLevelCoefficientOfVariation' REAL,
	'AbovePhreaticLevelShift' REAL,
	'BelowPhreaticLevelMean' REAL,
	'BelowPhreaticLevelCoefficientOfVariation' REAL,
	'BelowPhreaticLevelShift' REAL,
	'CohesionMean' REAL,
	'CohesionCoefficientOfVariation' REAL,
	'FrictionAngleMean' REAL,
	'FrictionAngleCoefficientOfVariation' REAL,
	'ShearStrengthRatioMean' REAL,
	'ShearStrengthRatioCoefficientOfVariation' REAL,
	'StrengthIncreaseExponentMean' REAL,
	'StrengthIncreaseExponentCoefficientOfVariation' REAL,
	'PopMean' REAL,
	'PopCoefficientOfVariation' REAL,
	'OuterRingXml' TEXT NOT NULL,
	'Order' INT (4) NOT NULL,
	CONSTRAINT 'FK_MacroStabilityInwardsSoilLayerTwoDEntity_MacroStabilityInwardsSoilLayerTwoDEntity' FOREIGN KEY ('ParentMacroStabilityInwardsSoilLayerTwoDEntityId') REFERENCES 'MacroStabilityInwardsSoilLayerTwoDEntity' ('MacroStabilityInwardsSoilLayerTwoDEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'MacroStabilityInwardsSoilProfileTwoDEntity'
(
	'MacroStabilityInwardsSoilProfileTwoDEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'Name' TEXT NOT NULL
)
;

CREATE TABLE 'MacroStabilityInwardsStochasticSoilProfileEntity'
(
	'MacroStabilityInwardsStochasticSoilProfileEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'StochasticSoilModelEntityId' INTEGER NOT NULL,
	'MacroStabilityInwardsSoilProfileOneDEntityId' INTEGER,
	'MacroStabilityInwardsSoilProfileTwoDEntityId' INTEGER,
	'Probability' REAL NOT NULL,
	'Order' INT (4) NOT NULL,
	CONSTRAINT 'FK_MacroStabilityInwardsStochasticSoilProfileEntity_MacroStabilityInwardsSoilProfileOneDEntity' FOREIGN KEY ('MacroStabilityInwardsSoilProfileOneDEntityId') REFERENCES 'MacroStabilityInwardsSoilProfileOneDEntity' ('MacroStabilityInwardsSoilProfileOneDEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'FK_MacroStabilityInwardsStochasticSoilProfileEntity_MacroStabilityInwardsSoilProfileTwoDEntity' FOREIGN KEY ('MacroStabilityInwardsSoilProfileTwoDEntityId') REFERENCES 'MacroStabilityInwardsSoilProfileTwoDEntity' ('MacroStabilityInwardsSoilProfileTwoDEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'FK_MacroStabilityInwardsStochasticSoilProfileEntity_StochasticSoilModelEntity' FOREIGN KEY ('StochasticSoilModelEntityId') REFERENCES 'StochasticSoilModelEntity' ('StochasticSoilModelEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'MacroStabilityInwardsPreconsolidationStressEntity'
(
	'MacroStabilityInwardsPreconsolidationStressEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'MacroStabilityInwardsSoilProfileTwoDEntityId' INTEGER NOT NULL,
	'CoordinateX' REAL NOT NULL,
	'CoordinateZ' REAL NOT NULL,
	'PreconsolidationStressMean' REAL,
	'PreconsolidationStressCoefficientOfVariation' REAL,
	'Order' INT (4) NOT NULL,
	CONSTRAINT 'FK_MacroStabilityInwardsPreconsolidationStressEntity_MacroStabilityInwardsSoilProfileTwoDEntity' FOREIGN KEY ('MacroStabilityInwardsSoilProfileTwoDEntityId') REFERENCES 'MacroStabilityInwardsSoilProfileTwoDEntity' ('MacroStabilityInwardsSoilProfileTwoDEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'MacroStabilityInwardsSoilProfileTwoDSoilLayerTwoDEntity'
(
	'MacroStabilityInwardsSoilProfileTwoDEntityId' INTEGER NOT NULL,
	'MacroStabilityInwardsSoilLayerTwoDEntityId' INTEGER NOT NULL,
	CONSTRAINT 'PK_MacroStabilityInwardsSoilProfileTwoDSoilLayerTwoDEntity' PRIMARY KEY ('MacroStabilityInwardsSoilProfileTwoDEntityId','MacroStabilityInwardsSoilLayerTwoDEntityId'),
	CONSTRAINT 'FK_MacroStabilityInwardsSoilProfileTwoDSoilLayerTwoDEntity_MacroStabilityInwardsSoilLayerTwoDEntity' FOREIGN KEY ('MacroStabilityInwardsSoilLayerTwoDEntityId') REFERENCES 'MacroStabilityInwardsSoilLayerTwoDEntity' ('MacroStabilityInwardsSoilLayerTwoDEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'FK_MacroStabilityInwardsSoilProfileTwoDSoilLayerTwoDEntity_MacroStabilityInwardsSoilProfileTwoDEntity' FOREIGN KEY ('MacroStabilityInwardsSoilProfileTwoDEntityId') REFERENCES 'MacroStabilityInwardsSoilProfileTwoDEntity' ('MacroStabilityInwardsSoilProfileTwoDEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'HydraulicLocationCalculationEntity'
(
	'HydraulicLocationCalculationEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'HydraulicLocationEntityId' INTEGER NOT NULL,
	'HydraulicLocationCalculationCollectionEntityId' INTEGER NOT NULL,
	'ShouldIllustrationPointsBeCalculated' TINYINT (1) NOT NULL, -- True or false
	CONSTRAINT 'FK_HydraulicLocationCalculationEntity_HydraulicLocationCalculationCollectionEntity' FOREIGN KEY ('HydraulicLocationCalculationCollectionEntityId') REFERENCES 'HydraulicLocationCalculationCollectionEntity' ('HydraulicLocationCalculationCollectionEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'FK_HydraulicLocationCalculationEntity_HydraulicLocationEntity' FOREIGN KEY ('HydraulicLocationEntityId') REFERENCES 'HydraulicLocationEntity' ('HydraulicLocationEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'HydraulicLocationCalculationCollectionEntity'
(
	'HydraulicLocationCalculationCollectionEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT
)
;

CREATE TABLE 'DuneLocationCalculationCollectionEntity'
(
	'DuneLocationCalculationCollectionEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT
)
;

CREATE TABLE 'DuneLocationCalculationEntity'
(
	'DuneLocationCalculationEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'DuneLocationEntityId' INTEGER,
	'DuneLocationCalculationCollectionEntityId' INTEGER,
	CONSTRAINT 'FK_DuneLocationCalculationEntity_DuneLocationCalculationCollectionEntity' FOREIGN KEY ('DuneLocationCalculationCollectionEntityId') REFERENCES 'DuneLocationCalculationCollectionEntity' ('DuneLocationCalculationCollectionEntityId') ON DELETE Cascade ON UPDATE Cascade,
	CONSTRAINT 'FK_DuneLocationCalculationEntity_DuneLocationEntity' FOREIGN KEY ('DuneLocationEntityId') REFERENCES 'DuneLocationEntity' ('DuneLocationEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

CREATE TABLE 'HydraulicBoundaryDatabaseEntity'
(
	'HydraulicBoundaryDatabaseEntity' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	'AssessmentSectionEntityId' INTEGER NOT NULL,
	'HydraulicBoundaryDatabaseVersion' TEXT NOT NULL,
	'HydraulicBoundaryDatabaseFilePath' TEXT NOT NULL,
	'HydraulicLocationConfigurationSettingsFilePath' TEXT NOT NULL,
	'HydraulicLocationConfigurationSettingsScenarioName' TEXT NOT NULL,
	'HydraulicLocationConfigurationSettingsYear' INT (4) NOT NULL,
	'HydraulicLocationConfigurationSettingsScope' TEXT NOT NULL,
	'HydraulicLocationConfigurationSettingsSeaLevel' TEXT,
	'HydraulicLocationConfigurationSettingsRiverDischarge' TEXT,
	'HydraulicLocationConfigurationSettingsLakeLevel' TEXT,
	'HydraulicLocationConfigurationSettingsWindDirection' TEXT,
	'HydraulicLocationConfigurationSettingsWindSpeed' TEXT,
	'HydraulicLocationConfigurationSettingsComment' TEXT,
	CONSTRAINT 'FK_HydraulicBoundaryDatabaseEntity_AssessmentSectionEntity' FOREIGN KEY ('AssessmentSectionEntityId') REFERENCES 'AssessmentSectionEntity' ('AssessmentSectionEntityId') ON DELETE Cascade ON UPDATE Cascade
)
;

/* Create Indexes and Triggers */

CREATE INDEX 'IXFK_GrassCoverErosionInwardsDikeHeightOutputEntity_GeneralResultFaultTreeIllustrationPointEntity'
 ON 'GrassCoverErosionInwardsDikeHeightOutputEntity' ('GeneralResultFaultTreeIllustrationPointEntityId' ASC)
;

CREATE INDEX 'IXFK_GrassCoverErosionInwardsDikeHeightOutputEntity_GrassCoverErosionInwardsOutputEntity'
 ON 'GrassCoverErosionInwardsDikeHeightOutputEntity' ('GrassCoverErosionInwardsOutputEntityId' ASC)
;
CREATE TRIGGER [TR_AfterDeleteGrassCoverErosionInwardsDikeHeightOutputEntity_RemoveGeneralResultFaultTreeIllustrationPointEntity]
	AFTER DELETE
	ON GrassCoverErosionInwardsDikeHeightOutputEntity
	FOR EACH ROW
BEGIN
	DELETE
	FROM GeneralResultFaultTreeIllustrationPointEntity
	WHERE OLD.GeneralResultFaultTreeIllustrationPointEntityId IS NOT NULL 
	AND GeneralResultFaultTreeIllustrationPointEntityId IS OLD.GeneralResultFaultTreeIllustrationPointEntityId;
END; 
;

CREATE INDEX 'IXFK_MacroStabilityInwardsFailureMechanismMetaEntity_FailureMechanismEntity'
 ON 'MacroStabilityInwardsFailureMechanismMetaEntity' ('FailureMechanismEntityId' ASC)
;

CREATE INDEX 'IXFK_AssessmentSectionEntity_HydraulicLocationCalculationCollectionEntity1'
 ON 'AssessmentSectionEntity' ('HydraulicLocationCalculationCollectionEntity1Id' ASC)
;

CREATE INDEX 'IXFK_AssessmentSectionEntity_HydraulicLocationCalculationCollectionEntity2'
 ON 'AssessmentSectionEntity' ('HydraulicLocationCalculationCollectionEntity2Id' ASC)
;

CREATE INDEX 'IXFK_AssessmentSectionEntity_HydraulicLocationCalculationCollectionEntity3'
 ON 'AssessmentSectionEntity' ('HydraulicLocationCalculationCollectionEntity3Id' ASC)
;

CREATE INDEX 'IXFK_AssessmentSectionEntity_HydraulicLocationCalculationCollectionEntity4'
 ON 'AssessmentSectionEntity' ('HydraulicLocationCalculationCollectionEntity4Id' ASC)
;

CREATE INDEX 'IXFK_AssessmentSectionEntity_HydraulicLocationCalculationCollectionEntity5'
 ON 'AssessmentSectionEntity' ('HydraulicLocationCalculationCollectionEntity5Id' ASC)
;

CREATE INDEX 'IXFK_AssessmentSectionEntity_HydraulicLocationCalculationCollectionEntity6'
 ON 'AssessmentSectionEntity' ('HydraulicLocationCalculationCollectionEntity6Id' ASC)
;

CREATE INDEX 'IXFK_AssessmentSectionEntity_HydraulicLocationCalculationCollectionEntity7'
 ON 'AssessmentSectionEntity' ('HydraulicLocationCalculationCollectionEntity7Id' ASC)
;

CREATE INDEX 'IXFK_AssessmentSectionEntity_HydraulicLocationCalculationCollectionEntity8'
 ON 'AssessmentSectionEntity' ('HydraulicLocationCalculationCollectionEntity8Id' ASC)
;

CREATE INDEX 'IXFK_AssessmentSectionEntity_ProjectEntity'
 ON 'AssessmentSectionEntity' ('ProjectEntityId' ASC)
;
CREATE TRIGGER [TR_AfterDeleteAssessmentSectionEntity_RemoveHydraulicLocationCalculationCollectionEntities]
	AFTER DELETE
	ON AssessmentSectionEntity
	FOR EACH ROW
BEGIN
	DELETE 
	FROM HydraulicLocationCalculationCollectionEntity
	WHERE HydraulicLocationCalculationCollectionEntityId IS OLD.HydraulicLocationCalculationCollectionEntity1Id
	OR HydraulicLocationCalculationCollectionEntityId IS OLD.HydraulicLocationCalculationCollectionEntity2Id
	OR HydraulicLocationCalculationCollectionEntityId IS OLD.HydraulicLocationCalculationCollectionEntity3Id
	OR HydraulicLocationCalculationCollectionEntityId IS OLD.HydraulicLocationCalculationCollectionEntity4Id
	OR HydraulicLocationCalculationCollectionEntityId IS OLD.HydraulicLocationCalculationCollectionEntity5Id
	OR HydraulicLocationCalculationCollectionEntityId IS OLD.HydraulicLocationCalculationCollectionEntity6Id
	OR HydraulicLocationCalculationCollectionEntityId IS OLD.HydraulicLocationCalculationCollectionEntity7Id
	OR HydraulicLocationCalculationCollectionEntityId IS OLD.HydraulicLocationCalculationCollectionEntity8Id;
END; 
;

CREATE INDEX 'IXFK_MacroStabilityOutwardsFailureMechanismMetaEntity_FailureMechanismEntity'
 ON 'MacroStabilityOutwardsFailureMechanismMetaEntity' ('FailureMechanismEntityId' ASC)
;

CREATE INDEX 'IXFK_FailureMechanismSectionEntity_FailureMechanismEntity'
 ON 'FailureMechanismSectionEntity' ('FailureMechanismEntityId' ASC)
;

CREATE INDEX 'IXFK_FailureMechanismEntity_AssessmentSectionEntity'
 ON 'FailureMechanismEntity' ('AssessmentSectionEntityId' ASC)
;

CREATE INDEX 'IXFK_FailureMechanismEntity_CalculationGroupEntity'
 ON 'FailureMechanismEntity' ('CalculationGroupEntityId' ASC)
;

CREATE INDEX 'IXFK_StabilityPointStructuresCalculationEntity_CalculationGroupEntity'
 ON 'StabilityPointStructuresCalculationEntity' ('CalculationGroupEntityId' ASC)
;

CREATE INDEX 'IXFK_StabilityPointStructuresCalculationEntity_ForeshoreProfileEntity'
 ON 'StabilityPointStructuresCalculationEntity' ('ForeshoreProfileEntityId' ASC)
;

CREATE INDEX 'IXFK_StabilityPointStructuresCalculationEntity_HydraulicLocationEntity'
 ON 'StabilityPointStructuresCalculationEntity' ('HydraulicLocationEntityId' ASC)
;

CREATE INDEX 'IXFK_StabilityPointStructuresCalculationEntity_StabilityPointStructureEntity'
 ON 'StabilityPointStructuresCalculationEntity' ('StabilityPointStructureEntityId' ASC)
;

CREATE INDEX 'IXFK_ClosingStructuresFailureMechanismMetaEntity_FailureMechanismEntity'
 ON 'ClosingStructuresFailureMechanismMetaEntity' ('FailureMechanismEntityId' ASC)
;

CREATE INDEX 'IXFK_PipingFailureMechanismMetaEntity_FailureMechanismEntity'
 ON 'PipingFailureMechanismMetaEntity' ('FailureMechanismEntityId' ASC)
;

CREATE INDEX 'IXFK_StabilityStoneCoverFailureMechanismMetaEntity_FailureMechanismEntity'
 ON 'StabilityStoneCoverFailureMechanismMetaEntity' ('FailureMechanismEntityId' ASC)
;

CREATE INDEX 'IXFK_CalculationGroupEntity_CalculationGroupEntity'
 ON 'CalculationGroupEntity' ('ParentCalculationGroupEntityId' ASC)
;

CREATE INDEX 'IXFK_HydraulicLocationEntity_AssessmentSectionEntity'
 ON 'HydraulicLocationEntity' ('AssessmentSectionEntityId' ASC)
;

CREATE INDEX 'IXFK_PipingCalculationEntity_PipingStochasticSoilProfileEntity'
 ON 'PipingCalculationEntity' ('PipingStochasticSoilProfileEntityId' ASC)
;

CREATE INDEX 'IXFK_PipingCalculationEntity_SurfaceLineEntity'
 ON 'PipingCalculationEntity' ('SurfaceLineEntityId' ASC)
;

CREATE INDEX 'IXFK_PipingCalculationEntity_HydraulicLocationEntity'
 ON 'PipingCalculationEntity' ('HydraulicLocationEntityId' ASC)
;

CREATE INDEX 'IXFK_PipingCalculationEntity_CalculationGroupEntity'
 ON 'PipingCalculationEntity' ('CalculationGroupEntityId' ASC)
;

CREATE INDEX 'IXFK_GrassCoverErosionInwardsFailureMechanismMetaEntity_FailureMechanismEntity'
 ON 'GrassCoverErosionInwardsFailureMechanismMetaEntity' ('FailureMechanismEntityId' ASC)
;

CREATE INDEX 'IXFK_StrengthStabilityPointConstructionFailureMechanismMetaEntity_FailureMechanismEntity'
 ON 'StabilityPointStructuresFailureMechanismMetaEntity' ('FailureMechanismEntityId' ASC)
;

CREATE INDEX 'IXFK_GrassCoverErosionInwardsCalculationEntity_CalculationGroupEntity'
 ON 'GrassCoverErosionInwardsCalculationEntity' ('CalculationGroupEntityId' ASC)
;

CREATE INDEX 'IXFK_GrassCoverErosionInwardsCalculationEntity_DikeProfileEntity'
 ON 'GrassCoverErosionInwardsCalculationEntity' ('DikeProfileEntityId' ASC)
;

CREATE INDEX 'IXFK_GrassCoverErosionInwardsCalculationEntity_HydraulicLocationEntity'
 ON 'GrassCoverErosionInwardsCalculationEntity' ('HydraulicLocationEntityId' ASC)
;

CREATE INDEX 'IXFK_DuneErosionFailureMechanismMetaEntity_DuneLocationCalculationCollectionEntity1'
 ON 'DuneErosionFailureMechanismMetaEntity' ('DuneLocationCalculationCollectionEntity1Id' ASC)
;

CREATE INDEX 'IXFK_DuneErosionFailureMechanismMetaEntity_DuneLocationCalculationCollectionEntity2'
 ON 'DuneErosionFailureMechanismMetaEntity' ('DuneLocationCalculationCollectionEntity2Id' ASC)
;

CREATE INDEX 'IXFK_DuneErosionFailureMechanismMetaEntity_DuneLocationCalculationCollectionEntity3'
 ON 'DuneErosionFailureMechanismMetaEntity' ('DuneLocationCalculationCollectionEntity3Id' ASC)
;

CREATE INDEX 'IXFK_DuneErosionFailureMechanismMetaEntity_DuneLocationCalculationCollectionEntity4'
 ON 'DuneErosionFailureMechanismMetaEntity' ('DuneLocationCalculationCollectionEntity4Id' ASC)
;

CREATE INDEX 'IXFK_DuneErosionFailureMechanismMetaEntity_DuneLocationCalculationCollectionEntity5'
 ON 'DuneErosionFailureMechanismMetaEntity' ('DuneLocationCalculationCollectionEntity5Id' ASC)
;

CREATE INDEX 'IXFK_DuneErosionFailureMechanismMetaEntity_FailureMechanismEntity'
 ON 'DuneErosionFailureMechanismMetaEntity' ('FailureMechanismEntityId' ASC)
;
CREATE TRIGGER [TR_AfterDeleteDuneErosionFailureMechanismMetaEntity_RemoveDuneLocationCalculationCollectionEntities]
	AFTER DELETE
	ON DuneErosionFailureMechanismMetaEntity
	FOR EACH ROW
BEGIN
	DELETE 
	FROM DuneLocationCalculationCollectionEntity
	WHERE DuneLocationCalculationCollectionEntityId IS OLD.DuneLocationCalculationCollectionEntity1Id
	OR DuneLocationCalculationCollectionEntityId IS OLD.DuneLocationCalculationCollectionEntity2Id
	OR DuneLocationCalculationCollectionEntityId IS OLD.DuneLocationCalculationCollectionEntity3Id
	OR DuneLocationCalculationCollectionEntityId IS OLD.DuneLocationCalculationCollectionEntity4Id
	OR DuneLocationCalculationCollectionEntityId IS OLD.DuneLocationCalculationCollectionEntity5Id;
END; 
;

CREATE INDEX 'IXFK_GrassCoverErosionOutwardsFailureMechanismMetaEntity_FailureMechanismEntity'
 ON 'GrassCoverErosionOutwardsFailureMechanismMetaEntity' ('FailureMechanismEntityId' ASC)
;

CREATE INDEX 'IXFK_GrassCoverErosionOutwardsFailureMechanismMetaEntity_HydraulicLocationCalculationCollectionEntity1'
 ON 'GrassCoverErosionOutwardsFailureMechanismMetaEntity' ('HydraulicLocationCalculationCollectionEntity1Id' ASC)
;

CREATE INDEX 'IXFK_GrassCoverErosionOutwardsFailureMechanismMetaEntity_HydraulicLocationCalculationCollectionEntity2'
 ON 'GrassCoverErosionOutwardsFailureMechanismMetaEntity' ('HydraulicLocationCalculationCollectionEntity2Id' ASC)
;

CREATE INDEX 'IXFK_GrassCoverErosionOutwardsFailureMechanismMetaEntity_HydraulicLocationCalculationCollectionEntity3'
 ON 'GrassCoverErosionOutwardsFailureMechanismMetaEntity' ('HydraulicLocationCalculationCollectionEntity3Id' ASC)
;

CREATE INDEX 'IXFK_GrassCoverErosionOutwardsFailureMechanismMetaEntity_HydraulicLocationCalculationCollectionEntity4'
 ON 'GrassCoverErosionOutwardsFailureMechanismMetaEntity' ('HydraulicLocationCalculationCollectionEntity4Id' ASC)
;

CREATE INDEX 'IXFK_GrassCoverErosionOutwardsFailureMechanismMetaEntity_HydraulicLocationCalculationCollectionEntity5'
 ON 'GrassCoverErosionOutwardsFailureMechanismMetaEntity' ('HydraulicLocationCalculationCollectionEntity5Id' ASC)
;

CREATE INDEX 'IXFK_GrassCoverErosionOutwardsFailureMechanismMetaEntity_HydraulicLocationCalculationCollectionEntity6'
 ON 'GrassCoverErosionOutwardsFailureMechanismMetaEntity' ('HydraulicLocationCalculationCollectionEntity6Id' ASC)
;
CREATE TRIGGER [TR_AfterDeleteGrassCoverErosionOutwardsFailureMechanismMetaEntity_RemoveHydraulicLocationCalculationCollectionEntities]
	AFTER DELETE
	ON GrassCoverErosionOutwardsFailureMechanismMetaEntity
	FOR EACH ROW
BEGIN
	DELETE 
	FROM HydraulicLocationCalculationCollectionEntity
	WHERE HydraulicLocationCalculationCollectionEntityId IS OLD.HydraulicLocationCalculationCollectionEntity1Id
	OR HydraulicLocationCalculationCollectionEntityId IS OLD.HydraulicLocationCalculationCollectionEntity2Id
	OR HydraulicLocationCalculationCollectionEntityId IS OLD.HydraulicLocationCalculationCollectionEntity3Id
	OR HydraulicLocationCalculationCollectionEntityId IS OLD.HydraulicLocationCalculationCollectionEntity4Id
	OR HydraulicLocationCalculationCollectionEntityId IS OLD.HydraulicLocationCalculationCollectionEntity5Id
	OR HydraulicLocationCalculationCollectionEntityId IS OLD.HydraulicLocationCalculationCollectionEntity6Id
	OR HydraulicLocationCalculationCollectionEntityId IS OLD.HydraulicLocationCalculationCollectionEntity7Id
	OR HydraulicLocationCalculationCollectionEntityId IS OLD.HydraulicLocationCalculationCollectionEntity8Id;
END; 
;

CREATE INDEX 'IXFK_HeightStructuresFailureMechanismMetaEntity_FailureMechanismEntity'
 ON 'HeightStructuresFailureMechanismMetaEntity' ('FailureMechanismEntityId' ASC)
;

CREATE INDEX 'IXFK_PipingStochasticSoilProfileEntity_SoilProfileEntity'
 ON 'PipingStochasticSoilProfileEntity' ('PipingSoilProfileEntityId' ASC)
;

CREATE INDEX 'IXFK_PipingStochasticSoilProfileEntity_StochasticSoilModelEntity'
 ON 'PipingStochasticSoilProfileEntity' ('StochasticSoilModelEntityId' ASC)
;

CREATE INDEX 'IXFK_StochasticSoilModelEntity_FailureMechanismEntity'
 ON 'StochasticSoilModelEntity' ('FailureMechanismEntityId' ASC)
;

CREATE INDEX 'IXFK_SurfaceLineEntity_FailureMechanismEntity'
 ON 'SurfaceLineEntity' ('FailureMechanismEntityId' ASC)
;

CREATE INDEX 'IXFK_SurfaceLinePointEntity_SurfaceLineEntity'
 ON 'PipingCharacteristicPointEntity' ('SurfaceLineEntityId' ASC)
;

CREATE INDEX 'IXFK_PipingCalculationOutputEntity_PipingCalculationEntity'
 ON 'PipingCalculationOutputEntity' ('PipingCalculationEntityId' ASC)
;

CREATE INDEX 'IXFK_PipingStructureFailureMechanismMetaEntity_FailureMechanismEntity'
 ON 'PipingStructureFailureMechanismMetaEntity' ('FailureMechanismEntityId' ASC)
;

CREATE INDEX 'IXFK_PipingSectionResultEntity_FailureMechanismSectionEntity'
 ON 'PipingSectionResultEntity' ('FailureMechanismSectionEntityId' ASC)
;

CREATE INDEX 'IXFK_GrassCoverErosionInwardsSectionResultEntity_FailureMechanismSectionEntity'
 ON 'GrassCoverErosionInwardsSectionResultEntity' ('FailureMechanismSectionEntityId' ASC)
;

CREATE INDEX 'IXFK_GrassCoverErosionInwardsSectionResultEntity_GrassCoverErosionInwardsCalculationEntity'
 ON 'GrassCoverErosionInwardsSectionResultEntity' ('GrassCoverErosionInwardsCalculationEntityId' ASC)
;

CREATE INDEX 'IXFK_HeightStructuresSectionResultEntity_FailureMechanismSectionEntity'
 ON 'HeightStructuresSectionResultEntity' ('FailureMechanismSectionEntityId' ASC)
;

CREATE INDEX 'IXFK_HeightStructuresSectionResultEntity_HeightStructuresCalculationEntity'
 ON 'HeightStructuresSectionResultEntity' ('HeightStructuresCalculationEntityId' ASC)
;

CREATE INDEX 'IXFK_StrengthStabilityLengthwiseConstructionSectionResultEntity_FailureMechanismSectionEntity'
 ON 'StrengthStabilityLengthwiseConstructionSectionResultEntity' ('FailureMechanismSectionEntityId' ASC)
;

CREATE INDEX 'IXFK_TechnicalInnovationSectionResultEntity_FailureMechanismSectionEntity'
 ON 'TechnicalInnovationSectionResultEntity' ('FailureMechanismSectionEntityId' ASC)
;

CREATE INDEX 'IXFK_WaterPressureAsphaltCoverSectionResultEntity_FailureMechanismSectionEntity'
 ON 'WaterPressureAsphaltCoverSectionResultEntity' ('FailureMechanismSectionEntityId' ASC)
;

CREATE INDEX 'IXFK_ClosingStructuresSectionResultEntity_ClosingStructuresCalculationEntity'
 ON 'ClosingStructuresSectionResultEntity' ('ClosingStructuresCalculationEntityId' ASC)
;

CREATE INDEX 'IXFK_ClosingStructuresSectionResultEntity_FailureMechanismSectionEntity'
 ON 'ClosingStructuresSectionResultEntity' ('FailureMechanismSectionEntityId' ASC)
;

CREATE INDEX 'IXFK_GrassCoverErosionOutwardsSectionResultEntity_FailureMechanismSectionEntity'
 ON 'GrassCoverErosionOutwardsSectionResultEntity' ('FailureMechanismSectionEntityId' ASC)
;

CREATE INDEX 'IXFK_GrassCoverSlipOffInwardsSectionResultEntity_FailureMechanismSectionEntity'
 ON 'GrassCoverSlipOffInwardsSectionResultEntity' ('FailureMechanismSectionEntityId' ASC)
;

CREATE INDEX 'IXFK_GrassCoverSlipOffOutwardsSectionResultEntity_FailureMechanismSectionEntity'
 ON 'GrassCoverSlipOffOutwardsSectionResultEntity' ('FailureMechanismSectionEntityId' ASC)
;

CREATE INDEX 'IXFK_MacroStabilityInwardsSectionResultEntity_FailureMechanismSectionEntity'
 ON 'MacroStabilityInwardsSectionResultEntity' ('FailureMechanismSectionEntityId' ASC)
;

CREATE INDEX 'IXFK_MacroStabilityOutwardsSectionResultEntity_FailureMechanismSectionEntity'
 ON 'MacroStabilityOutwardsSectionResultEntity' ('FailureMechanismSectionEntityId' ASC)
;

CREATE INDEX 'IXFK_WaveImpactAsphaltCoverFailureMechanismMetaEntity_FailureMechanismEntity'
 ON 'WaveImpactAsphaltCoverFailureMechanismMetaEntity' ('FailureMechanismEntityId' ASC)
;

CREATE INDEX 'IXFK_WaveImpactAsphaltCoverSectionResultEntity_FailureMechanismSectionEntity'
 ON 'WaveImpactAsphaltCoverSectionResultEntity' ('FailureMechanismSectionEntityId' ASC)
;

CREATE INDEX 'IXFK_MicrostabilitySectionResultEntity_FailureMechanismSectionEntity'
 ON 'MicrostabilitySectionResultEntity' ('FailureMechanismSectionEntityId' ASC)
;

CREATE INDEX 'IXFK_PipingStructureSectionResultEntity_FailureMechanismSectionEntity'
 ON 'PipingStructureSectionResultEntity' ('FailureMechanismSectionEntityId' ASC)
;

CREATE INDEX 'IXFK_DuneErosionSectionResultEntity_FailureMechanismSectionEntity'
 ON 'DuneErosionSectionResultEntity' ('FailureMechanismSectionEntityId' ASC)
;

CREATE INDEX 'IXFK_StabilityStoneCoverSectionResultEntity_FailureMechanismSectionEntity'
 ON 'StabilityStoneCoverSectionResultEntity' ('FailureMechanismSectionEntityId' ASC)
;

CREATE INDEX 'IXFK_StabilityPointStructuresSectionResultEntity_FailureMechanismSectionEntity'
 ON 'StabilityPointStructuresSectionResultEntity' ('FailureMechanismSectionEntityId' ASC)
;

CREATE INDEX 'IXFK_StabilityPointStructuresSectionResultEntity_StabilityPointStructuresCalculationEntity'
 ON 'StabilityPointStructuresSectionResultEntity' ('StabilityPointStructuresCalculationEntityId' ASC)
;

CREATE INDEX 'IXFK_DikeProfileEntity_FailureMechanismEntity'
 ON 'DikeProfileEntity' ('FailureMechanismEntityId' ASC)
;

CREATE INDEX 'IXFK_GrassCoverErosionInwardsOutputEntity_GeneralResultFaultTreeIllustrationPointEntity'
 ON 'GrassCoverErosionInwardsOutputEntity' ('GeneralResultFaultTreeIllustrationPointEntityId' ASC)
;

CREATE INDEX 'IXFK_GrassCoverErosionInwardsOutputEntity_GrassCoverErosionInwardsCalculationEntity'
 ON 'GrassCoverErosionInwardsOutputEntity' ('GrassCoverErosionInwardsCalculationEntityId' ASC)
;
CREATE TRIGGER [TR_AfterDeleteGrassCoverErosionInwardsOutputEntity_RemoveGeneralResultFaultTreeIllustrationPointEntity]
	AFTER DELETE
	ON GrassCoverErosionInwardsOutputEntity
	FOR EACH ROW
BEGIN
	DELETE
	FROM GeneralResultFaultTreeIllustrationPointEntity
	WHERE OLD.GeneralResultFaultTreeIllustrationPointEntityId IS NOT NULL 
	AND GeneralResultFaultTreeIllustrationPointEntityId IS OLD.GeneralResultFaultTreeIllustrationPointEntityId;
END; 
;

CREATE INDEX 'IXFK_ForeshoreProfileEntity_FailureMechanismEntity'
 ON 'ForeshoreProfileEntity' ('FailureMechanismEntityId' ASC)
;

CREATE INDEX 'IXFK_StabilityStoneCoverWaveConditionsCalculationEntity_CalculationGroupEntity'
 ON 'StabilityStoneCoverWaveConditionsCalculationEntity' ('CalculationGroupEntityId' ASC)
;

CREATE INDEX 'IXFK_StabilityStoneCoverWaveConditionsCalculationEntity_ForeshoreProfileEntity'
 ON 'StabilityStoneCoverWaveConditionsCalculationEntity' ('ForeshoreProfileEntityId' ASC)
;

CREATE INDEX 'IXFK_StabilityStoneCoverWaveConditionsCalculationEntity_HydraulicLocationEntity'
 ON 'StabilityStoneCoverWaveConditionsCalculationEntity' ('HydraulicLocationEntityId' ASC)
;

CREATE INDEX 'IXFK_StabilityStoneCoverWaveConditionsOutputEntity_StabilityStoneCoverWaveConditionsCalculationEntity'
 ON 'StabilityStoneCoverWaveConditionsOutputEntity' ('StabilityStoneCoverWaveConditionsCalculationEntityId' ASC)
;

CREATE INDEX 'IXFK_WaveImpactAsphaltCoverWaveConditionsCalculationEntity_CalculationGroupEntity'
 ON 'WaveImpactAsphaltCoverWaveConditionsCalculationEntity' ('CalculationGroupEntityId' ASC)
;

CREATE INDEX 'IXFK_WaveImpactAsphaltCoverWaveConditionsCalculationEntity_ForeshoreProfileEntity'
 ON 'WaveImpactAsphaltCoverWaveConditionsCalculationEntity' ('ForeshoreProfileEntityId' ASC)
;

CREATE INDEX 'IXFK_WaveImpactAsphaltCoverWaveConditionsCalculationEntity_HydraulicLocationEntity'
 ON 'WaveImpactAsphaltCoverWaveConditionsCalculationEntity' ('HydraulicLocationEntityId' ASC)
;

CREATE INDEX 'IXFK_WaveImpactAsphaltCoverWaveConditionsOutputEntity_WaveImpactAsphaltCoverWaveConditionsCalculationEntity'
 ON 'WaveImpactAsphaltCoverWaveConditionsOutputEntity' ('WaveImpactAsphaltCoverWaveConditionsCalculationEntityId' ASC)
;

CREATE INDEX 'IXFK_GrassCoverErosionOutwardsWaveConditionsCalculationEntity_CalculationGroupEntity'
 ON 'GrassCoverErosionOutwardsWaveConditionsCalculationEntity' ('CalculationGroupEntityId' ASC)
;

CREATE INDEX 'IXFK_GrassCoverErosionOutwardsWaveConditionsCalculationEntity_ForeshoreProfileEntity'
 ON 'GrassCoverErosionOutwardsWaveConditionsCalculationEntity' ('ForeshoreProfileEntityId' ASC)
;

CREATE INDEX 'IXFK_GrassCoverErosionOutwardsWaveConditionsCalculationEntity_HydraulicLocationEntity'
 ON 'GrassCoverErosionOutwardsWaveConditionsCalculationEntity' ('HydraulicLocationEntityId' ASC)
;

CREATE INDEX 'IXFK_GrassCoverErosionOutwardsWaveConditionsOutputEntity_GrassCoverErosionOutwardsWaveConditionsCalculationEntity'
 ON 'GrassCoverErosionOutwardsWaveConditionsOutputEntity' ('GrassCoverErosionOutwardsWaveConditionsCalculationEntityId' ASC)
;

CREATE INDEX 'IXFK_HeightStructuresOutputEntity_HeightStructuresCalculationEntity'
 ON 'HeightStructuresOutputEntity' ('HeightStructuresCalculationEntityId' ASC)
;
CREATE TRIGGER [TR_AfterDeleteHeightStructuresOutputEntity_RemoveGeneralResultFaultTreeIllustrationPointEntity]
	AFTER DELETE
	ON HeightStructuresOutputEntity
	FOR EACH ROW
BEGIN
	DELETE
	FROM GeneralResultFaultTreeIllustrationPointEntity
	WHERE OLD.GeneralResultFaultTreeIllustrationPointEntityId IS NOT NULL 
	AND GeneralResultFaultTreeIllustrationPointEntityId IS OLD.GeneralResultFaultTreeIllustrationPointEntityId;
END; 
;

CREATE INDEX 'IXFK_HeightStructure_FailureMechanismEntity'
 ON 'HeightStructureEntity' ('FailureMechanismEntityId' ASC)
;

CREATE INDEX 'IXFK_HeightStructuresCalculationEntity_CalculationGroupEntity'
 ON 'HeightStructuresCalculationEntity' ('CalculationGroupEntityId' ASC)
;

CREATE INDEX 'IXFK_HeightStructuresCalculationEntity_ForeshoreProfileEntity'
 ON 'HeightStructuresCalculationEntity' ('ForeshoreProfileEntityId' ASC)
;

CREATE INDEX 'IXFK_HeightStructuresCalculationEntity_HeightStructureEntity'
 ON 'HeightStructuresCalculationEntity' ('HeightStructureEntityId' ASC)
;

CREATE INDEX 'IXFK_HeightStructuresCalculationEntity_HydraulicLocationEntity'
 ON 'HeightStructuresCalculationEntity' ('HydraulicLocationEntityId' ASC)
;

CREATE INDEX 'IXFK_ClosingStructureEntity_FailureMechanismEntity'
 ON 'ClosingStructureEntity' ('FailureMechanismEntityId' ASC)
;

CREATE INDEX 'IXFK_ClosingStructuresCalculationEntity_CalculationGroupEntity'
 ON 'ClosingStructuresCalculationEntity' ('CalculationGroupEntityId' ASC)
;

CREATE INDEX 'IXFK_ClosingStructuresCalculationEntity_ClosingStructureEntity'
 ON 'ClosingStructuresCalculationEntity' ('ClosingStructureEntityId' ASC)
;

CREATE INDEX 'IXFK_ClosingStructuresCalculationEntity_ForeshoreProfileEntity'
 ON 'ClosingStructuresCalculationEntity' ('ForeshoreProfileEntityId' ASC)
;

CREATE INDEX 'IXFK_ClosingStructuresCalculationEntity_HydraulicLocationEntity'
 ON 'ClosingStructuresCalculationEntity' ('HydraulicLocationEntityId' ASC)
;

CREATE INDEX 'IXFK_ClosingStructuresOutputEntity_ClosingStructuresCalculationEntity'
 ON 'ClosingStructuresOutputEntity' ('ClosingStructuresCalculationEntityId' ASC)
;
CREATE TRIGGER [TR_AfterDeleteClosingStructuresOutputEntity_RemoveGeneralResultFaultTreeIllustrationPointEntity]
	AFTER DELETE
	ON ClosingStructuresOutputEntity
	FOR EACH ROW
BEGIN
	DELETE
	FROM GeneralResultFaultTreeIllustrationPointEntity
	WHERE OLD.GeneralResultFaultTreeIllustrationPointEntityId IS NOT NULL 
	AND GeneralResultFaultTreeIllustrationPointEntityId IS OLD.GeneralResultFaultTreeIllustrationPointEntityId;
END; 
;

CREATE INDEX 'IXFK_StabilityPointStructureEntity_FailureMechanismEntity'
 ON 'StabilityPointStructureEntity' ('FailureMechanismEntityId' ASC)
;

CREATE INDEX 'IXFK_StabilityPointStructuresOutputEntity_StabilityPointStructuresCalculationEntity'
 ON 'StabilityPointStructuresOutputEntity' ('StabilityPointStructuresCalculationEntityId' ASC)
;
CREATE TRIGGER [TR_AfterDeleteStabilityPointStructuresOutputEntity_RemoveGeneralResultFaultTreeIllustrationPointEntity]
	AFTER DELETE
	ON StabilityPointStructuresOutputEntity
	FOR EACH ROW
BEGIN
	DELETE
	FROM GeneralResultFaultTreeIllustrationPointEntity
	WHERE OLD.GeneralResultFaultTreeIllustrationPointEntityId IS NOT NULL 
	AND GeneralResultFaultTreeIllustrationPointEntityId IS OLD.GeneralResultFaultTreeIllustrationPointEntityId;
END; 
;

CREATE INDEX 'IXFK_HydraulicLocationOutputEntity_GeneralResultSubMechanismIllustrationPointEntity'
 ON 'HydraulicLocationOutputEntity' ('GeneralResultSubMechanismIllustrationPointEntityId' ASC)
;

CREATE INDEX 'IXFK_HydraulicLocationOutputEntity_HydraulicLocationCalculationEntity'
 ON 'HydraulicLocationOutputEntity' ('HydraulicLocationCalculationEntityId' ASC)
;
CREATE TRIGGER [TR_AfterDeleteHydraulicLocationOutputEntity_RemoveGeneralResultSubMechanismIllustrationPointEntity]
	AFTER DELETE
	ON HydraulicLocationOutputEntity
	FOR EACH ROW
BEGIN
	DELETE 
	FROM GeneralResultSubMechanismIllustrationPointEntity
	WHERE OLD.GeneralResultSubMechanismIllustrationPointEntityId IS NOT NULL 
	AND GeneralResultSubMechanismIllustrationPointEntityId IS OLD.GeneralResultSubMechanismIllustrationPointEntityId;
END; 
;

CREATE INDEX 'IXFK_DuneLocationEntity_FailureMechanismEntity'
 ON 'DuneLocationEntity' ('FailureMechanismEntityId' ASC)
;

CREATE INDEX 'IXFK_DuneLocationCalculationOutputEntity_DuneLocationCalculationEntity'
 ON 'DuneLocationCalculationOutputEntity' ('DuneLocationCalculationEntityId' ASC)
;

CREATE INDEX 'IXFK_BackgroundDataEntity_AssessmentSectionEntity'
 ON 'BackgroundDataEntity' ('AssessmentSectionEntityId' ASC)
;

CREATE INDEX 'IXFK_BackgroundDataMetaEntity_BackgroundDataEntity'
 ON 'BackgroundDataMetaEntity' ('BackgroundDataEntityId' ASC)
;

CREATE INDEX 'IXFK_GrassCoverErosionInwardsOvertoppingRateOutputEntity_GeneralResultFaultTreeIllustrationPointEntity'
 ON 'GrassCoverErosionInwardsOvertoppingRateOutputEntity' ('GeneralResultFaultTreeIllustrationPointEntityId' ASC)
;

CREATE INDEX 'IXFK_GrassCoverErosionInwardsOvertoppingRateOutputEntity_GrassCoverErosionInwardsOutputEntity'
 ON 'GrassCoverErosionInwardsOvertoppingRateOutputEntity' ('GrassCoverErosionInwardsOutputEntityId' ASC)
;
CREATE TRIGGER [TR_AfterDeleteGrassCoverErosionInwardsOvertoppingRateOutputEntity_RemoveGeneralResultFaultTreeIllustrationPointEntity]
	AFTER DELETE
	ON GrassCoverErosionInwardsOvertoppingRateOutputEntity
	FOR EACH ROW
BEGIN
	DELETE
	FROM GeneralResultFaultTreeIllustrationPointEntity
	WHERE OLD.GeneralResultFaultTreeIllustrationPointEntityId IS NOT NULL 
	AND GeneralResultFaultTreeIllustrationPointEntityId IS OLD.GeneralResultFaultTreeIllustrationPointEntityId;
END; 
;

CREATE INDEX 'IXFK_IllustrationPointResultEntity_SubMechanismIllustrationPointEntity'
 ON 'IllustrationPointResultEntity' ('SubMechanismIllustrationPointEntityId' ASC)
;

CREATE INDEX 'IXFK_GeneralResultSubMechanismIllustrationPointStochastEntity_GeneralResultSubMechanismIllustrationPointEntity'
 ON 'GeneralResultSubMechanismIllustrationPointStochastEntity' ('GeneralResultSubMechanismIllustrationPointEntityId' ASC)
;

CREATE INDEX 'IXFK_GeneralResultSubMechanismIllustrationPointStochastEntity_StochastEntity'
 ON 'GeneralResultSubMechanismIllustrationPointStochastEntity' ('StochastEntityId' ASC)
;
CREATE TRIGGER [TR_AfterDeleteGeneralResultSubMechanismIllustrationPointStochastEntity_RemoveStochastEntity]
	AFTER DELETE
	ON GeneralResultSubMechanismIllustrationPointStochastEntity
	FOR EACH ROW
BEGIN
	DELETE 
	FROM StochastEntity
	WHERE OLD.StochastEntityId IS NOT NULL 
	AND StochastEntityId IS OLD.StochastEntityId;
END; 
;

CREATE INDEX 'IXFK_FaultTreeIllustrationPoint_FaultTreeIllustrationPoint'
 ON 'FaultTreeIllustrationPointEntity' ('ParentFaultTreeIllustrationPointEntityId' ASC)
;

CREATE INDEX 'IXFK_FaultTreeIllustrationPointStochastEntity_FaultTreeIllustrationPoint'
 ON 'FaultTreeIllustrationPointStochastEntity' ('FaultTreeIllustrationPointEntityId' ASC)
;

CREATE INDEX 'IXFK_FaultTreeIllustrationPointStochastEntity_StochastEntity'
 ON 'FaultTreeIllustrationPointStochastEntity' ('StochastEntityId' ASC)
;
CREATE TRIGGER [TR_AfterDeleteFaultTreeIllustrationPointStochastEntity_RemoveStochastEntity]
	AFTER DELETE
	ON FaultTreeIllustrationPointStochastEntity
	FOR EACH ROW
BEGIN
	DELETE
	FROM StochastEntity
	WHERE OLD.StochastEntityId IS NOT NULL 
	AND StochastEntityId IS OLD.StochastEntityId;
END; 
;

CREATE INDEX 'IXFK_GeneralResultFaultTreeIllustrationPointStochastEntity_GeneralResultFaultTreeIllustrationPointEntity'
 ON 'GeneralResultFaultTreeIllustrationPointStochastEntity' ('GeneralResultFaultTreeIllustrationPointEntityId' ASC)
;

CREATE INDEX 'IXFK_GeneralResultFaultTreeIllustrationPointStochastEntity_StochastEntity'
 ON 'GeneralResultFaultTreeIllustrationPointStochastEntity' ('StochastEntityId' ASC)
;
CREATE TRIGGER [TR_AfterDeleteGeneralResultFaultTreeIllustrationPointStochastEntity_RemoveStochastEntity]
	AFTER DELETE
	ON GeneralResultFaultTreeIllustrationPointStochastEntity
	FOR EACH ROW
BEGIN
	DELETE 
	FROM StochastEntity
	WHERE OLD.StochastEntityId IS NOT NULL 
	AND StochastEntityId IS OLD.StochastEntityId;
END; 
;

CREATE INDEX 'IXFK_TopLevelSubMechanismIllustrationPointEntity_GeneralResultSubMechanismIllustrationPointEntity'
 ON 'TopLevelSubMechanismIllustrationPointEntity' ('GeneralResultSubMechanismIllustrationPointEntityId' ASC)
;

CREATE INDEX 'IXFK_TopLevelSubMechanismIllustrationPointEntity_SubMechanismIllustrationPointEntity'
 ON 'TopLevelSubMechanismIllustrationPointEntity' ('SubMechanismIllustrationPointEntityId' ASC)
;
CREATE TRIGGER [TR_AfterDeleteTopLevelSubMechanismIllustrationPointEntity_RemoveSubMechanismIllustrationPointEntity]
	AFTER DELETE
	ON TopLevelSubMechanismIllustrationPointEntity
	FOR EACH ROW
BEGIN
	DELETE 
	FROM SubMechanismIllustrationPointEntity
	WHERE OLD.SubMechanismIllustrationPointEntityId IS NOT NULL 
	AND SubMechanismIllustrationPointEntityId IS OLD.SubMechanismIllustrationPointEntityId;
END; 
;

CREATE INDEX 'IXFK_TopLevelFaultTreeIllustrationPointEntity_FaultTreeIllustrationPointEntity'
 ON 'TopLevelFaultTreeIllustrationPointEntity' ('FaultTreeIllustrationPointEntityId' ASC)
;

CREATE INDEX 'IXFK_TopLevelFaultTreeIllustrationPointEntity_GeneralResultFaultTreeIllustrationPointEntity'
 ON 'TopLevelFaultTreeIllustrationPointEntity' ('GeneralResultFaultTreeIllustrationPointEntityId' ASC)
;
CREATE TRIGGER [TR_AfterDeleteTopLevelFaultTreeIllustrationPointEntity_RemoveFaultTreeIllustrationPointEntity]
	AFTER DELETE
	ON TopLevelFaultTreeIllustrationPointEntity
	FOR EACH ROW
BEGIN
	DELETE
	FROM FaultTreeIllustrationPointEntity
	WHERE OLD.FaultTreeIllustrationPointEntityId IS NOT NULL 
	AND FaultTreeIllustrationPointEntityId IS OLD.FaultTreeIllustrationPointEntityId;
END; 
;

CREATE INDEX 'IXFK_SubMechanismIllustrationPointStochast_SubMechanismIllustrationPointEntity'
 ON 'SubMechanismIllustrationPointStochastEntity' ('SubMechanismIllustrationPointEntityId' ASC)
;

CREATE INDEX 'IXFK_FaultTreeIllustrationPointEntity_FaultTreeIllustrationPointEntity'
 ON 'FaultTreeSubmechanismIllustrationPointEntity' ('FaultTreeIllustrationPointEntityId' ASC)
;

CREATE INDEX 'IXFK_FaultTreeIllustrationPointEntity_SubMechanismIllustrationPointEntity'
 ON 'FaultTreeSubmechanismIllustrationPointEntity' ('SubMechanismIllustrationPointEntityId' ASC)
;
CREATE TRIGGER [TR_AfterDeleteFaultTreeSubmechanismIllustrationPointEntity_RemoveSubmechanismIllustrationPointEntity]
	AFTER DELETE
	ON FaultTreeSubmechanismIllustrationPointEntity
	FOR EACH ROW
BEGIN
	DELETE 
	FROM SubmechanismIllustrationPointEntity
	WHERE OLD.SubmechanismIllustrationPointEntityId IS NOT NULL 
	AND SubmechanismIllustrationPointEntityId IS OLD.SubmechanismIllustrationPointEntityId;
END; 
;

CREATE INDEX 'IXFK_MacroStabilityInwardsCalculationEntity_CalculationGroupEntity'
 ON 'MacroStabilityInwardsCalculationEntity' ('CalculationGroupEntityId' ASC)
;

CREATE INDEX 'IXFK_MacroStabilityInwardsCalculationEntity_HydraulicLocationEntity'
 ON 'MacroStabilityInwardsCalculationEntity' ('HydraulicLocationEntityId' ASC)
;

CREATE INDEX 'IXFK_MacroStabilityInwardsCalculationEntity_MacroStabilityInwardsStochasticSoilProfileEntity'
 ON 'MacroStabilityInwardsCalculationEntity' ('MacroStabilityInwardsStochasticSoilProfileEntityId' ASC)
;

CREATE INDEX 'IXFK_MacroStabilityInwardsCalculationOutput_MacroStabilityInwardsCalculationEntity'
 ON 'MacroStabilityInwardsCalculationOutputEntity' ('MacroStabilityInwardsCalculationEntityId' ASC)
;

CREATE INDEX 'IXFK_MacroStabilityCharacteristicPointEntity_SurfaceLineEntity'
 ON 'MacroStabilityInwardsCharacteristicPointEntity' ('SurfaceLineEntityId' ASC)
;

CREATE INDEX 'IXFK_MacroStabilityInwardsSoilLayerOneDEntity_MacroStabilityInwardsSoilProfileOneDEntity'
 ON 'MacroStabilityInwardsSoilLayerOneDEntity' ('MacroStabilityInwardsSoilProfileOneDEntityId' ASC)
;

CREATE INDEX 'IXFK_MacroStabilityInwardsStochasticSoilProfileEntity_StochasticSoilModelEntity'
 ON 'MacroStabilityInwardsStochasticSoilProfileEntity' ('StochasticSoilModelEntityId' ASC)
;
CREATE TRIGGER [TR_BeforeInsertMacroStabilityInwardsStochasticSoilProfileEntity_MustHaveOneDOrTwoD]
	BEFORE INSERT
	ON MacroStabilityInwardsStochasticSoilProfileEntity
	FOR EACH ROW
BEGIN
	SELECT
		CASE
			WHEN 
			(
				NEW.MacroStabilityInwardsSoilProfileOneDEntityId IS NULL AND NEW.MacroStabilityInwardsSoilProfileTwoDEntityId IS NULL
			) OR (
				NEW.MacroStabilityInwardsSoilProfileOneDEntityId IS NOT NULL AND NEW.MacroStabilityInwardsSoilProfileTwoDEntityId IS NOT NULL
			)
				THEN RAISE(FAIL, 'Either SoilProfile1D or SoilProfile2D must be set.')
		END;
END; 
;

CREATE TRIGGER [TR_BeforeUpdateMacroStabilityInwardsStochasticSoilProfileEntity_MustHaveOneDOrTwoD]
	BEFORE UPDATE
	ON MacroStabilityInwardsStochasticSoilProfileEntity
	FOR EACH ROW
BEGIN
	SELECT
		CASE
			WHEN 
			(
				NEW.MacroStabilityInwardsSoilProfileOneDEntityId IS NULL AND NEW.MacroStabilityInwardsSoilProfileTwoDEntityId IS NULL
			) OR (
				NEW.MacroStabilityInwardsSoilProfileOneDEntityId IS NOT NULL AND NEW.MacroStabilityInwardsSoilProfileTwoDEntityId IS NOT NULL
			)
				THEN RAISE(FAIL, 'Either SoilProfile1D or SoilProfile2D must be set.')
		END;
END; 
;

CREATE TRIGGER [TR_AfterDeleteMacroStabilityInwardsSoilProfileTwoDEntity_MacroStabilityInwardsSoilLayerTwoDEntity]
	AFTER DELETE
	ON MacroStabilityInwardsSoilProfileTwoDEntity
	FOR EACH ROW
BEGIN
	DELETE 
	FROM MacroStabilityInwardsSoilLayerTwoDEntity
	WHERE OLD.MacroStabilityInwardsSoilLayerTwoDEntity IS NOT NULL 
	AND MacroStabilityInwardsSoilLayerTwoDEntity IS OLD.MacroStabilityInwardsSoilLayerTwoDEntity;
END; 
;

CREATE INDEX 'IXFK_HydraulicLocationCalculationEntity_HydraulicLocationCalculationCollectionEntity'
 ON 'HydraulicLocationCalculationEntity' ('HydraulicLocationCalculationCollectionEntityId' ASC)
;

CREATE INDEX 'IXFK_HydraulicLocationCalculationEntity_HydraulicLocationEntity'
 ON 'HydraulicLocationCalculationEntity' ('HydraulicLocationEntityId' ASC)
;

CREATE INDEX 'IXFK_DuneLocationCalculationEntity_DuneLocationCalculationCollectionEntity'
 ON 'DuneLocationCalculationEntity' ('DuneLocationCalculationCollectionEntityId' ASC)
;

CREATE INDEX 'IXFK_DuneLocationCalculationEntity_DuneLocationEntity'
 ON 'DuneLocationCalculationEntity' ('DuneLocationEntityId' ASC)
;

CREATE INDEX 'IXFK_HydraulicBoundaryDatabaseEntity_AssessmentSectionEntity'
 ON 'HydraulicBoundaryDatabaseEntity' ('AssessmentSectionEntityId' ASC)
;
