CREATE TABLE [MOTORVOERTUIG] (
    [VERMOGENSCOMPONENT_ID] INT PRIMARY KEY,
    [KENTEKEN] VARCHAR(255),
    [SOORT_MOTORVOERTUIG] VARCHAR(255)
);

CREATE TABLE [KP_BNKRKNNG_VRMGNSCMPNNT] (
    [KP_BNKRKNNG_VRMGNSCMPNNT_ID] INT PRIMARY KEY,
    [BANKREKENING_ID] INT,
    [VERMOGENSCOMPONENT_ID] INT
);

CREATE TABLE [ONROEREND_GOED] (
    [VERMOGENSCOMPONENT_ID] INT PRIMARY KEY,
    [HYPOTHEEK_RUST_OP_ONROEREND_GOED_VERMOGENSCOMPONENT_ID] INT,
    [OVERWAARDE] VARCHAR(255)
);

CREATE TABLE [VERMOGENSCOMPONENT] (
    [VERMOGENSCOMPONENT_ID] INT PRIMARY KEY,
    [CODE_SOORT_VERMOGENSCOMPONENT] VARCHAR(255),
    [DATUM_VASTSTELLING_VERMOGENCOMPONENT] DATE,
    [IDENTIFICATIE] VARCHAR(255),
    [NOG_AAN_TE_SPREKEN_VERMOGEN] VARCHAR(255),
    [VERMOGENSCOMPONENT_IS_GEWAARDEERD_MET_WAARDEPEILING_WAARDEPEILING_ID] INT,
    [VRIJ_TE_LATEN_VERMOGEN] VARCHAR(255)
);

CREATE TABLE [BANKREKENING] (
    [VERMOGENSCOMPONENT_ID] INT PRIMARY KEY,
    [BANKREKENINGNUMMER] VARCHAR(255),
    [BRONTYPE] VARCHAR(255),
    [DATUM_AANVANG_BANKREKENING] DATE,
    [DATUM_EINDE_BANKREKENING] DATE,
    [IBAN] VARCHAR(255),
    [REKENINGTYPE] VARCHAR(255),
    [TENAAMSTELLING] VARCHAR(255),
    [VOORKEUR_BANKREKENING] BIT
);

CREATE TABLE [HYPOTHEEK] (
    [VERMOGENSCOMPONENT_ID] INT PRIMARY KEY,
    [OVERWAARDE] VARCHAR(255)
);

CREATE TABLE [WAARDEPEILING] (
    [WAARDEPEILING_ID] INT PRIMARY KEY,
    [BIJGEVOEGD_BEWIJS] BIT,
    [BRONTYPE] VARCHAR(255),
    [DATUM_AANSPRAAK_VERMOGENSCOMPONENT] DATE,
    [LINK_NAAR_BEWIJS] VARCHAR(255),
    [PEILMOMENT] DATE,
    [WAARDESOORT_VERMOGENSCOMPONENT] VARCHAR(255),
    [WAARDE_VERMOGENSCOMPONENT] VARCHAR(255)
);

CREATE TABLE [KP_MTRVRTG_VRMGNSCMPNNT] (
    [KP_MTRVRTG_VRMGNSCMPNNT_ID] INT PRIMARY KEY,
    [MOTORVOERTUIG_ID] INT,
    [VERMOGENSCOMPONENT_ID] INT
);

CREATE TABLE [KP_HYPTHK_VRMGNSCMPNNT] (
    [KP_HYPTHK_VRMGNSCMPNNT_ID] INT PRIMARY KEY,
    [HYPOTHEEK_ID] INT,
    [VERMOGENSCOMPONENT_ID] INT
);

CREATE TABLE [KP_ONRRND_GD_VRMGNSCMPNNT] (
    [KP_ONRRND_GD_VRMGNSCMPNNT_ID] INT PRIMARY KEY,
    [ONROEREND_GOED_ID] INT,
    [VERMOGENSCOMPONENT_ID] INT
);

ALTER TABLE [BANKREKENING] ADD CONSTRAINT FK_BANKREKENING_GEN_VERMOGENSCOMPONENT FOREIGN KEY ([VERMOGENSCOMPONENT_ID]) REFERENCES [VERMOGENSCOMPONENT] ([VERMOGENSCOMPONENT_ID]);
-- Generalization to VERMOGENSCOMPONENT

ALTER TABLE [HYPOTHEEK] ADD CONSTRAINT FK_HYPOTHEEK_GEN_VERMOGENSCOMPONENT FOREIGN KEY ([VERMOGENSCOMPONENT_ID]) REFERENCES [VERMOGENSCOMPONENT] ([VERMOGENSCOMPONENT_ID]);
-- Generalization to VERMOGENSCOMPONENT

ALTER TABLE [MOTORVOERTUIG] ADD CONSTRAINT FK_MOTORVOERTUIG_GEN_VERMOGENSCOMPONENT FOREIGN KEY ([VERMOGENSCOMPONENT_ID]) REFERENCES [VERMOGENSCOMPONENT] ([VERMOGENSCOMPONENT_ID]);
-- Generalization to VERMOGENSCOMPONENT

