CREATE TABLE `SCHOUWRONDE` (
    `SCHOUWRONDE_ID` INT PRIMARY KEY
) ENGINE=InnoDB;

CREATE TABLE `AREAAL` (
    `AREAAL_ID` INT PRIMARY KEY,
    `GEOMETRIE` GEOMETRY
) ENGINE=InnoDB;

CREATE TABLE `WIJK` (
    `WIJK_ID` INT PRIMARY KEY,
    `BEGINGELDIGHEID` DATE,
    `DATUMEINDE` DATE,
    `DATUMINGANG` DATE,
    `EINDGELDIGHEID` DATE,
    `GECONSTATEERD` BOOLEAN,
    `GEOMETRIE` GEOMETRY,
    `IDENTIFICATIE` VARCHAR(255),
    `STATUS` VARCHAR(255),
    `VERSIE` INT,
    `WIJKCODE` VARCHAR(255),
    `WIJKNAAM` VARCHAR(255)
) ENGINE=InnoDB;

CREATE TABLE `KP_ARL_SCHWRND` (
    `KP_ARL_SCHWRND_ID` INT PRIMARY KEY,
    `AREAAL_ID` INT,
    `SCHOUWRONDE_ID` INT
) ENGINE=InnoDB;

CREATE TABLE `KP_ARL_WJK` (
    `KP_ARL_WJK_ID` INT PRIMARY KEY,
    `AREAAL_ID` INT,
    `WIJK_ID` INT
) ENGINE=InnoDB;

CREATE TABLE `BUURT` (
    `BUURT_ID` INT PRIMARY KEY,
    `BEGINGELDIGHEID` DATE,
    `CODE` VARCHAR(255),
    `DATUMEINDE` DATE,
    `DATUMINGANG` DATE,
    `EINDGELDIGHEID` DATE,
    `GECONSTATEERD` BOOLEAN,
    `GEOMETRIE` GEOMETRY,
    `IDENTIFICATIE` VARCHAR(255),
    `LIGT_IN_WIJK_ID` INT,
    `NAAM` VARCHAR(255),
    `STATUS` VARCHAR(255),
    `VERSIE` INT
) ENGINE=InnoDB;

CREATE TABLE `KP_ARL_BRT` (
    `KP_ARL_BRT_ID` INT PRIMARY KEY,
    `AREAAL_ID` INT,
    `BUURT_ID` INT
) ENGINE=InnoDB;

ALTER TABLE `KP_ARL_SCHWRND` ADD CONSTRAINT FK_KP_ARL_SCHWRND_1 FOREIGN KEY (`AREAAL_ID`) REFERENCES `AREAAL` (`AREAAL_ID`);
-- AREAAL (many-to-many junction, Connector_ID: 746)

ALTER TABLE `KP_ARL_SCHWRND` ADD CONSTRAINT FK_KP_ARL_SCHWRND_2 FOREIGN KEY (`SCHOUWRONDE_ID`) REFERENCES `SCHOUWRONDE` (`SCHOUWRONDE_ID`);
-- SCHOUWRONDE (many-to-many junction, Connector_ID: 746)

ALTER TABLE `KP_ARL_WJK` ADD CONSTRAINT FK_KP_ARL_WJK_1 FOREIGN KEY (`AREAAL_ID`) REFERENCES `AREAAL` (`AREAAL_ID`);
-- AREAAL (many-to-many junction, Connector_ID: 749)

ALTER TABLE `KP_ARL_WJK` ADD CONSTRAINT FK_KP_ARL_WJK_2 FOREIGN KEY (`WIJK_ID`) REFERENCES `WIJK` (`WIJK_ID`);
-- WIJK (many-to-many junction, Connector_ID: 749)

ALTER TABLE `KP_ARL_BRT` ADD CONSTRAINT FK_KP_ARL_BRT_1 FOREIGN KEY (`AREAAL_ID`) REFERENCES `AREAAL` (`AREAAL_ID`);
-- AREAAL (many-to-many junction, Connector_ID: 750)

ALTER TABLE `KP_ARL_BRT` ADD CONSTRAINT FK_KP_ARL_BRT_2 FOREIGN KEY (`BUURT_ID`) REFERENCES `BUURT` (`BUURT_ID`);
-- BUURT (many-to-many junction, Connector_ID: 750)

ALTER TABLE `BUURT` ADD CONSTRAINT FK_BUURT_LIGT_IN FOREIGN KEY (`LIGT_IN_WIJK_ID`) REFERENCES `WIJK` (`WIJK_ID`);
-- LIGT_IN (1..* to 1, Connector_ID: 2297)

