CREATE TABLE `DOELGROEP` (
    `DOELGROEP_ID` INT PRIMARY KEY,
    `NAAM` VARCHAR(255),
    `OMSCHRIJVING` TEXT
) ENGINE=InnoDB;

CREATE TABLE `CLIENT` (
    `CLIENT_ID` INT PRIMARY KEY,
    `CODE` VARCHAR(80),
    `GEZAGSDRAGERGEKEND` BOOLEAN,
    `JURIDISCHESTATUS` VARCHAR(80),
    `WETTELIJKEVERTEGENWOORDIGING` VARCHAR(80)
) ENGINE=InnoDB;

CREATE TABLE `CLIENTBEGELEIDER` (
    `CLIENTBEGELEIDER_ID` INT PRIMARY KEY,
    `BEGELEIDERSCODE` VARCHAR(20)
) ENGINE=InnoDB;

CREATE TABLE `WERKZOEKENDE` (
    `CLIENT_ID` INT PRIMARY KEY,
    `DATUMAANVANGWERKZOEKENDE` DATE,
    `DATUMEINDEWERKZOEKENDE` DATE
) ENGINE=InnoDB;

CREATE TABLE `KP_CLNT_DLGRP` (
    `KP_CLNT_DLGRP_ID` INT PRIMARY KEY,
    `CLIENT_ID` INT,
    `DOELGROEP_ID` INT
) ENGINE=InnoDB;

CREATE TABLE `KP_CLNTBGLDR_CLNT` (
    `KP_CLNTBGLDR_CLNT_ID` INT PRIMARY KEY,
    `CLIENTBEGELEIDER_ID` INT,
    `CLIENT_ID` INT
) ENGINE=InnoDB;

CREATE TABLE `KP_WRKZKND_CLNT` (
    `KP_WRKZKND_CLNT_ID` INT PRIMARY KEY,
    `WERKZOEKENDE_ID` INT,
    `CLIENT_ID` INT
) ENGINE=InnoDB;

ALTER TABLE `WERKZOEKENDE` ADD CONSTRAINT FK_WERKZOEKENDE_GEN_CLIENT FOREIGN KEY (`CLIENT_ID`) REFERENCES `CLIENT` (`CLIENT_ID`);
-- Generalization to CLIENT

ALTER TABLE `KP_CLNTBGLDR_CLNT` ADD CONSTRAINT FK_KP_CLNTBGLDR_CLNT_1 FOREIGN KEY (`CLIENTBEGELEIDER_ID`) REFERENCES `CLIENTBEGELEIDER` (`CLIENTBEGELEIDER_ID`);
-- CLIENTBEGELEIDER (many-to-many junction, Connector_ID: 941)

ALTER TABLE `KP_CLNTBGLDR_CLNT` ADD CONSTRAINT FK_KP_CLNTBGLDR_CLNT_2 FOREIGN KEY (`CLIENT_ID`) REFERENCES `CLIENT` (`CLIENT_ID`);
-- CLIENT (many-to-many junction, Connector_ID: 941)

ALTER TABLE `KP_WRKZKND_CLNT` ADD CONSTRAINT FK_KP_WRKZKND_CLNT_1 FOREIGN KEY (`WERKZOEKENDE_ID`) REFERENCES `WERKZOEKENDE` (`CLIENT_ID`);
-- WERKZOEKENDE (many-to-many junction, Connector_ID: 1564)

ALTER TABLE `KP_WRKZKND_CLNT` ADD CONSTRAINT FK_KP_WRKZKND_CLNT_2 FOREIGN KEY (`CLIENT_ID`) REFERENCES `CLIENT` (`CLIENT_ID`);
-- CLIENT (many-to-many junction, Connector_ID: 1564)

ALTER TABLE `KP_CLNT_DLGRP` ADD CONSTRAINT FK_KP_CLNT_DLGRP_1 FOREIGN KEY (`CLIENT_ID`) REFERENCES `CLIENT` (`CLIENT_ID`);
-- CLIENT (many-to-many junction, Connector_ID: 1586)

ALTER TABLE `KP_CLNT_DLGRP` ADD CONSTRAINT FK_KP_CLNT_DLGRP_2 FOREIGN KEY (`DOELGROEP_ID`) REFERENCES `DOELGROEP` (`DOELGROEP_ID`);
-- DOELGROEP (many-to-many junction, Connector_ID: 1586)