ALTER TABLE [ONROEREND_GOED] ADD CONSTRAINT FK_ONROEREND_GOED_GEN_VERMOGENSCOMPONENT FOREIGN KEY ([VERMOGENSCOMPONENT_ID]) REFERENCES [VERMOGENSCOMPONENT] ([VERMOGENSCOMPONENT_ID]);
-- Generalization to VERMOGENSCOMPONENT

ALTER TABLE [KP_ONRRND_GD_VRMGNSCMPNNT] ADD CONSTRAINT FK_KP_ONRRND_GD_VRMGNSCMPNNT_1 FOREIGN KEY ([ONROEREND_GOED_ID]) REFERENCES [ONROEREND_GOED] ([VERMOGENSCOMPONENT_ID]);
-- ONROEREND_GOED (many-to-many junction, Connector_ID: 867)

ALTER TABLE [KP_ONRRND_GD_VRMGNSCMPNNT] ADD CONSTRAINT FK_KP_ONRRND_GD_VRMGNSCMPNNT_2 FOREIGN KEY ([VERMOGENSCOMPONENT_ID]) REFERENCES [VERMOGENSCOMPONENT] ([VERMOGENSCOMPONENT_ID]);
-- VERMOGENSCOMPONENT (many-to-many junction, Connector_ID: 867)

ALTER TABLE [KP_MTRVRTG_VRMGNSCMPNNT] ADD CONSTRAINT FK_KP_MTRVRTG_VRMGNSCMPNNT_1 FOREIGN KEY ([MOTORVOERTUIG_ID]) REFERENCES [MOTORVOERTUIG] ([VERMOGENSCOMPONENT_ID]);
-- MOTORVOERTUIG (many-to-many junction, Connector_ID: 868)

ALTER TABLE [KP_MTRVRTG_VRMGNSCMPNNT] ADD CONSTRAINT FK_KP_MTRVRTG_VRMGNSCMPNNT_2 FOREIGN KEY ([VERMOGENSCOMPONENT_ID]) REFERENCES [VERMOGENSCOMPONENT] ([VERMOGENSCOMPONENT_ID]);
-- VERMOGENSCOMPONENT (many-to-many junction, Connector_ID: 868)

ALTER TABLE [KP_HYPTHK_VRMGNSCMPNNT] ADD CONSTRAINT FK_KP_HYPTHK_VRMGNSCMPNNT_1 FOREIGN KEY ([HYPOTHEEK_ID]) REFERENCES [HYPOTHEEK] ([VERMOGENSCOMPONENT_ID]);
-- HYPOTHEEK (many-to-many junction, Connector_ID: 870)

ALTER TABLE [KP_HYPTHK_VRMGNSCMPNNT] ADD CONSTRAINT FK_KP_HYPTHK_VRMGNSCMPNNT_2 FOREIGN KEY ([VERMOGENSCOMPONENT_ID]) REFERENCES [VERMOGENSCOMPONENT] ([VERMOGENSCOMPONENT_ID]);
-- VERMOGENSCOMPONENT (many-to-many junction, Connector_ID: 870)

ALTER TABLE [KP_BNKRKNNG_VRMGNSCMPNNT] ADD CONSTRAINT FK_KP_BNKRKNNG_VRMGNSCMPNNT_1 FOREIGN KEY ([BANKREKENING_ID]) REFERENCES [BANKREKENING] ([VERMOGENSCOMPONENT_ID]);
-- BANKREKENING (many-to-many junction, Connector_ID: 871)

ALTER TABLE [KP_BNKRKNNG_VRMGNSCMPNNT] ADD CONSTRAINT FK_KP_BNKRKNNG_VRMGNSCMPNNT_2 FOREIGN KEY ([VERMOGENSCOMPONENT_ID]) REFERENCES [VERMOGENSCOMPONENT] ([VERMOGENSCOMPONENT_ID]);
-- VERMOGENSCOMPONENT (many-to-many junction, Connector_ID: 871)

ALTER TABLE [VERMOGENSCOMPONENT] ADD CONSTRAINT FK_VERMOGENSCOMPONENT_VERMOGENSCOMPONENT_IS_GEWAARDEERD_MET_WAARDEPEILING FOREIGN KEY ([VERMOGENSCOMPONENT_IS_GEWAARDEERD_MET_WAARDEPEILING_WAARDEPEILING_ID]) REFERENCES [WAARDEPEILING] ([WAARDEPEILING_ID]);
-- VERMOGENSCOMPONENT_IS_GEWAARDEERD_MET_WAARDEPEILING (0..* to 1..1, Connector_ID: 866)

ALTER TABLE [ONROEREND_GOED] ADD CONSTRAINT FK_ONROEREND_GOED_HYPOTHEEK_RUST_OP_ONROEREND_GOED FOREIGN KEY ([HYPOTHEEK_RUST_OP_ONROEREND_GOED_VERMOGENSCOMPONENT_ID]) REFERENCES [VERMOGENSCOMPONENT] ([VERMOGENSCOMPONENT_ID]);
-- HYPOTHEEK_RUST_OP_ONROEREND_GOED (1..1 to 0..*, Connector_ID: 869)

