-- Name: sf_vw_krm_metingen_g; Type: VIEW; Schema: krm; Owner: -
--

CREATE VIEW sf_vw_krm_metingen_g AS
 WITH bio AS (
         SELECT bio.obs_id,
            gedrag.code AS gedrag_code,
            geslacht.code AS geslacht_code,
            lengte.code AS lengte_code,
            levensstadium.code AS levensstadium_code,
            levensvorm.code AS levensvorm_code,
            verschijning.code AS verschijning_code
           FROM ((((((public.bio_observation bio
             LEFT JOIN public.hoedanigheid_type gedrag ON (((bio.gedrag_id = gedrag.hdh_id) AND (bio.gedrag_id IS NOT NULL))))
             LEFT JOIN public.hoedanigheid_type geslacht ON (((bio.geslacht_id = geslacht.hdh_id) AND (bio.geslacht_id IS NOT NULL))))
             LEFT JOIN public.hoedanigheid_type lengte ON (((bio.lengte_klasse_id = lengte.hdh_id) AND (bio.lengte_klasse_id IS NOT NULL))))
             LEFT JOIN public.hoedanigheid_type levensstadium ON (((bio.levensstadium_id = levensstadium.hdh_id) AND (bio.levensstadium_id IS NOT NULL))))
             LEFT JOIN public.hoedanigheid_type levensvorm ON (((bio.levensvorm_id = levensvorm.hdh_id) AND (bio.levensvorm_id IS NOT NULL))))
             LEFT JOIN public.hoedanigheid_type verschijning ON (((bio.verschijningsvorm_id = verschijning.hdh_id) AND (bio.verschijningsvorm_id IS NOT NULL))))
          WHERE ((bio.gedrag_id IS NOT NULL) AND (bio.geslacht_id IS NOT NULL) AND (bio.lengte_klasse_id IS NOT NULL) AND (bio.levensstadium_id IS NOT NULL) AND (bio.levensvorm_id IS NOT NULL) AND (bio.verschijningsvorm_id IS NOT NULL))
        ), opt AS (
         SELECT opt.opt_id,
            grh.code AS grh_code,
            grh.omschrijving AS grh_omschrijving,
            typ.code AS typ_code,
            typ.omschrijving AS typ_omschrijving,
            txt.omschrijving AS txg_omschrijving,
            chs.code AS chs_code,
            chs.naam AS chs_naam,
            obj.code AS obj_code,
            obj.omschrijving AS obj_omschrijving,
            hdh.code AS hdh_code,
            hdh.omschrijving AS hdh_omschrijving
           FROM ((((((public.observed_property_type opt
             LEFT JOIN public.grootheid_type grh ON (((grh.grh_id = opt.quantity_id) AND (opt.quantity_id IS NOT NULL))))
             LEFT JOIN public.typering_type typ ON (((typ.typ_id = opt.indicator_id) AND (opt.indicator_id IS NOT NULL))))
             LEFT JOIN public.hoedanigheid_type hdh ON (((hdh.hdh_id = opt.hoedanigheid_id) AND (opt.hoedanigheid_id IS NOT NULL))))
             LEFT JOIN ((public.taxa_group txg
             JOIN public.taxa_group_element tge ON ((tge.txg_id = txg.txg_id)))
             JOIN public.taxon_type txt ON ((txt.txn_id = tge.txn_id))) ON (((txg.txg_id = opt.taxa_group_id) AND ((txg.group_type)::text = 'I'::text))))
             LEFT JOIN ((public.substance_group ssg
             JOIN public.substance_group_element ssge ON ((ssge.ssge_id = ssg.ssg_id)))
             JOIN public.chemische_stof_type chs ON ((chs.chs_id = ssge.chs_id))) ON (((ssg.ssg_id = opt.substance_group_id) AND ((ssg.group_type)::text = 'I'::text))))
             LEFT JOIN ((public.object_group ojg
             JOIN public.object_group_element ojge ON ((ojg.ojg_id = ojge.ojg_id)))
             JOIN public.object_type obj ON ((obj.obj_id = ojge.obj_id))) ON (((ojg.ojg_id = opt.object_group_id) AND ((ojg.group_type)::text = 'I'::text))))
        )
 SELECT mno.mno_id,
    qeid.qem_id,
    qeid.idd_id,
    ((qeo.qeo_id)::text || (obs.obs_id)::text) AS unique_key,
    ((('NL'::text || (mno_nst.code)::text) || '_'::text) || (mno.inspire_id_local_id)::text) AS "Meetpunt.Identificatie",
    public.st_x(public.st_transform(public.st_centroid(mno.geometry_etrs89), 4258)) AS "GeometriePunt.X",
    public.st_y(public.st_transform(public.st_centroid(mno.geometry_etrs89), 4258)) AS "GeometriePunt.Y",
        CASE
            WHEN (obf.obs_id IS NOT NULL) THEN (('NL'::text || (ns_hdo.code)::text) || (hdo.inspire_id_local_id)::text)
            ELSE
            CASE
                WHEN ((mno.monitoring_object_type)::text = 'Sample'::text) THEN NULL::text
                ELSE ((('NL'::text || (mno_nst.code)::text) || '_AQUO_COMPARTIMENT:'::text) || (compartiment_type.code)::text)
            END
        END AS "Geoobject.Identificatie",
    NULL::text AS "Monster.Identificatie",
    NULL::text AS "Monster.Namespace",
    NULL::integer AS "Monster.Versie",
    NULL::text AS "Compartiment.Code",
    NULL::text AS "Compartiment.Omschrijving",
    NULL::text AS "Orgaan.Code",
    NULL::text AS "Orgaan.Omschrijving",
    NULL::text AS "Organisme.Naam",
    NULL::numeric AS "BeginDiepte_m",
    NULL::numeric AS "EindDiepte_m",
    NULL::text AS "ReferentieVlak.Code",
    NULL::text AS "Monsterbewerkingsmethode.Code",
    NULL::text AS "Monsterbewerkingsmethode.Omschrijving",
    NULL::text AS "Monsterbewerkingsmethode.codespace",
    NULL::text AS "Bemonsteringsmethode.Code",
    NULL::text AS "Bemonsteringsmethode.Omschrijving",
    NULL::text AS "Bemonsteringsmethode.codespace",
    NULL::text AS "Monstercriterium.Code",
    NULL::text AS "veldapparaat.Code",
    NULL::text AS "veldapparaat.Omschrijving",
    NULL::text AS "veldapparaat.Codespace",
    NULL::text AS "Monsternemingsdatum",
    NULL::text AS "Monsternemingstijd",
    NULL::integer AS "Monster.Tijd_UTCoffset",
    NULL::text AS "ReferentieHorizontaal.code",
    NULL::text AS "Monster.Opmerking",
    NULL::text AS "GerelateerdMonsterobject",
    NULL::text AS "GerelateerdMonsterRol.id",
    obs.obs_id AS "Meetwaarde.Identificatie",
    ('NL'::text || (mno_nst.code)::text) AS "Meetwaarde.Namespace",
    mno.wkrv_id AS "Meetwaarde.Versie",
    opt.grh_code AS "Grootheid.code",
    opt.grh_omschrijving AS "Grootheid.omschrijving",
    opt.typ_code AS "Typering.code",
    opt.typ_omschrijving AS "Typering.omschrijving",
        CASE
            WHEN (opt.txg_omschrijving IS NOT NULL) THEN 'Biotaxon'::text
            WHEN (opt.chs_code IS NOT NULL) THEN 'ChemischeStof'::text
            WHEN (opt.obj_code IS NOT NULL) THEN 'Object'::text
            ELSE NULL::text
        END AS "Parameter.Groep",
        CASE
            WHEN (opt.txg_omschrijving IS NOT NULL) THEN (NULL::text)::character varying
            WHEN (opt.chs_code IS NOT NULL) THEN opt.chs_code
            WHEN (opt.obj_code IS NOT NULL) THEN opt.obj_code
            ELSE NULL::character varying
        END AS "Parameter.Code",
        CASE
            WHEN (opt.txg_omschrijving IS NOT NULL) THEN opt.txg_omschrijving
            WHEN (opt.chs_code IS NOT NULL) THEN opt.chs_naam
            WHEN (opt.obj_code IS NOT NULL) THEN opt.obj_omschrijving
            ELSE NULL::character varying
        END AS "Parameter.Omschrijving",
    eenh.code AS "Eenheid.code",
    eenh.omschrijving AS "Eenheid.omschrijving",
    opt.hdh_code AS "Hoedanigheid.code",
    opt.hdh_omschrijving AS "Hoedanigheid.omschrijving",
    wbm.code AS "Waardebewerkigngsmethode.code",
        CASE
            WHEN (wbm.code IS NULL) THEN NULL::text
            ELSE 'www.aquo.nl'::text
        END AS "Waardebewerkigngsmethode.codespace",
    wbpm.code AS "Waardebepalingsmethode.code",
        CASE
            WHEN (wbpm.code IS NULL) THEN NULL::text
            ELSE 'www.aquo.nl'::text
        END AS "Waardebepalingsmethode.codespace",
    to_char(obs.phenomenon_time_begin, 'YYYY-MM-DD'::text) AS "Begindatum",
    to_char(obs.phenomenon_time_begin, 'HH24:MM:SS'::text) AS "Begintijd",
    to_char(obs.phenomenon_time_end, 'YYYY-MM-DD'::text) AS "Einddatum",
    to_char(obs.phenomenon_time_end, 'HH24:MM:SS'::text) AS "Eindtijd",
    NULL::integer AS "Meetwaarde.Tijd_UTCoffset",
    to_char(obs.result_time, 'YYYY-MM-DD'::text) AS "Resultaatdatum",
    NULL::integer AS "Resultaat_UTCoffset",
    obs.limit_symbol_id AS "Limietsymbool",
    obs.numeric_value AS "Numeriekewaarde",
    obs.description AS "Alfanumeriekewaarde",
    kwaliteitsoordeel_type.code AS "Kwaliteitsoordeel.code",
    kwaliteitsoordeel_type.description AS "Kwaliteitsoordeel.omschrijving",
    mar.code AS "Meetapparaat.code",
        CASE
            WHEN (mar.code IS NULL) THEN NULL::text
            ELSE 'www.aquo.nl'::text
        END AS "Meetapparaat.codespace",
    bio.levensstadium_code AS "Levensstadium.code",
    bio.lengte_code AS "Lengteklasse.code",
    bio.geslacht_code AS "Geslachtcode",
    bio.verschijning_code AS "Verschijningsvorm.code",
    bio.levensvorm_code AS "Levensvorm.code",
    bio.gedrag_code AS "Gedrag.code",
        CASE
            WHEN (obx.obs_id_target IS NULL) THEN NULL::text
            ELSE ((('NL'::text || (mno_nst.code)::text) || '_'::text) || (obx.obs_id_target)::text)
        END AS "GerelateerdObservatieobject",
    ocr.code AS "GerelateerdObservatieobjectRol.id",
    obs.remarks AS "Meetwaarde.Opmerking",
    indicator.additional_description AS "Indicator.EUOmschrijving",
    typi.code AS "Indicator.Code",
    typd.code AS "Descriptor.Code",
    descriptor.additional_description AS "Descriptor.EUOmschrijving"
   FROM ((((((((((((((((((domains.indicator_descriptor indicator
     JOIN public.observed_property_type opti ON ((indicator.opt_id = opti.opt_id)))
     JOIN public.typering_type typi ON ((opti.indicator_id = typi.typ_id)))
     JOIN domains.indicator_descriptor descriptor ON (((indicator.part_of_idd_id = descriptor.idd_id) AND (descriptor.part_of_idd_id IS NULL))))
     JOIN public.observed_property_type optd ON ((descriptor.opt_id = optd.opt_id)))
     JOIN public.typering_type typd ON ((optd.indicator_id = typd.typ_id)))
     JOIN monprog.quality_element_indicator_descriptor qeid ON ((qeid.idd_id = indicator.idd_id)))
     JOIN public.quality_element qem ON ((qem.qem_id = qeid.qem_id)))
     JOIN public.quality_element_observation qeo ON ((qeo.qem_id = qem.qem_id)))
     JOIN public.observation obs ON ((qeo.obs_id = obs.obs_id)))
     JOIN ((public.monitoring_object mno
     LEFT JOIN (public.monitored_compartiment
     JOIN public.compartiment_type ON ((monitored_compartiment.cptm_id = compartiment_type.cptm_id))) ON ((monitored_compartiment.mno_id = mno.mno_id)))
     JOIN public.namespace_type mno_nst ON ((mno_nst.ns_id = mno.inspire_id_namespace_id))) ON (((mno.mno_id = obs.mno_id) AND ((mno.monitoring_object_type)::text <> 'Sample'::text))))
     LEFT JOIN public.eenheid_type eenh ON ((eenh.eenh_id = obs.numeric_value_uom_id)))
     JOIN opt ON ((opt.opt_id = obs.observed_property_type)))
     LEFT JOIN public.kwaliteitsoordeel_type ON ((obs.quality_indicator_id = kwaliteitsoordeel_type.kwod_id)))
     LEFT JOIN ((public.observation_process obp
     LEFT JOIN public.waarde_bepalings_methode_type wbpm ON ((wbpm.wbpm_id = obp.wbpm_id)))
     LEFT JOIN (public.obs_process_meetapparaat opm
     JOIN domains.meetapparaat mar ON ((mar.mar_id = opm.mar_id))) ON ((opm.obp_id = obp.obp_id))) ON ((obp.obp_id = obs.result_nature_id)))
     LEFT JOIN bio ON ((bio.obs_id = obs.obs_id)))
     LEFT JOIN (public.observation_context obx
     JOIN public.obs_ctx_role_type ocr ON ((ocr.ocr_id = obx.role_id))) ON ((obx.obs_id_source = obs.obs_id)))
     LEFT JOIN public.waarde_bewerkings_methode_type wbm ON ((wbm.wbm_id = obs.value_processing_method_id)))
     LEFT JOIN ((public.observed_feature obf
     JOIN public.hydro_object hdo ON ((obf.hdo_id = hdo.hdo_id)))
     JOIN public.namespace_type ns_hdo ON ((hdo.inspire_id_namespace = ns_hdo.ns_id))) ON (((obs.obs_id = obf.obs_id) AND (mno.wkrv_id = hdo.wkrv_id))))
UNION ALL
 SELECT mno.mno_id,
    qeid.qem_id,
    qeid.idd_id,
    ((qeo.qeo_id)::text || (obs.obs_id)::text) AS unique_key,
    ((('NL'::text || (mpn_nst.code)::text) || '_'::text) || (mno_mpn.inspire_id_local_id)::text) AS "Meetpunt.Identificatie",
    public.st_x(public.st_transform(public.st_centroid(mno.geometry_etrs89), 4258)) AS "GeometriePunt.X",
    public.st_y(public.st_transform(public.st_centroid(mno.geometry_etrs89), 4258)) AS "GeometriePunt.Y",
        CASE
            WHEN (obf.obs_id IS NOT NULL) THEN ((('NL'::text || (ns_hdo.code)::text) || '_'::text) || (hdo.inspire_id_local_id)::text)
            ELSE NULL::text
        END AS "Geoobject.Identificatie",
    mno.inspire_id_local_id AS "Monster.Identificatie",
    mpn_nst.code AS "Monster.Namespace",
    mno.wkrv_id AS "Monster.Versie",
    cmp.code AS "Compartiment.Code",
    cmp.description AS "Compartiment.Omschrijving",
    orgaan.code AS "Orgaan.Code",
    orgaan.description AS "Orgaan.Omschrijving",
    taxon_type.omschrijving AS "Organisme.Naam",
    smpl.upper_depth_value AS "BeginDiepte_m",
    smpl.lower_depth_value AS "EindDiepte_m",
        CASE
            WHEN (hdh_ud.hdh_id IS NULL) THEN
            CASE
                WHEN (hdh_ld.hdh_id IS NULL) THEN (NULL::text)::character varying
                ELSE hdh_ld.code
            END
            ELSE hdh_ud.code
        END AS "ReferentieVlak.Code",
    mbm.code AS "Monsterbewerkingsmethode.Code",
    mbm.description AS "Monsterbewerkingsmethode.Omschrijving",
    mbm.codespace AS "Monsterbewerkingsmethode.codespace",
    bmm.code AS "Bemonsteringsmethode.Code",
    bmm.description AS "Bemonsteringsmethode.Omschrijving",
        CASE
            WHEN (bmm.code IS NULL) THEN NULL::text
            ELSE 'www.aquo.nl'::text
        END AS "Bemonsteringsmethode.codespace",
        CASE
            WHEN (frac.code IS NULL) THEN biota.code
            ELSE frac.code
        END AS "Monstercriterium.Code",
    var.code AS "veldapparaat.Code",
    var.description AS "veldapparaat.Omschrijving",
    var.codespace AS "veldapparaat.Codespace",
    to_char(smpl.sampling_time, 'YYYY-MM-DD'::text) AS "Monsternemingsdatum",
    to_char(smpl.sampling_time, 'HH24:MM:SS'::text) AS "Monsternemingstijd",
    NULL::integer AS "Monster.Tijd_UTCoffset",
    'EPSG4258'::text AS "ReferentieHorizontaal.code",
    smpl.remarks AS "Monster.Opmerking",
        CASE
            WHEN (mno_smpl.wkrv_id IS NULL) THEN NULL::text
            ELSE ((('NL'::text || (smpl_nst.code)::text) || '_'::text) || (mno_smpl.inspire_id_local_id)::text)
        END AS "GerelateerdMonsterobject",
        CASE
            WHEN (mno_smpl.wkrv_id IS NULL) THEN (NULL::text)::character varying
            ELSE rsfr.code
        END AS "GerelateerdMonsterRol.id",
    obs.obs_id AS "Meetwaarde.Identificatie",
    ('NL'::text || (mpn_nst.code)::text) AS "Meetwaarde.Namespace",
    mno.wkrv_id AS "Meetwaarde.Versie",
    opt.grh_code AS "Grootheid.code",
    opt.grh_omschrijving AS "Grootheid.omschrijving",
    opt.typ_code AS "Typering.code",
    opt.typ_omschrijving AS "Typering.omschrijving",
        CASE
            WHEN (opt.txg_omschrijving IS NOT NULL) THEN 'Biotaxon'::text
            WHEN (opt.chs_code IS NOT NULL) THEN 'ChemischeStof'::text
            WHEN (opt.obj_code IS NOT NULL) THEN 'Object'::text
            ELSE NULL::text
        END AS "Parameter.Groep",
        CASE
            WHEN (opt.txg_omschrijving IS NOT NULL) THEN (NULL::text)::character varying
            WHEN (opt.chs_code IS NOT NULL) THEN opt.chs_code
            WHEN (opt.obj_code IS NOT NULL) THEN opt.obj_code
            ELSE NULL::character varying
        END AS "Parameter.Code",
        CASE
            WHEN (opt.txg_omschrijving IS NOT NULL) THEN opt.txg_omschrijving
            WHEN (opt.chs_code IS NOT NULL) THEN opt.chs_naam
            WHEN (opt.obj_code IS NOT NULL) THEN opt.obj_omschrijving
            ELSE NULL::character varying
        END AS "Parameter.Omschrijving",
    eenh.code AS "Eenheid.code",
    eenh.omschrijving AS "Eenheid.omschrijving",
    opt.hdh_code AS "Hoedanigheid.code",
    opt.hdh_omschrijving AS "Hoedanigheid.omschrijving",
    wbm.code AS "Waardebewerkigngsmethode.code",
        CASE
            WHEN (wbm.code IS NULL) THEN NULL::text
            ELSE 'www.aquo.nl'::text
        END AS "Waardebewerkigngsmethode.codespace",
    wbpm.code AS "Waardebepalingsmethode.code",
        CASE
            WHEN (wbpm.code IS NULL) THEN NULL::text
            ELSE 'www.aquo.nl'::text
        END AS "Waardebepalingsmethode.codespace",
    to_char(obs.phenomenon_time_begin, 'YYYY-MM-DD'::text) AS "Begindatum",
    to_char(obs.phenomenon_time_begin, 'HH24:MM:SS'::text) AS "Begintijd",
    to_char(obs.phenomenon_time_end, 'YYYY-MM-DD'::text) AS "Einddatum",
    to_char(obs.phenomenon_time_end, 'HH24:MM:SS'::text) AS "Eindtijd",
    NULL::integer AS "Meetwaarde.Tijd_UTCoffset",
    to_char(obs.result_time, 'YYYY-MM-DD'::text) AS "Resultaatdatum",
    NULL::integer AS "Resultaat_UTCoffset",
    obs.limit_symbol_id AS "Limietsymbool",
    obs.numeric_value AS "Numeriekewaarde",
    obs.description AS "Alfanumeriekewaarde",
    kwaliteitsoordeel_type.code AS "Kwaliteitsoordeel.code",
    kwaliteitsoordeel_type.description AS "Kwaliteitsoordeel.omschrijving",
    mar.code AS "Meetapparaat.code",
        CASE
            WHEN (mar.code IS NULL) THEN NULL::text
            ELSE 'www.aquo.nl'::text
        END AS "Meetapparaat.codespace",
    bio.levensstadium_code AS "Levensstadium.code",
    bio.lengte_code AS "Lengteklasse.code",
    bio.geslacht_code AS "Geslachtcode",
    bio.verschijning_code AS "Verschijningsvorm.code",
    bio.levensvorm_code AS "Levensvorm.code",
    bio.gedrag_code AS "Gedrag.code",
        CASE
            WHEN (obx.obs_id_target IS NULL) THEN NULL::text
            ELSE ((('NL'::text || (mpn_nst.code)::text) || '_'::text) || (obx.obs_id_target)::text)
        END AS "GerelateerdObservatieobject",
    ocr.code AS "GerelateerdObservatieobjectRol.id",
    obs.remarks AS "Meetwaarde.Opmerking",
    indicator.additional_description AS "Indicator.EUOmschrijving",
    typi.code AS "Indicator.Code",
    typd.code AS "Descriptor.Code",
    descriptor.additional_description AS "Descriptor.EUOmschrijving"
   FROM ((((((((((((((((((((((((((((((((((domains.indicator_descriptor indicator
     JOIN public.observed_property_type opti ON ((indicator.opt_id = opti.opt_id)))
     JOIN public.typering_type typi ON ((opti.indicator_id = typi.typ_id)))
     JOIN domains.indicator_descriptor descriptor ON (((indicator.part_of_idd_id = descriptor.idd_id) AND (descriptor.part_of_idd_id IS NULL))))
     JOIN public.observed_property_type optd ON ((descriptor.opt_id = optd.opt_id)))
     JOIN public.typering_type typd ON ((optd.indicator_id = typd.typ_id)))
     JOIN monprog.quality_element_indicator_descriptor qeid ON ((qeid.idd_id = indicator.idd_id)))
     JOIN public.quality_element qem ON ((qem.qem_id = qeid.qem_id)))
     JOIN public.quality_element_observation qeo ON ((qeo.qem_id = qem.qem_id)))
     JOIN public.observation obs ON ((qeo.obs_id = obs.obs_id)))
     JOIN public.sample smpl ON ((smpl.smpl_id = obs.mno_id)))
     JOIN public.monitoring_object mno ON ((mno.mno_id = smpl.smpl_id)))
     JOIN public.compartiment_type cmp ON ((smpl.material_class_id = cmp.cptm_id)))
     LEFT JOIN public.hoedanigheid_type hdh_ud ON ((hdh_ud.hdh_id = smpl.upper_depth_condition_id)))
     LEFT JOIN public.hoedanigheid_type hdh_ld ON ((hdh_ld.hdh_id = smpl.lower_depth_condition_id)))
     LEFT JOIN public.taxon_type ON ((smpl.txn_id = taxon_type.txn_id)))
     LEFT JOIN domains.orgaan ON ((orgaan.org_id = smpl.organ_id)))
     LEFT JOIN public.hoedanigheid_type frac ON ((frac.hdh_id = smpl.fraction_criterium_id)))
     LEFT JOIN public.hoedanigheid_type biota ON ((biota.hdh_id = smpl.biota_criterium_id)))
     LEFT JOIN public.eenheid_type eenh_ud ON ((eenh_ud.eenh_id = smpl.upper_depth_uom_id)))
     LEFT JOIN public.eenheid_type eenh_ld ON ((eenh_ld.eenh_id = smpl.lower_depth_uom_id)))
     LEFT JOIN (((public.sampling_proces smp
     LEFT JOIN domains.monsterbewerkingsmethode mbm ON ((mbm.mbm_id = smp.sampling_method_id)))
     LEFT JOIN domains.bemonsteringsmethode bmm ON ((bmm.bmm_id = smp.sampling_processing_method_id)))
     LEFT JOIN domains.veldapparaat var ON ((var.var_id = smp.var_id))) ON ((smp.smp_id = smpl.smp_id)))
     LEFT JOIN public.related_sampling_feature rel_smpl ON ((smpl.smpl_id = rel_smpl.mnf_id_source)))
     LEFT JOIN public.sample smpl2 ON ((smpl.smpl_id = rel_smpl.mnf_id_target)))
     LEFT JOIN (public.monitoring_object mno_mpn
     JOIN public.namespace_type mpn_nst ON ((mpn_nst.ns_id = mno_mpn.inspire_id_namespace_id))) ON (((mno_mpn.mno_id = rel_smpl.mnf_id_target) AND ((mno_mpn.monitoring_object_type)::text <> 'Sample'::text))))
     LEFT JOIN (public.monitoring_object mno_smpl
     JOIN public.namespace_type smpl_nst ON ((smpl_nst.ns_id = mno_smpl.inspire_id_namespace_id))) ON (((smpl2.smpl_id = mno_smpl.mno_id) AND ((mno_smpl.monitoring_object_type)::text = 'Sample'::text))))
     LEFT JOIN public.rel_samp_feat_role_type rsfr ON ((rsfr.rsfr_id = rel_smpl.role_id)))
     LEFT JOIN public.eenheid_type eenh ON ((eenh.eenh_id = obs.numeric_value_uom_id)))
     JOIN opt ON ((opt.opt_id = obs.observed_property_type)))
     LEFT JOIN public.kwaliteitsoordeel_type ON ((obs.quality_indicator_id = kwaliteitsoordeel_type.kwod_id)))
     LEFT JOIN ((public.observation_process obp
     LEFT JOIN public.waarde_bepalings_methode_type wbpm ON ((wbpm.wbpm_id = obp.wbpm_id)))
     LEFT JOIN (public.obs_process_meetapparaat opm
     JOIN domains.meetapparaat mar ON ((mar.mar_id = opm.mar_id))) ON ((opm.obp_id = obp.obp_id))) ON ((obp.obp_id = obs.result_nature_id)))
     LEFT JOIN bio ON ((bio.obs_id = obs.obs_id)))
     LEFT JOIN (public.observation_context obx
     JOIN public.obs_ctx_role_type ocr ON ((ocr.ocr_id = obx.role_id))) ON ((obx.obs_id_source = obs.obs_id)))
     LEFT JOIN public.waarde_bewerkings_methode_type wbm ON ((wbm.wbm_id = obs.value_processing_method_id)))
     LEFT JOIN ((public.observed_feature obf
     JOIN public.hydro_object hdo ON ((obf.hdo_id = hdo.hdo_id)))
     JOIN public.namespace_type ns_hdo ON ((hdo.inspire_id_namespace = ns_hdo.ns_id))) ON ((obs.obs_id = obf.obs_id)));


--
-- Name: sf_vw_krm_regels; Type: VIEW; Schema: krm; Owner: -
--

CREATE VIEW sf_vw_krm_regels AS
 SELECT txg.txg_id AS "txg.txg_id",
    txg.name AS "txg.name",
    txg.group_type AS "txg.group_type",
    txg.d_begin AS "txg.d_begin",
    txg.d_eind AS "txg.d_eind",
    txg.last_changed_date AS "txg.last_changed_date",
    txg.d_status AS "txg.d_status",
    ojg.ojg_id AS "ojg.ojg_id",
    ojg.name AS "ojg.name",
    ojg.group_type AS "ojg.group_type",
    ojg.d_begin AS "ojg.d_begin",
    ojg.d_eind AS "ojg.d_eind",
    ojg.last_changed_date AS "ojg.last_changed_date",
    ojg.d_status AS "ojg.d_status",
    ssg.ssg_id AS "ssg.ssg_id",
    ssg.name AS "ssg.name",
    ssg.group_type AS "ssg.group_type",
    ssg.d_begin AS "ssg.d_begin",
    ssg.d_eind AS "ssg.d_eind",
    ssg.last_changed_date AS "ssg.last_changed_date",
    ssg.d_status AS "ssg.d_status",
    opt.opt_id AS "opt.opt_id",
    opt.observed_property_type_class AS "opt.observed_property_type_class",
    opt.result_type AS "opt.result_type",
    opt.hoedanigheid_id AS "opt.hoedanigheid_id",
    opt.object_group_id AS "opt.object_group_id",
    opt.quantity_id AS "opt.quantity_id",
    opt.taxa_group_id AS "opt.taxa_group_id",
    opt.substance_group_id AS "opt.substance_group_id",
    opt.indicator_id AS "opt.indicator_id",
    opt.classification_group_id AS "opt.classification_group_id",
    opt.remarks AS "opt.remarks",
    opt.d_begin AS "opt.d_begin",
    opt.d_eind AS "opt.d_eind",
    opt.last_changed_date AS "opt.last_changed_date",
    opt.d_status AS "opt.d_status",
    hdh.hdh_id AS "hdh.hdh_id",
    hdh.code AS "hdh.code",
    hdh.omschrijving AS "hdh.omschrijving",
    hdh.d_begin AS "hdh.d_begin",
    hdh.d_eind AS "hdh.d_eind",
    hdh.last_changed_date AS "hdh.last_changed_date",
    hdh.d_status AS "hdh.d_status",
    hdh.id AS "hdh.id",
    grh.grh_id AS "grh.grh_id",
    grh.code AS "grh.code",
    grh.omschrijving AS "grh.omschrijving",
    grh.d_begin AS "grh.d_begin",
    grh.d_eind AS "grh.d_eind",
    grh.last_changed_date AS "grh.last_changed_date",
    grh.d_status AS "grh.d_status",
    grh.id AS "grh.id",
    typ.typ_id AS "typ.typ_id",
    typ.code AS "typ.code",
    typ.omschrijving AS "typ.omschrijving",
    typ.d_begin AS "typ.d_begin",
    typ.d_eind AS "typ.d_eind",
    typ.last_changed_date AS "typ.last_changed_date",
    typ.d_status AS "typ.d_status",
    typ.id AS "typ.id",
    clsg.clsg_id AS "clsg.clsg_id",
    clsg.code AS "clsg.code",
    clsg.description AS "clsg.description",
    clsg.d_begin AS "clsg.d_begin",
    clsg.d_eind AS "clsg.d_eind",
    clsg.last_changed_date AS "clsg.last_changed_date",
    clsg.d_status AS "clsg.d_status",
    qem.qem_id AS "qem.qem_id",
    qem.osc_id AS "qem.osc_id",
    qem.opt_id AS "qem.opt_id",
    qem.parameter_use_id AS "qem.parameter_use_id",
    qem.cycle_value AS "qem.cycle_value",
    qem.cycle_uom_id AS "qem.cycle_uom_id",
    qem.cycle_description AS "qem.cycle_description",
    qem.frequency_value AS "qem.frequency_value",
    qem.frequency_uom_id AS "qem.frequency_uom_id",
    qem.reason_deviation_program AS "qem.reason_deviation_program",
    qem.last_change_time AS "qem.last_change_time",
    qem.sampling_method_id AS "qem.sampling_method_id",
    qem.sampling_device_id AS "qem.sampling_device_id",
    qem.deviation_program_jn AS "qem.deviation_program_jn",
    qem.opt_uom_id AS "qem.opt_uom_id",
    qem.wbm_id AS "qem.wbm_id",
    qem.remark AS "qem.remark",
    ehd.eenh_id AS "ehd.eenh_id",
    ehd.code AS "ehd.code",
    ehd.omschrijving AS "ehd.omschrijving",
    ehd.d_begin AS "ehd.d_begin",
    ehd.d_eind AS "ehd.d_eind",
    ehd.last_changed_date AS "ehd.last_changed_date",
    ehd.d_status AS "ehd.d_status",
    ehd.id AS "ehd.id",
    var.var_id AS "var.var_id",
    var.code AS "var.code",
    var.description AS "var.description",
    var.d_begin AS "var.d_begin",
    var.d_eind AS "var.d_eind",
    var.last_changed_date AS "var.last_changed_date",
    var.d_status AS "var.d_status",
    var.id AS "var.id",
    var.codespace AS "var.codespace",
    var.groep AS "var.groep",
    wbm.wbm_id AS "wbm.wbm_id",
    wbm.code AS "wbm.code",
    wbm.omschrijving AS "wbm.omschrijving",
    wbm.d_begin AS "wbm.d_begin",
    wbm.d_eind AS "wbm.d_eind",
    wbm.last_changed_date AS "wbm.last_changed_date",
    wbm.d_status AS "wbm.d_status",
    wbm.id AS "wbm.id",
    bmm.bmm_id AS "bmm.bmm_id",
    bmm.code AS "bmm.code ",
    bmm.description AS "bmm.description",
    bmm.groep AS "bmm.groep",
    bmm.titel AS "bmm.titel",
    bmm.d_begin AS "bmm.d_begin",
    bmm.d_eind AS "bmm.d_eind ",
    bmm.last_changed_date AS "bmm.last_changed_date",
    bmm.d_status AS "bmm.d_status ",
    bmm.id AS "bmm.id ",
    osc.osc_id AS "osc.osc_id",
    osc.observing_time_begin AS "osc.observing_time_begin",
    osc.observing_time_end AS "osc.observing_time_end",
    osc.online_resource AS "osc.online_resource",
    osc.process_type_id AS "osc.process_type_id",
    osc.last_change_time AS "osc.last_change_time",
    osc.name AS "osc.name",
    osc.is_sample AS "osc.is_sample",
    osc.wkrv_id AS "osc.wkrv_id",
    moqe.moqe_id AS "moqe.moqe_id",
    moqe.mno_id AS "moqe.mno_id",
    moqe.qem_id AS "moqe.qem_id",
    mno.mno_id AS "mno.mno_id",
    mno.inspire_id_local_id AS "mno.inspire_id_local_id",
    mno.inspire_id_namespace_id AS "mno.inspire_id_namespace_id",
    mno.wkrv_id AS "mno.wkrv_id",
    mno.monitoring_object_type AS "mno.monitoring_object_type",
    mno.name AS "mno.name",
    mno.additional_description AS "mno.additional_description",
    mno.last_change_time AS "mno.last_change_time",
    mno.begin_lifespan_version AS "mno.begin_lifespan_version",
    mno.end_lifespan_version AS "mno.end_lifespan_version",
    mno.primary_geo_column AS "mno.primary_geo_column",
    mno.reason_change AS "mno.reason_change",
    mno.primary_geodetic_reference_id AS "mno.primary_geodetic_reference_id",
    pot.pot_id AS "pot.pot_id",
    pot.qem_id AS "pot.qem_id",
    pot.start_date AS "pot.start_date",
    pot.end_date AS "pot.end_date",
    pot.noof_samples AS "pot.noof_samples",
    pot.samples_bepalingsgrens_id AS "pot.samples_bepalingsgrens_id",
    pot.last_change_time AS "pot.last_change_time",
    bpg.bpg_id AS "bpg.bpg_id",
    bpg.code AS "bpg.code",
    bpg.omschrijving AS "bpg.omschrijving",
    bpg.d_begin AS "bpg.d_begin",
    bpg.d_eind AS "bpg.d_eind",
    bpg.last_changed_date AS "bpg.last_changed_date",
    bpg.d_status AS "bpg.d_status"
   FROM (((((((((((((((((public.observed_property_type opt
     LEFT JOIN public.taxa_group txg ON ((opt.taxa_group_id = txg.txg_id)))
     LEFT JOIN public.object_group ojg ON ((opt.object_group_id = ojg.ojg_id)))
     LEFT JOIN public.substance_group ssg ON ((opt.substance_group_id = ssg.ssg_id)))
     LEFT JOIN public.hoedanigheid_type hdh ON ((hdh.hdh_id = opt.hoedanigheid_id)))
     LEFT JOIN public.grootheid_type grh ON ((grh.grh_id = opt.quantity_id)))
     LEFT JOIN public.typering_type typ ON ((typ.typ_id = opt.indicator_id)))
     LEFT JOIN public.classification_group_type clsg ON ((clsg.clsg_id = opt.classification_group_id)))
     JOIN public.quality_element qem ON ((qem.opt_id = opt.opt_id)))
     LEFT JOIN public.eenheid_type ehd ON ((ehd.eenh_id = qem.opt_uom_id)))
     LEFT JOIN domains.veldapparaat var ON ((var.var_id = qem.sampling_device_id)))
     LEFT JOIN public.waarde_bewerkings_methode_type wbm ON ((wbm.wbm_id = qem.wbm_id)))
     LEFT JOIN domains.bemonsteringsmethode bmm ON ((bmm.bmm_id = qem.sampling_method_id)))
     LEFT JOIN public.observing_capability osc ON ((osc.osc_id = qem.osc_id)))
     LEFT JOIN public.monitoring_object_quality_element moqe ON ((moqe.qem_id = qem.qem_id)))
     LEFT JOIN public.monitoring_object mno ON ((mno.mno_id = moqe.mno_id)))
     LEFT JOIN monprog.planned_observation_time pot ON ((pot.qem_id = qem.qem_id)))
     LEFT JOIN public.bepaling_grens_type bpg ON ((bpg.bpg_id = pot.samples_bepalingsgrens_id)));


--
-- Name: vw_krm_meetpunten_g; Type: VIEW; Schema: krm; Owner: -
--

CREATE VIEW vw_krm_meetpunten_g AS
 SELECT DISTINCT ON (mno.mno_id, typi.code) mno.geometry_etrs89,
    ((osc.osc_id)::text || (obs.obs_id)::text) AS unique_key,
    mno.mno_id,
    ((('NL'::text || (mno_nst.code)::text) || '_'::text) || (mno.inspire_id_local_id)::text) AS "Meetpunt.Identificatie",
    indicator.additional_description AS "Indicator.EUOmschrijving",
    typi.code AS "Indicator.Code",
    typd.code AS "Descriptor.Code",
    descriptor.additional_description AS "Descriptor.EUOmschrijving"
   FROM (((((((((((domains.indicator_descriptor indicator
     JOIN public.observed_property_type opti ON ((indicator.opt_id = opti.opt_id)))
     JOIN public.typering_type typi ON ((opti.indicator_id = typi.typ_id)))
     JOIN domains.indicator_descriptor descriptor ON (((indicator.part_of_idd_id = descriptor.idd_id) AND (descriptor.part_of_idd_id IS NULL))))
     JOIN public.observed_property_type optd ON ((descriptor.opt_id = optd.opt_id)))
     JOIN public.typering_type typd ON ((optd.indicator_id = typd.typ_id)))
     JOIN monprog.quality_element_indicator_descriptor qeid ON ((qeid.idd_id = indicator.idd_id)))
     JOIN public.quality_element qem ON ((qem.qem_id = qeid.qem_id)))
     JOIN public.observing_capability osc ON ((osc.osc_id = qem.osc_id)))
     JOIN public.observing_capability_observation oco ON ((oco.osc_id = osc.osc_id)))
     JOIN public.observation obs ON ((oco.obs_id = obs.obs_id)))
     JOIN ((public.monitoring_object mno
     LEFT JOIN (public.monitored_compartiment
     JOIN public.compartiment_type ON ((monitored_compartiment.cptm_id = compartiment_type.cptm_id))) ON ((monitored_compartiment.mno_id = mno.mno_id)))
     JOIN public.namespace_type mno_nst ON ((mno_nst.ns_id = mno.inspire_id_namespace_id))) ON (((mno.mno_id = obs.mno_id) AND ((mno.monitoring_object_type)::text <> 'Sample'::text))))
UNION ALL
 SELECT DISTINCT ON (mno_mpn.mno_id, typi.code) mno.geometry_etrs89,
    ((osc.osc_id)::text || (obs.obs_id)::text) AS unique_key,
    mno_mpn.mno_id,
    ((('NL'::text || (mpn_nst.code)::text) || '_'::text) || (mno_mpn.inspire_id_local_id)::text) AS "Meetpunt.Identificatie",
    indicator.additional_description AS "Indicator.EUOmschrijving",
    typi.code AS "Indicator.Code",
    typd.code AS "Descriptor.Code",
    descriptor.additional_description AS "Descriptor.EUOmschrijving"
   FROM (((((((((((((((((domains.indicator_descriptor indicator
     JOIN public.observed_property_type opti ON ((indicator.opt_id = opti.opt_id)))
     JOIN public.typering_type typi ON ((opti.indicator_id = typi.typ_id)))
     JOIN domains.indicator_descriptor descriptor ON (((indicator.part_of_idd_id = descriptor.idd_id) AND (descriptor.part_of_idd_id IS NULL))))
     JOIN public.observed_property_type optd ON ((descriptor.opt_id = optd.opt_id)))
     JOIN public.typering_type typd ON ((optd.indicator_id = typd.typ_id)))
     JOIN monprog.quality_element_indicator_descriptor qeid ON ((qeid.idd_id = indicator.idd_id)))
     JOIN public.quality_element qem ON ((qem.qem_id = qeid.qem_id)))
     JOIN public.observing_capability osc ON ((osc.osc_id = qem.osc_id)))
     JOIN public.observing_capability_observation oco ON ((oco.osc_id = osc.osc_id)))
     JOIN public.observation obs ON ((oco.obs_id = obs.obs_id)))
     JOIN public.sample smpl ON ((smpl.smpl_id = obs.mno_id)))
     JOIN public.monitoring_object mno ON ((mno.mno_id = smpl.smpl_id)))
     LEFT JOIN public.related_sampling_feature rel_smpl ON ((smpl.smpl_id = rel_smpl.mnf_id_source)))
     LEFT JOIN public.sample smpl2 ON ((smpl.smpl_id = rel_smpl.mnf_id_target)))
     LEFT JOIN (public.monitoring_object mno_mpn
     JOIN public.namespace_type mpn_nst ON ((mpn_nst.ns_id = mno_mpn.inspire_id_namespace_id))) ON (((mno_mpn.mno_id = rel_smpl.mnf_id_target) AND ((mno_mpn.monitoring_object_type)::text <> 'Sample'::text))))
     LEFT JOIN (public.monitoring_object mno_smpl
     JOIN public.namespace_type smpl_nst ON ((smpl_nst.ns_id = mno_smpl.inspire_id_namespace_id))) ON (((smpl2.smpl_id = mno_smpl.mno_id) AND ((mno_smpl.monitoring_object_type)::text = 'Sample'::text))))
     LEFT JOIN public.rel_samp_feat_role_type rsfr ON ((rsfr.rsfr_id = rel_smpl.role_id)))
  ORDER BY 2;


--
-- Name: vw_krm_metingen_g; Type: VIEW; Schema: krm; Owner: -
--

CREATE VIEW vw_krm_metingen_g AS
 WITH bio AS (
         SELECT bio.obs_id,
            gedrag.code AS gedrag_code,
            geslacht.code AS geslacht_code,
            lengte.code AS lengte_code,
            levensstadium.code AS levensstadium_code,
            levensvorm.code AS levensvorm_code,
            verschijning.code AS verschijning_code
           FROM ((((((public.bio_observation bio
             LEFT JOIN public.hoedanigheid_type gedrag ON (((bio.gedrag_id = gedrag.hdh_id) AND (bio.gedrag_id IS NOT NULL))))
             LEFT JOIN public.hoedanigheid_type geslacht ON (((bio.geslacht_id = geslacht.hdh_id) AND (bio.geslacht_id IS NOT NULL))))
             LEFT JOIN public.hoedanigheid_type lengte ON (((bio.lengte_klasse_id = lengte.hdh_id) AND (bio.lengte_klasse_id IS NOT NULL))))
             LEFT JOIN public.hoedanigheid_type levensstadium ON (((bio.levensstadium_id = levensstadium.hdh_id) AND (bio.levensstadium_id IS NOT NULL))))
             LEFT JOIN public.hoedanigheid_type levensvorm ON (((bio.levensvorm_id = levensvorm.hdh_id) AND (bio.levensvorm_id IS NOT NULL))))
             LEFT JOIN public.hoedanigheid_type verschijning ON (((bio.verschijningsvorm_id = verschijning.hdh_id) AND (bio.verschijningsvorm_id IS NOT NULL))))
          WHERE ((bio.gedrag_id IS NOT NULL) AND (bio.geslacht_id IS NOT NULL) AND (bio.lengte_klasse_id IS NOT NULL) AND (bio.levensstadium_id IS NOT NULL) AND (bio.levensvorm_id IS NOT NULL) AND (bio.verschijningsvorm_id IS NOT NULL))
        ), opt AS (
         SELECT opt.opt_id,
            grh.code AS grh_code,
            grh.omschrijving AS grh_omschrijving,
            typ.code AS typ_code,
            typ.omschrijving AS typ_omschrijving,
            txt.omschrijving AS txg_omschrijving,
            chs.code AS chs_code,
            chs.naam AS chs_naam,
            obj.code AS obj_code,
            obj.omschrijving AS obj_omschrijving,
            hdh.code AS hdh_code,
            hdh.omschrijving AS hdh_omschrijving
           FROM ((((((public.observed_property_type opt
             LEFT JOIN public.grootheid_type grh ON (((grh.grh_id = opt.quantity_id) AND (opt.quantity_id IS NOT NULL))))
             LEFT JOIN public.typering_type typ ON (((typ.typ_id = opt.indicator_id) AND (opt.indicator_id IS NOT NULL))))
             LEFT JOIN public.hoedanigheid_type hdh ON (((hdh.hdh_id = opt.hoedanigheid_id) AND (opt.hoedanigheid_id IS NOT NULL))))
             LEFT JOIN ((public.taxa_group txg
             JOIN public.taxa_group_element tge ON ((tge.txg_id = txg.txg_id)))
             JOIN public.taxon_type txt ON ((txt.txn_id = tge.txn_id))) ON (((txg.txg_id = opt.taxa_group_id) AND ((txg.group_type)::text = 'I'::text))))
             LEFT JOIN ((public.substance_group ssg
             JOIN public.substance_group_element ssge ON ((ssge.ssge_id = ssg.ssg_id)))
             JOIN public.chemische_stof_type chs ON ((chs.chs_id = ssge.chs_id))) ON (((ssg.ssg_id = opt.substance_group_id) AND ((ssg.group_type)::text = 'I'::text))))
             LEFT JOIN ((public.object_group ojg
             JOIN public.object_group_element ojge ON ((ojg.ojg_id = ojge.ojg_id)))
             JOIN public.object_type obj ON ((obj.obj_id = ojge.obj_id))) ON (((ojg.ojg_id = opt.object_group_id) AND ((ojg.group_type)::text = 'I'::text))))
        )
 SELECT mno.geometry_etrs89,
    ((osc.osc_id)::text || (obs.obs_id)::text) AS unique_key,
    ((('NL'::text || (mno_nst.code)::text) || '_'::text) || (mno.inspire_id_local_id)::text) AS "Meetpunt.Identificatie",
    public.st_x(public.st_transform(public.st_centroid(mno.geometry_etrs89), 4258)) AS "GeometriePunt.X",
    public.st_y(public.st_transform(public.st_centroid(mno.geometry_etrs89), 4258)) AS "GeometriePunt.Y",
        CASE
            WHEN (obf.obs_id IS NOT NULL) THEN (('NL'::text || (ns_hdo.code)::text) || (hdo.inspire_id_local_id)::text)
            ELSE
            CASE
                WHEN ((mno.monitoring_object_type)::text = 'Sample'::text) THEN NULL::text
                ELSE ((('NL'::text || (mno_nst.code)::text) || '_AQUO_COMPARTIMENT:'::text) || (compartiment_type.code)::text)
            END
        END AS "Geoobject.Identificatie",
    NULL::text AS "Monster.Identificatie",
    NULL::text AS "Monster.Namespace",
    NULL::integer AS "Monster.Versie",
    NULL::text AS "Compartiment.Code",
    NULL::text AS "Compartiment.Omschrijving",
    NULL::text AS "Orgaan.Code",
    NULL::text AS "Orgaan.Omschrijving",
    NULL::text AS "Organisme.Naam",
    NULL::numeric AS "BeginDiepte_m",
    NULL::numeric AS "EindDiepte_m",
    NULL::text AS "ReferentieVlak.Code",
    NULL::text AS "Monsterbewerkingsmethode.Code",
    NULL::text AS "Monsterbewerkingsmethode.Omschrijving",
    NULL::text AS "Monsterbewerkingsmethode.codespace",
    NULL::text AS "Bemonsteringsmethode.Code",
    NULL::text AS "Bemonsteringsmethode.Omschrijving",
    NULL::text AS "Bemonsteringsmethode.codespace",
    NULL::text AS "Monstercriterium.Code",
    NULL::text AS "veldapparaat.Code",
    NULL::text AS "veldapparaat.Omschrijving",
    NULL::text AS "veldapparaat.Codespace",
    NULL::text AS "Monsternemingsdatum",
    NULL::text AS "Monsternemingstijd",
    NULL::integer AS "Monster.Tijd_UTCoffset",
    NULL::text AS "ReferentieHorizontaal.code",
    NULL::text AS "Monster.Opmerking",
    NULL::text AS "GerelateerdMonsterobject",
    NULL::text AS "GerelateerdMonsterRol.id",
    obs.obs_id AS "Meetwaarde.Identificatie",
    ('NL'::text || (mno_nst.code)::text) AS "Meetwaarde.Namespace",
    mno.wkrv_id AS "Meetwaarde.Versie",
    opt.grh_code AS "Grootheid.code",
    opt.grh_omschrijving AS "Grootheid.omschrijving",
    opt.typ_code AS "Typering.code",
    opt.typ_omschrijving AS "Typering.omschrijving",
        CASE
            WHEN (opt.txg_omschrijving IS NOT NULL) THEN 'Biotaxon'::text
            WHEN (opt.chs_code IS NOT NULL) THEN 'ChemischeStof'::text
            WHEN (opt.obj_code IS NOT NULL) THEN 'Object'::text
            ELSE NULL::text
        END AS "Parameter.Groep",
        CASE
            WHEN (opt.txg_omschrijving IS NOT NULL) THEN (NULL::text)::character varying
            WHEN (opt.chs_code IS NOT NULL) THEN opt.chs_code
            WHEN (opt.obj_code IS NOT NULL) THEN opt.obj_code
            ELSE NULL::character varying
        END AS "Parameter.Code",
        CASE
            WHEN (opt.txg_omschrijving IS NOT NULL) THEN opt.txg_omschrijving
            WHEN (opt.chs_code IS NOT NULL) THEN opt.chs_naam
            WHEN (opt.obj_code IS NOT NULL) THEN opt.obj_omschrijving
            ELSE NULL::character varying
        END AS "Parameter.Omschrijving",
    eenh.code AS "Eenheid.code",
    eenh.omschrijving AS "Eenheid.omschrijving",
    opt.hdh_code AS "Hoedanigheid.code",
    opt.hdh_omschrijving AS "Hoedanigheid.omschrijving",
    wbm.code AS "Waardebewerkigngsmethode.code",
        CASE
            WHEN (wbm.code IS NULL) THEN NULL::text
            ELSE 'www.aquo.nl'::text
        END AS "Waardebewerkigngsmethode.codespace",
    wbpm.code AS "Waardebepalingsmethode.code",
        CASE
            WHEN (wbpm.code IS NULL) THEN NULL::text
            ELSE 'www.aquo.nl'::text
        END AS "Waardebepalingsmethode.codespace",
    to_char(obs.phenomenon_time_begin, 'YYYY-MM-DD'::text) AS "Begindatum",
    to_char(obs.phenomenon_time_begin, 'HH24:MM:SS'::text) AS "Begintijd",
    to_char(obs.phenomenon_time_end, 'YYYY-MM-DD'::text) AS "Einddatum",
    to_char(obs.phenomenon_time_end, 'HH24:MM:SS'::text) AS "Eindtijd",
    NULL::integer AS "Meetwaarde.Tijd_UTCoffset",
    to_char(obs.result_time, 'YYYY-MM-DD'::text) AS "Resultaatdatum",
    NULL::integer AS "Resultaat_UTCoffset",
    obs.limit_symbol_id AS "Limietsymbool",
    obs.numeric_value AS "Numeriekewaarde",
    obs.description AS "Alfanumeriekewaarde",
    kwaliteitsoordeel_type.code AS "Kwaliteitsoordeel.code",
    kwaliteitsoordeel_type.description AS "Kwaliteitsoordeel.omschrijving",
    mar.code AS "Meetapparaat.code",
        CASE
            WHEN (mar.code IS NULL) THEN NULL::text
            ELSE 'www.aquo.nl'::text
        END AS "Meetapparaat.codespace",
    bio.levensstadium_code AS "Levensstadium.code",
    bio.lengte_code AS "Lengteklasse.code",
    bio.geslacht_code AS "Geslachtcode",
    bio.verschijning_code AS "Verschijningsvorm.code",
    bio.levensvorm_code AS "Levensvorm.code",
    bio.gedrag_code AS "Gedrag.code",
        CASE
            WHEN (obx.obs_id_target IS NULL) THEN NULL::text
            ELSE ((('NL'::text || (mno_nst.code)::text) || '_'::text) || (obx.obs_id_target)::text)
        END AS "GerelateerdObservatieobject",
    ocr.code AS "GerelateerdObservatieobjectRol.id",
    obs.remarks AS "Meetwaarde.Opmerking",
    indicator.additional_description AS "Indicator.EUOmschrijving",
    typi.code AS "Indicator.Code",
    typd.code AS "Descriptor.Code",
    descriptor.additional_description AS "Descriptor.EUOmschrijving"
   FROM (((((((((((((((((((domains.indicator_descriptor indicator
     JOIN public.observed_property_type opti ON ((indicator.opt_id = opti.opt_id)))
     JOIN public.typering_type typi ON ((opti.indicator_id = typi.typ_id)))
     JOIN domains.indicator_descriptor descriptor ON (((indicator.part_of_idd_id = descriptor.idd_id) AND (descriptor.part_of_idd_id IS NULL))))
     JOIN public.observed_property_type optd ON ((descriptor.opt_id = optd.opt_id)))
     JOIN public.typering_type typd ON ((optd.indicator_id = typd.typ_id)))
     JOIN monprog.quality_element_indicator_descriptor qeid ON ((qeid.idd_id = indicator.idd_id)))
     JOIN public.quality_element qem ON ((qem.qem_id = qeid.qem_id)))
     JOIN public.observing_capability osc ON ((osc.osc_id = qem.osc_id)))
     JOIN public.observing_capability_observation oco ON ((oco.osc_id = osc.osc_id)))
     JOIN public.observation obs ON ((oco.obs_id = obs.obs_id)))
     JOIN ((public.monitoring_object mno
     LEFT JOIN (public.monitored_compartiment
     JOIN public.compartiment_type ON ((monitored_compartiment.cptm_id = compartiment_type.cptm_id))) ON ((monitored_compartiment.mno_id = mno.mno_id)))
     JOIN public.namespace_type mno_nst ON ((mno_nst.ns_id = mno.inspire_id_namespace_id))) ON (((mno.mno_id = obs.mno_id) AND ((mno.monitoring_object_type)::text <> 'Sample'::text))))
     LEFT JOIN public.eenheid_type eenh ON ((eenh.eenh_id = obs.numeric_value_uom_id)))
     JOIN opt ON ((opt.opt_id = obs.observed_property_type)))
     LEFT JOIN public.kwaliteitsoordeel_type ON ((obs.quality_indicator_id = kwaliteitsoordeel_type.kwod_id)))
     LEFT JOIN ((public.observation_process obp
     LEFT JOIN public.waarde_bepalings_methode_type wbpm ON ((wbpm.wbpm_id = obp.wbpm_id)))
     LEFT JOIN (public.obs_process_meetapparaat opm
     JOIN domains.meetapparaat mar ON ((mar.mar_id = opm.mar_id))) ON ((opm.obp_id = obp.obp_id))) ON ((obp.obp_id = obs.result_nature_id)))
     LEFT JOIN bio ON ((bio.obs_id = obs.obs_id)))
     LEFT JOIN (public.observation_context obx
     JOIN public.obs_ctx_role_type ocr ON ((ocr.ocr_id = obx.role_id))) ON ((obx.obs_id_source = obs.obs_id)))
     LEFT JOIN public.waarde_bewerkings_methode_type wbm ON ((wbm.wbm_id = obs.value_processing_method_id)))
     LEFT JOIN ((public.observed_feature obf
     JOIN public.hydro_object hdo ON ((obf.hdo_id = hdo.hdo_id)))
     JOIN public.namespace_type ns_hdo ON ((hdo.inspire_id_namespace = ns_hdo.ns_id))) ON (((obs.obs_id = obf.obs_id) AND (mno.wkrv_id = hdo.wkrv_id))))
UNION ALL
 SELECT mno.geometry_etrs89,
    ((osc.osc_id)::text || (obs.obs_id)::text) AS unique_key,
    ((('NL'::text || (mpn_nst.code)::text) || '_'::text) || (mno_mpn.inspire_id_local_id)::text) AS "Meetpunt.Identificatie",
    public.st_x(public.st_transform(public.st_centroid(mno.geometry_etrs89), 4258)) AS "GeometriePunt.X",
    public.st_y(public.st_transform(public.st_centroid(mno.geometry_etrs89), 4258)) AS "GeometriePunt.Y",
        CASE
            WHEN (obf.obs_id IS NOT NULL) THEN ((('NL'::text || (ns_hdo.code)::text) || '_'::text) || (hdo.inspire_id_local_id)::text)
            ELSE NULL::text
        END AS "Geoobject.Identificatie",
    mno.inspire_id_local_id AS "Monster.Identificatie",
    mpn_nst.code AS "Monster.Namespace",
    mno.wkrv_id AS "Monster.Versie",
    cmp.code AS "Compartiment.Code",
    cmp.description AS "Compartiment.Omschrijving",
    orgaan.code AS "Orgaan.Code",
    orgaan.description AS "Orgaan.Omschrijving",
    taxon_type.omschrijving AS "Organisme.Naam",
    smpl.upper_depth_value AS "BeginDiepte_m",
    smpl.lower_depth_value AS "EindDiepte_m",
        CASE
            WHEN (hdh_ud.hdh_id IS NULL) THEN
            CASE
                WHEN (hdh_ld.hdh_id IS NULL) THEN (NULL::text)::character varying
                ELSE hdh_ld.code
            END
            ELSE hdh_ud.code
        END AS "ReferentieVlak.Code",
    mbm.code AS "Monsterbewerkingsmethode.Code",
    mbm.description AS "Monsterbewerkingsmethode.Omschrijving",
    mbm.codespace AS "Monsterbewerkingsmethode.codespace",
    bmm.code AS "Bemonsteringsmethode.Code",
    bmm.description AS "Bemonsteringsmethode.Omschrijving",
        CASE
            WHEN (bmm.code IS NULL) THEN NULL::text
            ELSE 'www.aquo.nl'::text
        END AS "Bemonsteringsmethode.codespace",
        CASE
            WHEN (frac.code IS NULL) THEN biota.code
            ELSE frac.code
        END AS "Monstercriterium.Code",
    var.code AS "veldapparaat.Code",
    var.description AS "veldapparaat.Omschrijving",
    var.codespace AS "veldapparaat.Codespace",
    to_char(smpl.sampling_time, 'YYYY-MM-DD'::text) AS "Monsternemingsdatum",
    to_char(smpl.sampling_time, 'HH24:MM:SS'::text) AS "Monsternemingstijd",
    NULL::integer AS "Monster.Tijd_UTCoffset",
    'EPSG4258'::text AS "ReferentieHorizontaal.code",
    smpl.remarks AS "Monster.Opmerking",
        CASE
            WHEN (mno_smpl.wkrv_id IS NULL) THEN NULL::text
            ELSE ((('NL'::text || (smpl_nst.code)::text) || '_'::text) || (mno_smpl.inspire_id_local_id)::text)
        END AS "GerelateerdMonsterobject",
        CASE
            WHEN (mno_smpl.wkrv_id IS NULL) THEN (NULL::text)::character varying
            ELSE rsfr.code
        END AS "GerelateerdMonsterRol.id",
    obs.obs_id AS "Meetwaarde.Identificatie",
    ('NL'::text || (mpn_nst.code)::text) AS "Meetwaarde.Namespace",
    mno.wkrv_id AS "Meetwaarde.Versie",
    opt.grh_code AS "Grootheid.code",
    opt.grh_omschrijving AS "Grootheid.omschrijving",
    opt.typ_code AS "Typering.code",
    opt.typ_omschrijving AS "Typering.omschrijving",
        CASE
            WHEN (opt.txg_omschrijving IS NOT NULL) THEN 'Biotaxon'::text
            WHEN (opt.chs_code IS NOT NULL) THEN 'ChemischeStof'::text
            WHEN (opt.obj_code IS NOT NULL) THEN 'Object'::text
            ELSE NULL::text
        END AS "Parameter.Groep",
        CASE
            WHEN (opt.txg_omschrijving IS NOT NULL) THEN (NULL::text)::character varying
            WHEN (opt.chs_code IS NOT NULL) THEN opt.chs_code
            WHEN (opt.obj_code IS NOT NULL) THEN opt.obj_code
            ELSE NULL::character varying
        END AS "Parameter.Code",
        CASE
            WHEN (opt.txg_omschrijving IS NOT NULL) THEN opt.txg_omschrijving
            WHEN (opt.chs_code IS NOT NULL) THEN opt.chs_naam
            WHEN (opt.obj_code IS NOT NULL) THEN opt.obj_omschrijving
            ELSE NULL::character varying
        END AS "Parameter.Omschrijving",
    eenh.code AS "Eenheid.code",
    eenh.omschrijving AS "Eenheid.omschrijving",
    opt.hdh_code AS "Hoedanigheid.code",
    opt.hdh_omschrijving AS "Hoedanigheid.omschrijving",
    wbm.code AS "Waardebewerkigngsmethode.code",
        CASE
            WHEN (wbm.code IS NULL) THEN NULL::text
            ELSE 'www.aquo.nl'::text
        END AS "Waardebewerkigngsmethode.codespace",
    wbpm.code AS "Waardebepalingsmethode.code",
        CASE
            WHEN (wbpm.code IS NULL) THEN NULL::text
            ELSE 'www.aquo.nl'::text
        END AS "Waardebepalingsmethode.codespace",
    to_char(obs.phenomenon_time_begin, 'YYYY-MM-DD'::text) AS "Begindatum",
    to_char(obs.phenomenon_time_begin, 'HH24:MM:SS'::text) AS "Begintijd",
    to_char(obs.phenomenon_time_end, 'YYYY-MM-DD'::text) AS "Einddatum",
    to_char(obs.phenomenon_time_end, 'HH24:MM:SS'::text) AS "Eindtijd",
    NULL::integer AS "Meetwaarde.Tijd_UTCoffset",
    to_char(obs.result_time, 'YYYY-MM-DD'::text) AS "Resultaatdatum",
    NULL::integer AS "Resultaat_UTCoffset",
    obs.limit_symbol_id AS "Limietsymbool",
    obs.numeric_value AS "Numeriekewaarde",
    obs.description AS "Alfanumeriekewaarde",
    kwaliteitsoordeel_type.code AS "Kwaliteitsoordeel.code",
    kwaliteitsoordeel_type.description AS "Kwaliteitsoordeel.omschrijving",
    mar.code AS "Meetapparaat.code",
        CASE
            WHEN (mar.code IS NULL) THEN NULL::text
            ELSE 'www.aquo.nl'::text
        END AS "Meetapparaat.codespace",
    bio.levensstadium_code AS "Levensstadium.code",
    bio.lengte_code AS "Lengteklasse.code",
    bio.geslacht_code AS "Geslachtcode",
    bio.verschijning_code AS "Verschijningsvorm.code",
    bio.levensvorm_code AS "Levensvorm.code",
    bio.gedrag_code AS "Gedrag.code",
        CASE
            WHEN (obx.obs_id_target IS NULL) THEN NULL::text
            ELSE ((('NL'::text || (mpn_nst.code)::text) || '_'::text) || (obx.obs_id_target)::text)
        END AS "GerelateerdObservatieobject",
    ocr.code AS "GerelateerdObservatieobjectRol.id",
    obs.remarks AS "Meetwaarde.Opmerking",
    indicator.additional_description AS "Indicator.EUOmschrijving",
    typi.code AS "Indicator.Code",
    typd.code AS "Descriptor.Code",
    descriptor.additional_description AS "Descriptor.EUOmschrijving"
   FROM (((((((((((((((((((((((((((((((((((domains.indicator_descriptor indicator
     JOIN public.observed_property_type opti ON ((indicator.opt_id = opti.opt_id)))
     JOIN public.typering_type typi ON ((opti.indicator_id = typi.typ_id)))
     JOIN domains.indicator_descriptor descriptor ON (((indicator.part_of_idd_id = descriptor.idd_id) AND (descriptor.part_of_idd_id IS NULL))))
     JOIN public.observed_property_type optd ON ((descriptor.opt_id = optd.opt_id)))
     JOIN public.typering_type typd ON ((optd.indicator_id = typd.typ_id)))
     JOIN monprog.quality_element_indicator_descriptor qeid ON ((qeid.idd_id = indicator.idd_id)))
     JOIN public.quality_element qem ON ((qem.qem_id = qeid.qem_id)))
     JOIN public.observing_capability osc ON ((osc.osc_id = qem.osc_id)))
     JOIN public.observing_capability_observation oco ON ((oco.osc_id = osc.osc_id)))
     JOIN public.observation obs ON ((oco.obs_id = obs.obs_id)))
     JOIN public.sample smpl ON ((smpl.smpl_id = obs.mno_id)))
     JOIN public.monitoring_object mno ON ((mno.mno_id = smpl.smpl_id)))
     JOIN public.compartiment_type cmp ON ((smpl.material_class_id = cmp.cptm_id)))
     LEFT JOIN public.hoedanigheid_type hdh_ud ON ((hdh_ud.hdh_id = smpl.upper_depth_condition_id)))
     LEFT JOIN public.hoedanigheid_type hdh_ld ON ((hdh_ld.hdh_id = smpl.lower_depth_condition_id)))
     LEFT JOIN public.taxon_type ON ((smpl.txn_id = taxon_type.txn_id)))
     LEFT JOIN domains.orgaan ON ((orgaan.org_id = smpl.organ_id)))
     LEFT JOIN public.hoedanigheid_type frac ON ((frac.hdh_id = smpl.fraction_criterium_id)))
     LEFT JOIN public.hoedanigheid_type biota ON ((biota.hdh_id = smpl.biota_criterium_id)))
     LEFT JOIN public.eenheid_type eenh_ud ON ((eenh_ud.eenh_id = smpl.upper_depth_uom_id)))
     LEFT JOIN public.eenheid_type eenh_ld ON ((eenh_ld.eenh_id = smpl.lower_depth_uom_id)))
     LEFT JOIN (((public.sampling_proces smp
     LEFT JOIN domains.monsterbewerkingsmethode mbm ON ((mbm.mbm_id = smp.sampling_method_id)))
     LEFT JOIN domains.bemonsteringsmethode bmm ON ((bmm.bmm_id = smp.sampling_processing_method_id)))
     LEFT JOIN domains.veldapparaat var ON ((var.var_id = smp.var_id))) ON ((smp.smp_id = smpl.smp_id)))
     LEFT JOIN public.related_sampling_feature rel_smpl ON ((smpl.smpl_id = rel_smpl.mnf_id_source)))
     LEFT JOIN public.sample smpl2 ON ((smpl.smpl_id = rel_smpl.mnf_id_target)))
     LEFT JOIN (public.monitoring_object mno_mpn
     JOIN public.namespace_type mpn_nst ON ((mpn_nst.ns_id = mno_mpn.inspire_id_namespace_id))) ON (((mno_mpn.mno_id = rel_smpl.mnf_id_target) AND ((mno_mpn.monitoring_object_type)::text <> 'Sample'::text))))
     LEFT JOIN (public.monitoring_object mno_smpl
     JOIN public.namespace_type smpl_nst ON ((smpl_nst.ns_id = mno_smpl.inspire_id_namespace_id))) ON (((smpl2.smpl_id = mno_smpl.mno_id) AND ((mno_smpl.monitoring_object_type)::text = 'Sample'::text))))
     LEFT JOIN public.rel_samp_feat_role_type rsfr ON ((rsfr.rsfr_id = rel_smpl.role_id)))
     LEFT JOIN public.eenheid_type eenh ON ((eenh.eenh_id = obs.numeric_value_uom_id)))
     JOIN opt ON ((opt.opt_id = obs.observed_property_type)))
     LEFT JOIN public.kwaliteitsoordeel_type ON ((obs.quality_indicator_id = kwaliteitsoordeel_type.kwod_id)))
     LEFT JOIN ((public.observation_process obp
     LEFT JOIN public.waarde_bepalings_methode_type wbpm ON ((wbpm.wbpm_id = obp.wbpm_id)))
     LEFT JOIN (public.obs_process_meetapparaat opm
     JOIN domains.meetapparaat mar ON ((mar.mar_id = opm.mar_id))) ON ((opm.obp_id = obp.obp_id))) ON ((obp.obp_id = obs.result_nature_id)))
     LEFT JOIN bio ON ((bio.obs_id = obs.obs_id)))
     LEFT JOIN (public.observation_context obx
     JOIN public.obs_ctx_role_type ocr ON ((ocr.ocr_id = obx.role_id))) ON ((obx.obs_id_source = obs.obs_id)))
     LEFT JOIN public.waarde_bewerkings_methode_type wbm ON ((wbm.wbm_id = obs.value_processing_method_id)))
     LEFT JOIN ((public.observed_feature obf
     JOIN public.hydro_object hdo ON ((obf.hdo_id = hdo.hdo_id)))
     JOIN public.namespace_type ns_hdo ON ((hdo.inspire_id_namespace = ns_hdo.ns_id))) ON ((obs.obs_id = obf.obs_id)));


--
-- Name: vw_monprogs; Type: VIEW; Schema: krm; Owner: -
--

CREATE VIEW vw_monprogs AS
 SELECT txg.txg_id AS "txg.txg_id",
    txg.name AS "txg.name",
    txg.group_type AS "txg.group_type",
    txg.d_begin AS "txg.d_begin",
    txg.d_eind AS "txg.d_eind",
    txg.last_changed_date AS "txg.last_changed_date",
    txg.d_status AS "txg.d_status",
    ojg.ojg_id AS "ojg.ojg_id",
    ojg.name AS "ojg.name",
    ojg.group_type AS "ojg.group_type",
    ojg.d_begin AS "ojg.d_begin",
    ojg.d_eind AS "ojg.d_eind",
    ojg.last_changed_date AS "ojg.last_changed_date",
    ojg.d_status AS "ojg.d_status",
    ssg.ssg_id AS "ssg.ssg_id",
    ssg.name AS "ssg.name",
    ssg.group_type AS "ssg.group_type",
    ssg.d_begin AS "ssg.d_begin",
    ssg.d_eind AS "ssg.d_eind",
    ssg.last_changed_date AS "ssg.last_changed_date",
    ssg.d_status AS "ssg.d_status",
    opt.opt_id AS "opt.opt_id",
    opt.observed_property_type_class AS "opt.observed_property_type_class",
    opt.result_type AS "opt.result_type",
    opt.hoedanigheid_id AS "opt.hoedanigheid_id",
    opt.object_group_id AS "opt.object_group_id",
    opt.quantity_id AS "opt.quantity_id",
    opt.taxa_group_id AS "opt.taxa_group_id",
    opt.substance_group_id AS "opt.substance_group_id",
    opt.indicator_id AS "opt.indicator_id",
    opt.classification_group_id AS "opt.classification_group_id",
    opt.remarks AS "opt.remarks",
    opt.d_begin AS "opt.d_begin",
    opt.d_eind AS "opt.d_eind",
    opt.last_changed_date AS "opt.last_changed_date",
    opt.d_status AS "opt.d_status",
    hdh.hdh_id AS "hdh.hdh_id",
    hdh.code AS "hdh.code",
    hdh.omschrijving AS "hdh.omschrijving",
    hdh.d_begin AS "hdh.d_begin",
    hdh.d_eind AS "hdh.d_eind",
    hdh.last_changed_date AS "hdh.last_changed_date",
    hdh.d_status AS "hdh.d_status",
    hdh.id AS "hdh.id",
    grh.grh_id AS "grh.grh_id",
    grh.code AS "grh.code",
    grh.omschrijving AS "grh.omschrijving",
    grh.d_begin AS "grh.d_begin",
    grh.d_eind AS "grh.d_eind",
    grh.last_changed_date AS "grh.last_changed_date",
    grh.d_status AS "grh.d_status",
    grh.id AS "grh.id",
    typ.typ_id AS "typ.typ_id",
    typ.code AS "typ.code",
    typ.omschrijving AS "typ.omschrijving",
    typ.d_begin AS "typ.d_begin",
    typ.d_eind AS "typ.d_eind",
    typ.last_changed_date AS "typ.last_changed_date",
    typ.d_status AS "typ.d_status",
    typ.id AS "typ.id",
    clsg.clsg_id AS "clsg.clsg_id",
    clsg.code AS "clsg.code",
    clsg.description AS "clsg.description",
    clsg.d_begin AS "clsg.d_begin",
    clsg.d_eind AS "clsg.d_eind",
    clsg.last_changed_date AS "clsg.last_changed_date",
    clsg.d_status AS "clsg.d_status",
    qem.qem_id AS "qem.qem_id",
    qem.osc_id AS "qem.osc_id",
    qem.opt_id AS "qem.opt_id",
    qem.parameter_use_id AS "qem.parameter_use_id",
    qem.cycle_value AS "qem.cycle_value",
    qem.cycle_uom_id AS "qem.cycle_uom_id",
    qem.cycle_description AS "qem.cycle_description",
    qem.frequency_value AS "qem.frequency_value",
    qem.frequency_uom_id AS "qem.frequency_uom_id",
    qem.reason_deviation_program AS "qem.reason_deviation_program",
    qem.last_change_time AS "qem.last_change_time",
    qem.sampling_method_id AS "qem.sampling_method_id",
    qem.sampling_device_id AS "qem.sampling_device_id",
    qem.deviation_program_jn AS "qem.deviation_program_jn",
    qem.opt_uom_id AS "qem.opt_uom_id",
    qem.wbm_id AS "qem.wbm_id",
    qem.remark AS "qem.remark",
    ehd.eenh_id AS "ehd.eenh_id",
    ehd.code AS "ehd.code",
    ehd.omschrijving AS "ehd.omschrijving",
    ehd.d_begin AS "ehd.d_begin",
    ehd.d_eind AS "ehd.d_eind",
    ehd.last_changed_date AS "ehd.last_changed_date",
    ehd.d_status AS "ehd.d_status",
    ehd.id AS "ehd.id",
    var.var_id AS "var.var_id",
    var.code AS "var.code",
    var.description AS "var.description",
    var.d_begin AS "var.d_begin",
    var.d_eind AS "var.d_eind",
    var.last_changed_date AS "var.last_changed_date",
    var.d_status AS "var.d_status",
    var.id AS "var.id",
    var.codespace AS "var.codespace",
    var.groep AS "var.groep",
    wbm.wbm_id AS "wbm.wbm_id",
    wbm.code AS "wbm.code",
    wbm.omschrijving AS "wbm.omschrijving",
    wbm.d_begin AS "wbm.d_begin",
    wbm.d_eind AS "wbm.d_eind",
    wbm.last_changed_date AS "wbm.last_changed_date",
    wbm.d_status AS "wbm.d_status",
    wbm.id AS "wbm.id",
    bmm.bmm_id AS "bmm.bmm_id",
    bmm.code AS "bmm.code ",
    bmm.description AS "bmm.description",
    bmm.groep AS "bmm.groep",
    bmm.titel AS "bmm.titel",
    bmm.d_begin AS "bmm.d_begin",
    bmm.d_eind AS "bmm.d_eind ",
    bmm.last_changed_date AS "bmm.last_changed_date",
    bmm.d_status AS "bmm.d_status ",
    bmm.id AS "bmm.id ",
    osc.osc_id AS "osc.osc_id",
    osc.observing_time_begin AS "osc.observing_time_begin",
    osc.observing_time_end AS "osc.observing_time_end",
    osc.online_resource AS "osc.online_resource",
    osc.process_type_id AS "osc.process_type_id",
    osc.last_change_time AS "osc.last_change_time",
    osc.name AS "osc.name",
    osc.is_sample AS "osc.is_sample",
    osc.wkrv_id AS "osc.wkrv_id",
    moqe.moqe_id AS "moqe.moqe_id",
    moqe.mno_id AS "moqe.mno_id",
    moqe.qem_id AS "moqe.qem_id",
    mno.mno_id AS "mno.mno_id",
    mno.inspire_id_local_id AS "mno.inspire_id_local_id",
    mno.inspire_id_namespace_id AS "mno.inspire_id_namespace_id",
    mno.wkrv_id AS "mno.wkrv_id",
    mno.monitoring_object_type AS "mno.monitoring_object_type",
    mno.name AS "mno.name",
    mno.additional_description AS "mno.additional_description",
    mno.last_change_time AS "mno.last_change_time",
    mno.begin_lifespan_version AS "mno.begin_lifespan_version",
    mno.end_lifespan_version AS "mno.end_lifespan_version",
    mno.primary_geo_column AS "mno.primary_geo_column",
    mno.reason_change AS "mno.reason_change",
    mno.primary_geodetic_reference_id AS "mno.primary_geodetic_reference_id",
    pot.pot_id AS "pot.pot_id",
    pot.qem_id AS "pot.qem_id",
    pot.start_date AS "pot.start_date",
    pot.end_date AS "pot.end_date",
    pot.noof_samples AS "pot.noof_samples",
    pot.samples_bepalingsgrens_id AS "pot.samples_bepalingsgrens_id",
    pot.last_change_time AS "pot.last_change_time",
    bpg.bpg_id AS "bpg.bpg_id",
    bpg.code AS "bpg.code",
    bpg.omschrijving AS "bpg.omschrijving",
    bpg.d_begin AS "bpg.d_begin",
    bpg.d_eind AS "bpg.d_eind",
    bpg.last_changed_date AS "bpg.last_changed_date",
    bpg.d_status AS "bpg.d_status"
   FROM (((((((((((((((((public.observed_property_type opt
     LEFT JOIN public.taxa_group txg ON ((opt.taxa_group_id = txg.txg_id)))
     LEFT JOIN public.object_group ojg ON ((opt.object_group_id = ojg.ojg_id)))
     LEFT JOIN public.substance_group ssg ON ((opt.substance_group_id = ssg.ssg_id)))
     LEFT JOIN public.hoedanigheid_type hdh ON ((hdh.hdh_id = opt.hoedanigheid_id)))
     LEFT JOIN public.grootheid_type grh ON ((grh.grh_id = opt.quantity_id)))
     LEFT JOIN public.typering_type typ ON ((typ.typ_id = opt.indicator_id)))
     LEFT JOIN public.classification_group_type clsg ON ((clsg.clsg_id = opt.classification_group_id)))
     LEFT JOIN public.quality_element qem ON ((qem.opt_id = opt.opt_id)))
     LEFT JOIN public.eenheid_type ehd ON ((ehd.eenh_id = qem.opt_uom_id)))
     LEFT JOIN domains.veldapparaat var ON ((var.var_id = qem.sampling_device_id)))
     LEFT JOIN public.waarde_bewerkings_methode_type wbm ON ((wbm.wbm_id = qem.wbm_id)))
     LEFT JOIN domains.bemonsteringsmethode bmm ON ((bmm.bmm_id = qem.sampling_method_id)))
     LEFT JOIN public.observing_capability osc ON ((osc.osc_id = qem.osc_id)))
     LEFT JOIN public.monitoring_object_quality_element moqe ON ((moqe.qem_id = qem.qem_id)))
     LEFT JOIN public.monitoring_object mno ON ((mno.mno_id = moqe.mno_id)))
     LEFT JOIN monprog.planned_observation_time pot ON ((pot.qem_id = qem.qem_id)))
     LEFT JOIN public.bepaling_grens_type bpg ON ((bpg.bpg_id = pot.samples_bepalingsgrens_id)));


--
-- Name: vw_sf_krm_oud; Type: VIEW; Schema: krm; Owner: -
--

CREATE VIEW vw_sf_krm_oud AS
 WITH bio AS (
         SELECT bio.obs_id,
            gedrag.code AS gedrag_code,
            geslacht.code AS geslacht_code,
            lengte.code AS lengte_code,
            levensstadium.code AS levensstadium_code,
            levensvorm.code AS levensvorm_code,
            verschijning.code AS verschijning_code
           FROM ((((((public.bio_observation bio
             LEFT JOIN public.hoedanigheid_type gedrag ON (((bio.gedrag_id = gedrag.hdh_id) AND (bio.gedrag_id IS NOT NULL))))
             LEFT JOIN public.hoedanigheid_type geslacht ON (((bio.geslacht_id = geslacht.hdh_id) AND (bio.geslacht_id IS NOT NULL))))
             LEFT JOIN public.hoedanigheid_type lengte ON (((bio.lengte_klasse_id = lengte.hdh_id) AND (bio.lengte_klasse_id IS NOT NULL))))
             LEFT JOIN public.hoedanigheid_type levensstadium ON (((bio.levensstadium_id = levensstadium.hdh_id) AND (bio.levensstadium_id IS NOT NULL))))
             LEFT JOIN public.hoedanigheid_type levensvorm ON (((bio.levensvorm_id = levensvorm.hdh_id) AND (bio.levensvorm_id IS NOT NULL))))
             LEFT JOIN public.hoedanigheid_type verschijning ON (((bio.verschijningsvorm_id = verschijning.hdh_id) AND (bio.verschijningsvorm_id IS NOT NULL))))
          WHERE ((bio.gedrag_id IS NOT NULL) AND (bio.geslacht_id IS NOT NULL) AND (bio.lengte_klasse_id IS NOT NULL) AND (bio.levensstadium_id IS NOT NULL) AND (bio.levensvorm_id IS NOT NULL) AND (bio.verschijningsvorm_id IS NOT NULL))
        ), opt AS (
         SELECT opt.opt_id,
            grh.code AS grh_code,
            grh.omschrijving AS grh_omschrijving,
            typ.code AS typ_code,
            typ.omschrijving AS typ_omschrijving,
            txt.omschrijving AS txg_omschrijving,
            chs.code AS chs_code,
            chs.naam AS chs_naam,
            obj.code AS obj_code,
            obj.omschrijving AS obj_omschrijving,
            hdh.code AS hdh_code,
            hdh.omschrijving AS hdh_omschrijving
           FROM ((((((public.observed_property_type opt
             LEFT JOIN public.grootheid_type grh ON (((grh.grh_id = opt.quantity_id) AND (opt.quantity_id IS NOT NULL))))
             LEFT JOIN public.typering_type typ ON (((typ.typ_id = opt.indicator_id) AND (opt.indicator_id IS NOT NULL))))
             LEFT JOIN public.hoedanigheid_type hdh ON (((hdh.hdh_id = opt.hoedanigheid_id) AND (opt.hoedanigheid_id IS NOT NULL))))
             LEFT JOIN ((public.taxa_group txg
             JOIN public.taxa_group_element tge ON ((tge.txg_id = txg.txg_id)))
             JOIN public.taxon_type txt ON ((txt.txn_id = tge.txn_id))) ON (((txg.txg_id = opt.taxa_group_id) AND ((txg.group_type)::text = 'I'::text))))
             LEFT JOIN ((public.substance_group ssg
             JOIN public.substance_group_element ssge ON ((ssge.ssge_id = ssg.ssg_id)))
             JOIN public.chemische_stof_type chs ON ((chs.chs_id = ssge.chs_id))) ON (((ssg.ssg_id = opt.substance_group_id) AND ((ssg.group_type)::text = 'I'::text))))
             LEFT JOIN ((public.object_group ojg
             JOIN public.object_group_element ojge ON ((ojg.ojg_id = ojge.ojg_id)))
             JOIN public.object_type obj ON ((obj.obj_id = ojge.obj_id))) ON (((ojg.ojg_id = opt.object_group_id) AND ((ojg.group_type)::text = 'I'::text))))
        )
 SELECT mno.mno_id,
    qeid.qem_id,
    qeid.idd_id,
    ((osc.osc_id)::text || (obs.obs_id)::text) AS unique_key,
    ((('NL'::text || (mno_nst.code)::text) || '_'::text) || (mno.inspire_id_local_id)::text) AS "Meetpunt.Identificatie",
    public.st_x(public.st_transform(public.st_centroid(mno.geometry_etrs89), 4258)) AS "GeometriePunt.X",
    public.st_y(public.st_transform(public.st_centroid(mno.geometry_etrs89), 4258)) AS "GeometriePunt.Y",
        CASE
            WHEN (obf.obs_id IS NOT NULL) THEN (('NL'::text || (ns_hdo.code)::text) || (hdo.inspire_id_local_id)::text)
            ELSE
            CASE
                WHEN ((mno.monitoring_object_type)::text = 'Sample'::text) THEN NULL::text
                ELSE ((('NL'::text || (mno_nst.code)::text) || '_AQUO_COMPARTIMENT:'::text) || (compartiment_type.code)::text)
            END
        END AS "Geoobject.Identificatie",
    NULL::text AS "Monster.Identificatie",
    NULL::text AS "Monster.Namespace",
    NULL::integer AS "Monster.Versie",
    NULL::text AS "Compartiment.Code",
    NULL::text AS "Compartiment.Omschrijving",
    NULL::text AS "Orgaan.Code",
    NULL::text AS "Orgaan.Omschrijving",
    NULL::text AS "Organisme.Naam",
    NULL::numeric AS "BeginDiepte_m",
    NULL::numeric AS "EindDiepte_m",
    NULL::text AS "ReferentieVlak.Code",
    NULL::text AS "Monsterbewerkingsmethode.Code",
    NULL::text AS "Monsterbewerkingsmethode.Omschrijving",
    NULL::text AS "Monsterbewerkingsmethode.codespace",
    NULL::text AS "Bemonsteringsmethode.Code",
    NULL::text AS "Bemonsteringsmethode.Omschrijving",
    NULL::text AS "Bemonsteringsmethode.codespace",
    NULL::text AS "Monstercriterium.Code",
    NULL::text AS "veldapparaat.Code",
    NULL::text AS "veldapparaat.Omschrijving",
    NULL::text AS "veldapparaat.Codespace",
    NULL::text AS "Monsternemingsdatum",
    NULL::text AS "Monsternemingstijd",
    NULL::integer AS "Monster.Tijd_UTCoffset",
    NULL::text AS "ReferentieHorizontaal.code",
    NULL::text AS "Monster.Opmerking",
    NULL::text AS "GerelateerdMonsterobject",
    NULL::text AS "GerelateerdMonsterRol.id",
    obs.obs_id AS "Meetwaarde.Identificatie",
    ('NL'::text || (mno_nst.code)::text) AS "Meetwaarde.Namespace",
    mno.wkrv_id AS "Meetwaarde.Versie",
    opt.grh_code AS "Grootheid.code",
    opt.grh_omschrijving AS "Grootheid.omschrijving",
    opt.typ_code AS "Typering.code",
    opt.typ_omschrijving AS "Typering.omschrijving",
        CASE
            WHEN (opt.txg_omschrijving IS NOT NULL) THEN 'Biotaxon'::text
            WHEN (opt.chs_code IS NOT NULL) THEN 'ChemischeStof'::text
            WHEN (opt.obj_code IS NOT NULL) THEN 'Object'::text
            ELSE NULL::text
        END AS "Parameter.Groep",
        CASE
            WHEN (opt.txg_omschrijving IS NOT NULL) THEN (NULL::text)::character varying
            WHEN (opt.chs_code IS NOT NULL) THEN opt.chs_code
            WHEN (opt.obj_code IS NOT NULL) THEN opt.obj_code
            ELSE NULL::character varying
        END AS "Parameter.Code",
        CASE
            WHEN (opt.txg_omschrijving IS NOT NULL) THEN opt.txg_omschrijving
            WHEN (opt.chs_code IS NOT NULL) THEN opt.chs_naam
            WHEN (opt.obj_code IS NOT NULL) THEN opt.obj_omschrijving
            ELSE NULL::character varying
        END AS "Parameter.Omschrijving",
    eenh.code AS "Eenheid.code",
    eenh.omschrijving AS "Eenheid.omschrijving",
    opt.hdh_code AS "Hoedanigheid.code",
    opt.hdh_omschrijving AS "Hoedanigheid.omschrijving",
    wbm.code AS "Waardebewerkigngsmethode.code",
        CASE
            WHEN (wbm.code IS NULL) THEN NULL::text
            ELSE 'www.aquo.nl'::text
        END AS "Waardebewerkigngsmethode.codespace",
    wbpm.code AS "Waardebepalingsmethode.code",
        CASE
            WHEN (wbpm.code IS NULL) THEN NULL::text
            ELSE 'www.aquo.nl'::text
        END AS "Waardebepalingsmethode.codespace",
    to_char(obs.phenomenon_time_begin, 'YYYY-MM-DD'::text) AS "Begindatum",
    to_char(obs.phenomenon_time_begin, 'HH24:MM:SS'::text) AS "Begintijd",
    to_char(obs.phenomenon_time_end, 'YYYY-MM-DD'::text) AS "Einddatum",
    to_char(obs.phenomenon_time_end, 'HH24:MM:SS'::text) AS "Eindtijd",
    NULL::integer AS "Meetwaarde.Tijd_UTCoffset",
    to_char(obs.result_time, 'YYYY-MM-DD'::text) AS "Resultaatdatum",
    NULL::integer AS "Resultaat_UTCoffset",
    obs.limit_symbol_id AS "Limietsymbool",
    obs.numeric_value AS "Numeriekewaarde",
    obs.description AS "Alfanumeriekewaarde",
    kwaliteitsoordeel_type.code AS "Kwaliteitsoordeel.code",
    kwaliteitsoordeel_type.description AS "Kwaliteitsoordeel.omschrijving",
    mar.code AS "Meetapparaat.code",
        CASE
            WHEN (mar.code IS NULL) THEN NULL::text
            ELSE 'www.aquo.nl'::text
        END AS "Meetapparaat.codespace",
    bio.levensstadium_code AS "Levensstadium.code",
    bio.lengte_code AS "Lengteklasse.code",
    bio.geslacht_code AS "Geslachtcode",
    bio.verschijning_code AS "Verschijningsvorm.code",
    bio.levensvorm_code AS "Levensvorm.code",
    bio.gedrag_code AS "Gedrag.code",
        CASE
            WHEN (obx.obs_id_target IS NULL) THEN NULL::text
            ELSE ((('NL'::text || (mno_nst.code)::text) || '_'::text) || (obx.obs_id_target)::text)
        END AS "GerelateerdObservatieobject",
    ocr.code AS "GerelateerdObservatieobjectRol.id",
    obs.remarks AS "Meetwaarde.Opmerking",
    indicator.additional_description AS "Indicator.EUOmschrijving",
    typi.code AS "Indicator.Code",
    typd.code AS "Descriptor.Code",
    descriptor.additional_description AS "Descriptor.EUOmschrijving"
   FROM (((((((((((((((((((domains.indicator_descriptor indicator
     JOIN public.observed_property_type opti ON ((indicator.opt_id = opti.opt_id)))
     JOIN public.typering_type typi ON ((opti.indicator_id = typi.typ_id)))
     JOIN domains.indicator_descriptor descriptor ON (((indicator.part_of_idd_id = descriptor.idd_id) AND (descriptor.part_of_idd_id IS NULL))))
     JOIN public.observed_property_type optd ON ((descriptor.opt_id = optd.opt_id)))
     JOIN public.typering_type typd ON ((optd.indicator_id = typd.typ_id)))
     JOIN monprog.quality_element_indicator_descriptor qeid ON ((qeid.idd_id = indicator.idd_id)))
     JOIN public.quality_element qem ON ((qem.qem_id = qeid.qem_id)))
     JOIN public.observing_capability osc ON ((osc.osc_id = qem.osc_id)))
     JOIN public.observing_capability_observation oco ON ((oco.osc_id = osc.osc_id)))
     JOIN public.observation obs ON ((oco.obs_id = obs.obs_id)))
     JOIN ((public.monitoring_object mno
     LEFT JOIN (public.monitored_compartiment
     JOIN public.compartiment_type ON ((monitored_compartiment.cptm_id = compartiment_type.cptm_id))) ON ((monitored_compartiment.mno_id = mno.mno_id)))
     JOIN public.namespace_type mno_nst ON ((mno_nst.ns_id = mno.inspire_id_namespace_id))) ON (((mno.mno_id = obs.mno_id) AND ((mno.monitoring_object_type)::text <> 'Sample'::text))))
     LEFT JOIN public.eenheid_type eenh ON ((eenh.eenh_id = obs.numeric_value_uom_id)))
     JOIN opt ON ((opt.opt_id = obs.observed_property_type)))
     LEFT JOIN public.kwaliteitsoordeel_type ON ((obs.quality_indicator_id = kwaliteitsoordeel_type.kwod_id)))
     LEFT JOIN ((public.observation_process obp
     LEFT JOIN public.waarde_bepalings_methode_type wbpm ON ((wbpm.wbpm_id = obp.wbpm_id)))
     LEFT JOIN (public.obs_process_meetapparaat opm
     JOIN domains.meetapparaat mar ON ((mar.mar_id = opm.mar_id))) ON ((opm.obp_id = obp.obp_id))) ON ((obp.obp_id = obs.result_nature_id)))
     LEFT JOIN bio ON ((bio.obs_id = obs.obs_id)))
     LEFT JOIN (public.observation_context obx
     JOIN public.obs_ctx_role_type ocr ON ((ocr.ocr_id = obx.role_id))) ON ((obx.obs_id_source = obs.obs_id)))
     LEFT JOIN public.waarde_bewerkings_methode_type wbm ON ((wbm.wbm_id = obs.value_processing_method_id)))
     LEFT JOIN ((public.observed_feature obf
     JOIN public.hydro_object hdo ON ((obf.hdo_id = hdo.hdo_id)))
     JOIN public.namespace_type ns_hdo ON ((hdo.inspire_id_namespace = ns_hdo.ns_id))) ON (((obs.obs_id = obf.obs_id) AND (mno.wkrv_id = hdo.wkrv_id))))
UNION ALL
 SELECT mno.mno_id,
    qeid.qem_id,
    qeid.idd_id,
    ((osc.osc_id)::text || (obs.obs_id)::text) AS unique_key,
    ((('NL'::text || (mpn_nst.code)::text) || '_'::text) || (mno_mpn.inspire_id_local_id)::text) AS "Meetpunt.Identificatie",
    public.st_x(public.st_transform(public.st_centroid(mno.geometry_etrs89), 4258)) AS "GeometriePunt.X",
    public.st_y(public.st_transform(public.st_centroid(mno.geometry_etrs89), 4258)) AS "GeometriePunt.Y",
        CASE
            WHEN (obf.obs_id IS NOT NULL) THEN ((('NL'::text || (ns_hdo.code)::text) || '_'::text) || (hdo.inspire_id_local_id)::text)
            ELSE NULL::text
        END AS "Geoobject.Identificatie",
    mno.inspire_id_local_id AS "Monster.Identificatie",
    mpn_nst.code AS "Monster.Namespace",
    mno.wkrv_id AS "Monster.Versie",
    cmp.code AS "Compartiment.Code",
    cmp.description AS "Compartiment.Omschrijving",
    orgaan.code AS "Orgaan.Code",
    orgaan.description AS "Orgaan.Omschrijving",
    taxon_type.omschrijving AS "Organisme.Naam",
    smpl.upper_depth_value AS "BeginDiepte_m",
    smpl.lower_depth_value AS "EindDiepte_m",
        CASE
            WHEN (hdh_ud.hdh_id IS NULL) THEN
            CASE
                WHEN (hdh_ld.hdh_id IS NULL) THEN (NULL::text)::character varying
                ELSE hdh_ld.code
            END
            ELSE hdh_ud.code
        END AS "ReferentieVlak.Code",
    mbm.code AS "Monsterbewerkingsmethode.Code",
    mbm.description AS "Monsterbewerkingsmethode.Omschrijving",
    mbm.codespace AS "Monsterbewerkingsmethode.codespace",
    bmm.code AS "Bemonsteringsmethode.Code",
    bmm.description AS "Bemonsteringsmethode.Omschrijving",
        CASE
            WHEN (bmm.code IS NULL) THEN NULL::text
            ELSE 'www.aquo.nl'::text
        END AS "Bemonsteringsmethode.codespace",
        CASE
            WHEN (frac.code IS NULL) THEN biota.code
            ELSE frac.code
        END AS "Monstercriterium.Code",
    var.code AS "veldapparaat.Code",
    var.description AS "veldapparaat.Omschrijving",
    var.codespace AS "veldapparaat.Codespace",
    to_char(smpl.sampling_time, 'YYYY-MM-DD'::text) AS "Monsternemingsdatum",
    to_char(smpl.sampling_time, 'HH24:MM:SS'::text) AS "Monsternemingstijd",
    NULL::integer AS "Monster.Tijd_UTCoffset",
    'EPSG4258'::text AS "ReferentieHorizontaal.code",
    smpl.remarks AS "Monster.Opmerking",
        CASE
            WHEN (mno_smpl.wkrv_id IS NULL) THEN NULL::text
            ELSE ((('NL'::text || (smpl_nst.code)::text) || '_'::text) || (mno_smpl.inspire_id_local_id)::text)
        END AS "GerelateerdMonsterobject",
        CASE
            WHEN (mno_smpl.wkrv_id IS NULL) THEN (NULL::text)::character varying
            ELSE rsfr.code
        END AS "GerelateerdMonsterRol.id",
    obs.obs_id AS "Meetwaarde.Identificatie",
    ('NL'::text || (mpn_nst.code)::text) AS "Meetwaarde.Namespace",
    mno.wkrv_id AS "Meetwaarde.Versie",
    opt.grh_code AS "Grootheid.code",
    opt.grh_omschrijving AS "Grootheid.omschrijving",
    opt.typ_code AS "Typering.code",
    opt.typ_omschrijving AS "Typering.omschrijving",
        CASE
            WHEN (opt.txg_omschrijving IS NOT NULL) THEN 'Biotaxon'::text
            WHEN (opt.chs_code IS NOT NULL) THEN 'ChemischeStof'::text
            WHEN (opt.obj_code IS NOT NULL) THEN 'Object'::text
            ELSE NULL::text
        END AS "Parameter.Groep",
        CASE
            WHEN (opt.txg_omschrijving IS NOT NULL) THEN (NULL::text)::character varying
            WHEN (opt.chs_code IS NOT NULL) THEN opt.chs_code
            WHEN (opt.obj_code IS NOT NULL) THEN opt.obj_code
            ELSE NULL::character varying
        END AS "Parameter.Code",
        CASE
            WHEN (opt.txg_omschrijving IS NOT NULL) THEN opt.txg_omschrijving
            WHEN (opt.chs_code IS NOT NULL) THEN opt.chs_naam
            WHEN (opt.obj_code IS NOT NULL) THEN opt.obj_omschrijving
            ELSE NULL::character varying
        END AS "Parameter.Omschrijving",
    eenh.code AS "Eenheid.code",
    eenh.omschrijving AS "Eenheid.omschrijving",
    opt.hdh_code AS "Hoedanigheid.code",
    opt.hdh_omschrijving AS "Hoedanigheid.omschrijving",
    wbm.code AS "Waardebewerkigngsmethode.code",
        CASE
            WHEN (wbm.code IS NULL) THEN NULL::text
            ELSE 'www.aquo.nl'::text
        END AS "Waardebewerkigngsmethode.codespace",
    wbpm.code AS "Waardebepalingsmethode.code",
        CASE
            WHEN (wbpm.code IS NULL) THEN NULL::text
            ELSE 'www.aquo.nl'::text
        END AS "Waardebepalingsmethode.codespace",
    to_char(obs.phenomenon_time_begin, 'YYYY-MM-DD'::text) AS "Begindatum",
    to_char(obs.phenomenon_time_begin, 'HH24:MM:SS'::text) AS "Begintijd",
    to_char(obs.phenomenon_time_end, 'YYYY-MM-DD'::text) AS "Einddatum",
    to_char(obs.phenomenon_time_end, 'HH24:MM:SS'::text) AS "Eindtijd",
    NULL::integer AS "Meetwaarde.Tijd_UTCoffset",
    to_char(obs.result_time, 'YYYY-MM-DD'::text) AS "Resultaatdatum",
    NULL::integer AS "Resultaat_UTCoffset",
    obs.limit_symbol_id AS "Limietsymbool",
    obs.numeric_value AS "Numeriekewaarde",
    obs.description AS "Alfanumeriekewaarde",
    kwaliteitsoordeel_type.code AS "Kwaliteitsoordeel.code",
    kwaliteitsoordeel_type.description AS "Kwaliteitsoordeel.omschrijving",
    mar.code AS "Meetapparaat.code",
        CASE
            WHEN (mar.code IS NULL) THEN NULL::text
            ELSE 'www.aquo.nl'::text
        END AS "Meetapparaat.codespace",
    bio.levensstadium_code AS "Levensstadium.code",
    bio.lengte_code AS "Lengteklasse.code",
    bio.geslacht_code AS "Geslachtcode",
    bio.verschijning_code AS "Verschijningsvorm.code",
    bio.levensvorm_code AS "Levensvorm.code",
    bio.gedrag_code AS "Gedrag.code",
        CASE
            WHEN (obx.obs_id_target IS NULL) THEN NULL::text
            ELSE ((('NL'::text || (mpn_nst.code)::text) || '_'::text) || (obx.obs_id_target)::text)
        END AS "GerelateerdObservatieobject",
    ocr.code AS "GerelateerdObservatieobjectRol.id",
    obs.remarks AS "Meetwaarde.Opmerking",
    indicator.additional_description AS "Indicator.EUOmschrijving",
    typi.code AS "Indicator.Code",
    typd.code AS "Descriptor.Code",
    descriptor.additional_description AS "Descriptor.EUOmschrijving"
   FROM (((((((((((((((((((((((((((((((((((domains.indicator_descriptor indicator
     JOIN public.observed_property_type opti ON ((indicator.opt_id = opti.opt_id)))
     JOIN public.typering_type typi ON ((opti.indicator_id = typi.typ_id)))
     JOIN domains.indicator_descriptor descriptor ON (((indicator.part_of_idd_id = descriptor.idd_id) AND (descriptor.part_of_idd_id IS NULL))))
     JOIN public.observed_property_type optd ON ((descriptor.opt_id = optd.opt_id)))
     JOIN public.typering_type typd ON ((optd.indicator_id = typd.typ_id)))
     JOIN monprog.quality_element_indicator_descriptor qeid ON ((qeid.idd_id = indicator.idd_id)))
     JOIN public.quality_element qem ON ((qem.qem_id = qeid.qem_id)))
     JOIN public.observing_capability osc ON ((osc.osc_id = qem.osc_id)))
     JOIN public.observing_capability_observation oco ON ((oco.osc_id = osc.osc_id)))
     JOIN public.observation obs ON ((oco.obs_id = obs.obs_id)))
     JOIN public.sample smpl ON ((smpl.smpl_id = obs.mno_id)))
     JOIN public.monitoring_object mno ON ((mno.mno_id = smpl.smpl_id)))
     JOIN public.compartiment_type cmp ON ((smpl.material_class_id = cmp.cptm_id)))
     LEFT JOIN public.hoedanigheid_type hdh_ud ON ((hdh_ud.hdh_id = smpl.upper_depth_condition_id)))
     LEFT JOIN public.hoedanigheid_type hdh_ld ON ((hdh_ld.hdh_id = smpl.lower_depth_condition_id)))
     LEFT JOIN public.taxon_type ON ((smpl.txn_id = taxon_type.txn_id)))
     LEFT JOIN domains.orgaan ON ((orgaan.org_id = smpl.organ_id)))
     LEFT JOIN public.hoedanigheid_type frac ON ((frac.hdh_id = smpl.fraction_criterium_id)))
     LEFT JOIN public.hoedanigheid_type biota ON ((biota.hdh_id = smpl.biota_criterium_id)))
     LEFT JOIN public.eenheid_type eenh_ud ON ((eenh_ud.eenh_id = smpl.upper_depth_uom_id)))
     LEFT JOIN public.eenheid_type eenh_ld ON ((eenh_ld.eenh_id = smpl.lower_depth_uom_id)))
     LEFT JOIN (((public.sampling_proces smp
     LEFT JOIN domains.monsterbewerkingsmethode mbm ON ((mbm.mbm_id = smp.sampling_method_id)))
     LEFT JOIN domains.bemonsteringsmethode bmm ON ((bmm.bmm_id = smp.sampling_processing_method_id)))
     LEFT JOIN domains.veldapparaat var ON ((var.var_id = smp.var_id))) ON ((smp.smp_id = smpl.smp_id)))
     LEFT JOIN public.related_sampling_feature rel_smpl ON ((smpl.smpl_id = rel_smpl.mnf_id_source)))
     LEFT JOIN public.sample smpl2 ON ((smpl.smpl_id = rel_smpl.mnf_id_target)))
     LEFT JOIN (public.monitoring_object mno_mpn
     JOIN public.namespace_type mpn_nst ON ((mpn_nst.ns_id = mno_mpn.inspire_id_namespace_id))) ON (((mno_mpn.mno_id = rel_smpl.mnf_id_target) AND ((mno_mpn.monitoring_object_type)::text <> 'Sample'::text))))
     LEFT JOIN (public.monitoring_object mno_smpl
     JOIN public.namespace_type smpl_nst ON ((smpl_nst.ns_id = mno_smpl.inspire_id_namespace_id))) ON (((smpl2.smpl_id = mno_smpl.mno_id) AND ((mno_smpl.monitoring_object_type)::text = 'Sample'::text))))
     LEFT JOIN public.rel_samp_feat_role_type rsfr ON ((rsfr.rsfr_id = rel_smpl.role_id)))
     LEFT JOIN public.eenheid_type eenh ON ((eenh.eenh_id = obs.numeric_value_uom_id)))
     JOIN opt ON ((opt.opt_id = obs.observed_property_type)))
     LEFT JOIN public.kwaliteitsoordeel_type ON ((obs.quality_indicator_id = kwaliteitsoordeel_type.kwod_id)))
     LEFT JOIN ((public.observation_process obp
     LEFT JOIN public.waarde_bepalings_methode_type wbpm ON ((wbpm.wbpm_id = obp.wbpm_id)))
     LEFT JOIN (public.obs_process_meetapparaat opm
     JOIN domains.meetapparaat mar ON ((mar.mar_id = opm.mar_id))) ON ((opm.obp_id = obp.obp_id))) ON ((obp.obp_id = obs.result_nature_id)))
     LEFT JOIN bio ON ((bio.obs_id = obs.obs_id)))
     LEFT JOIN (public.observation_context obx
     JOIN public.obs_ctx_role_type ocr ON ((ocr.ocr_id = obx.role_id))) ON ((obx.obs_id_source = obs.obs_id)))
     LEFT JOIN public.waarde_bewerkings_methode_type wbm ON ((wbm.wbm_id = obs.value_processing_method_id)))
     LEFT JOIN ((public.observed_feature obf
     JOIN public.hydro_object hdo ON ((obf.hdo_id = hdo.hdo_id)))
     JOIN public.namespace_type ns_hdo ON ((hdo.inspire_id_namespace = ns_hdo.ns_id))) ON ((obs.obs_id = obf.obs_id)));



--
-- Name: planned_observation_time_pot_id_seq; Type: SEQUENCE; Schema: monprog; Owner: -
--

CREATE SEQUENCE planned_observation_time_pot_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: planned_observation_time_pot_id_seq; Type: SEQUENCE OWNED BY; Schema: monprog; Owner: -
--

ALTER SEQUENCE planned_observation_time_pot_id_seq OWNED BY planned_observation_time.pot_id;



--
-- Name: Actie; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE "Actie" (
    id integer NOT NULL,
    code character varying(100) NOT NULL,
    naam character varying(100) NOT NULL,
    omschrijving character varying(255)
);


--
-- Name: Actie_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "Actie_id_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: Actie_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "Actie_id_seq" OWNED BY "Actie".id;


--
-- Name: VerwerkingsVerslag; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE "VerwerkingsVerslag" (
    id integer NOT NULL,
    "correlatieId" character varying(100) NOT NULL,
    "actieId" integer NOT NULL,
    "gestartOp" timestamp without time zone NOT NULL,
    "verwerkingsVerslagStatusId" integer NOT NULL,
    "gestartDoor" character varying(50) NOT NULL,
    "gestoptOp" timestamp without time zone NOT NULL
);


--
-- Name: VerwerkingsVerslagParameter; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE "VerwerkingsVerslagParameter" (
    id integer NOT NULL,
    "verwerkingsVerslagId" integer NOT NULL,
    "parameterNaam" character varying(100) NOT NULL,
    waarde character varying(1000) NOT NULL
);


--
-- Name: VerwerkingsVerslagParameter_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "VerwerkingsVerslagParameter_id_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: VerwerkingsVerslagParameter_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "VerwerkingsVerslagParameter_id_seq" OWNED BY "VerwerkingsVerslagParameter".id;


--
-- Name: VerwerkingsVerslagRegel; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE "VerwerkingsVerslagRegel" (
    id integer NOT NULL,
    "verwerkingsVerslagId" integer NOT NULL,
    "verwerkingsVerslagRegelSoortId" integer NOT NULL,
    "gestartOp" timestamp without time zone NOT NULL,
    "omschrijvingSjabloon" character varying(255) NOT NULL,
    waarde1 text NOT NULL,
    waarde2 text,
    waarde3 text,
    "sortOrder" integer NOT NULL
);


--
-- Name: VerwerkingsVerslagRegelSoort; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE "VerwerkingsVerslagRegelSoort" (
    id integer NOT NULL,
    code character varying(100) NOT NULL,
    naam character varying(100) NOT NULL,
    omschrijving character varying(255)
);


--
-- Name: VerwerkingsVerslagRegelSoort_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "VerwerkingsVerslagRegelSoort_id_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: VerwerkingsVerslagRegelSoort_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "VerwerkingsVerslagRegelSoort_id_seq" OWNED BY "VerwerkingsVerslagRegelSoort".id;


--
-- Name: VerwerkingsVerslagRegel_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "VerwerkingsVerslagRegel_id_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: VerwerkingsVerslagRegel_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "VerwerkingsVerslagRegel_id_seq" OWNED BY "VerwerkingsVerslagRegel".id;


--
-- Name: VerwerkingsVerslagStatus; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE "VerwerkingsVerslagStatus" (
    id integer NOT NULL,
    code character varying(100) NOT NULL,
    naam character varying(100) NOT NULL,
    omschrijving character varying(255)
);


--
-- Name: VerwerkingsVerslagStatus_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "VerwerkingsVerslagStatus_id_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: VerwerkingsVerslagStatus_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "VerwerkingsVerslagStatus_id_seq" OWNED BY "VerwerkingsVerslagStatus".id;


--
-- Name: VerwerkingsVerslag_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "VerwerkingsVerslag_id_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: VerwerkingsVerslag_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "VerwerkingsVerslag_id_seq" OWNED BY "VerwerkingsVerslag".id;


--
-- Name: _aquo_ds_biotaxon_20160202; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE _aquo_ds_biotaxon_20160202 (
    id integer,
    naam character varying(100),
    auteur character varying(100),
    taxonniveau character varying(100),
    taxonouder character varying(100),
    verwijsnaam character varying(100),
    naam_nederlands character varying(100),
    twnmutatiedatum timestamp without time zone,
    twnstatus integer,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: TABLE _aquo_ds_biotaxon_20160202; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE _aquo_ds_biotaxon_20160202 IS 'Hulptabel. Alle kolommen met kleine letters overgenomen van Aquo DS Biotaxon op 2016-02-02';


--
-- Name: _hab_ds; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE _hab_ds (
    id integer NOT NULL,
    geom geometry(MultiPolygon,28992),
    naam_n2k character varying(64),
    vhn_new integer,
    nr integer,
    tranche integer,
    beschermin character varying(50),
    status character varying(60),
    sitecode_v character varying(16),
    sitecode_h character varying(16),
    area numeric,
    perimeter numeric
);


--
-- Name: _hab_ds_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE _hab_ds_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: _hab_ds_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE _hab_ds_id_seq OWNED BY _hab_ds.id;


--
-- Name: _vog_ds; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE _vog_ds (
    id integer NOT NULL,
    geom geometry(MultiPolygon,28992),
    naam_n2k character varying(64),
    vhn_new integer,
    nr integer,
    tranche integer,
    beschermin character varying(50),
    status character varying(60),
    sitecode_v character varying(16),
    sitecode_h character varying(16),
    area numeric,
    perimeter numeric
);


--
-- Name: _vog_ds_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE _vog_ds_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: _vog_ds_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE _vog_ds_id_seq OWNED BY _vog_ds.id;


--
-- Name: aquo_kit_voor_opt_id; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE aquo_kit_voor_opt_id (
    grootheid_code character varying(50),
    biotaxon_aquo character varying(90),
    hoedanigheid_code character varying(50),
    taxa_group_name character varying(90),
    type_stof character varying(50) DEFAULT 'Biotaxon'::character varying
);


--
-- Name: _vw_aquo_kit_voor_opt_id; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW _vw_aquo_kit_voor_opt_id AS
 SELECT tgr.txg_id AS tgr_txg_id,
    tgr.name AS tgr_name,
    tgr.group_type AS tgr_group_type,
    tgr.d_begin AS tgr_d_begin,
    tgr.d_eind AS tgr_d_eind,
    tgr.last_changed_date AS tgr_last_changed_date,
    tgr.d_status AS tgr_d_status,
    aoi.grootheid_code AS aoi_grootheid_code,
    aoi.biotaxon_aquo AS aoi_biotaxon_aquo,
    aoi.hoedanigheid_code AS aoi_hoedanigheid_code,
    aoi.taxa_group_name AS aoi_taxa_group_name,
    aoi.type_stof AS aoi_type_stof,
    adb.id AS adb_txn_id,
    adb.naam AS adb_naam,
    adb.auteur AS adb_auteur,
    adb.taxonniveau AS adb_taxonniveau,
    adb.taxonouder AS adb_taxonouder,
    adb.verwijsnaam AS adb_verwijsnaam,
    adb.naam_nederlands AS adb_naam_nederlands,
    adb.twnmutatiedatum AS adb_twnmutatiedatum,
    adb.twnstatus AS adb_twnstatus,
    adb.d_begin AS adb_d_begin,
    adb.d_eind AS adb_d_eind,
    adb.d_status AS adb_d_status
   FROM ((taxa_group tgr
     JOIN _aquo_ds_biotaxon_20160202 adb ON (((adb.naam)::text = (tgr.name)::text)))
     JOIN aquo_kit_voor_opt_id aoi ON (((aoi.biotaxon_aquo)::text = (tgr.name)::text)))
  WHERE (((tgr.group_type)::text = 'I'::text) AND ((adb.twnstatus = 10) OR (adb.twnstatus = 80) OR ((adb.twnstatus = 20) AND (adb.verwijsnaam IS NOT NULL)) OR ((adb.twnstatus = 30) AND (adb.verwijsnaam IS NOT NULL))));


--
-- Name: abstraction_point; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE abstraction_point (
    asp_id integer NOT NULL,
    wbd_id integer NOT NULL,
    geometry geometry(MultiPoint,28992),
    last_change_time timestamp without time zone NOT NULL,
    asp_type character varying(50)
);


--
-- Name: ground_water_body; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE ground_water_body (
    gwb_id integer NOT NULL,
    area double precision NOT NULL,
    centroid geometry(Point,28992) NOT NULL,
    is_out_of_rbd boolean DEFAULT false,
    is_transboundary boolean,
    average_depth_value double precision,
    average_depth_uom_id integer,
    average_thickness_value double precision,
    average_thickness_uom_id integer,
    capacity_value double precision,
    capacity_uom_id integer,
    depth_range_id integer,
    geological_formation_id integer,
    vertical_orientation_id integer,
    horizon_id integer NOT NULL,
    substrate_id integer NOT NULL,
    is_layered boolean,
    is_linked_to_terrestrial_ecosystems boolean,
    other_pressure_description character varying(3000),
    other_impact_description character varying(100),
    last_change_time timestamp without time zone NOT NULL,
    significantlychanged boolean,
    reason_change_old text,
    rct_id integer
);


--
-- Name: gw_abstraction_point; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE gw_abstraction_point (
    gasp_id integer NOT NULL,
    company character varying(50),
    rewab_code integer,
    rewab_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: rewab_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE rewab_type (
    rwb_id integer NOT NULL,
    code character varying(50),
    description text,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: substrate_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE substrate_type (
    sub_id integer NOT NULL,
    omschrijving character varying(50),
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying,
    code character varying(50)
);


--
-- Name: vw_grondwaterlichamen; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW vw_grondwaterlichamen AS
 SELECT DISTINCT ON (vw_waterlichamen.db_id) vw_waterlichamen.db_id,
    vw_waterlichamen.identificatie,
    vw_waterlichamen.waterbeheerder_code,
    vw_waterlichamen.omschrijving,
    vw_waterlichamen.schaal,
    vw_waterlichamen.stroomgebieddistrict,
    ground_water_body.area AS oppervlakte_waarde,
    ground_water_body.is_out_of_rbd AS is_buiten_deelstroomgebied,
    ground_water_body.is_transboundary AS is_grensoverschrijdend,
    ground_water_body.average_depth_value AS gemiddelde_diepte_waarde,
    ground_water_body.average_depth_uom_id,
    ground_water_body.average_thickness_value AS gemiddelde_dikte_waarde,
    ground_water_body.average_thickness_uom_id,
    ground_water_body.capacity_value AS volume_waarde,
    ground_water_body.capacity_uom_id,
    ground_water_body.depth_range_id,
    ground_water_body.geological_formation_id,
    ground_water_body.vertical_orientation_id,
    ground_water_body.horizon_id AS horizon,
    substrate_type.omschrijving AS substraat,
    ground_water_body.is_layered AS is_gelaagd,
    ground_water_body.is_linked_to_terrestrial_ecosystems AS heeft_link_terrestrische_ecosystemen,
    ground_water_body.other_pressure_description AS heeft_overige_belastingen,
    ground_water_body.other_impact_description AS heeft_overige_invloeden,
    vw_waterlichamen.karakterschets,
    vw_waterlichamen.drinkwateronttrekking_jn,
    vw_waterlichamen.versie,
    vw_waterlichamen.versie_begintijd,
    vw_waterlichamen.versie_eindtijd,
    vw_waterlichamen."Gerelateerd_HydroObject"
   FROM ((((hydro_object
     LEFT JOIN vw_waterlichamen ON ((hydro_object.hdo_id = vw_waterlichamen.db_id)))
     LEFT JOIN water_body ON ((water_body.wbd_id = hydro_object.hdo_id)))
     LEFT JOIN ground_water_body ON ((hydro_object.hdo_id = ground_water_body.gwb_id)))
     JOIN substrate_type ON ((substrate_type.sub_id = ground_water_body.substrate_id)));


--
-- Name: vw_gw_onttrekking_g; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW vw_gw_onttrekking_g AS
 SELECT hydro_object.hdo_id AS "DB_ID",
    hydro_object.inspire_id_local_id AS "Identificatie",
    hdo_names.name AS omschrijving,
    abstraction_point.geometry,
    gw_abstraction_point.company AS bedrijf,
    rewab_type.rwb_id AS "REWAB_DB_ID",
    gw_abstraction_point.rewab_code AS "REWAB_Code",
    rewab_type.description AS "REWAB_Type",
    hydro_object.wkrv_id AS wkr_versie,
    vw_grondwaterlichamen.stroomgebieddistrict AS "Stroomgebieddistrict"
   FROM (((((hydro_object
     LEFT JOIN hdo_names ON ((hdo_names.hdo_id = hydro_object.hdo_id)))
     JOIN abstraction_point ON ((hydro_object.hdo_id = abstraction_point.asp_id)))
     JOIN gw_abstraction_point ON ((hydro_object.hdo_id = gw_abstraction_point.gasp_id)))
     JOIN rewab_type ON ((rewab_type.rwb_id = gw_abstraction_point.rewab_id)))
     LEFT JOIN vw_grondwaterlichamen ON ((vw_grondwaterlichamen.db_id = abstraction_point.wbd_id)));


--
-- Name: vw_oppervlaktewaterlichaam_l_kaart; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW vw_oppervlaktewaterlichaam_l_kaart AS
 SELECT swb.swb_id AS db_id,
    hydro_object.inspire_id_local_id AS owmident,
    mrz.geometry,
    hydro_object.wkrv_id AS versie
   FROM ((surface_water_body swb
     LEFT JOIN hydro_object ON ((swb.swb_id = hydro_object.hdo_id)))
     LEFT JOIN management_regulation_or_restriction_zone mrz ON ((swb.swb_id = mrz.mrz_id)))
  WHERE (geometrytype(mrz.geometry) = 'MULTILINESTRING'::text);


--
-- Name: vw_oppervlaktewaterlichaam_v_kaart; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW vw_oppervlaktewaterlichaam_v_kaart AS
 SELECT swb.swb_id AS db_id,
    hydro_object.inspire_id_local_id AS owmident,
    mrz.geometry,
    hydro_object.wkrv_id AS versie
   FROM ((surface_water_body swb
     LEFT JOIN hydro_object ON ((swb.swb_id = hydro_object.hdo_id)))
     LEFT JOIN management_regulation_or_restriction_zone mrz ON ((swb.swb_id = mrz.mrz_id)))
  WHERE (geometrytype(mrz.geometry) = 'MULTIPOLYGON'::text);


--
-- Name: _vw_buffer_waterlichamen_onttrekkingen_g; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW _vw_buffer_waterlichamen_onttrekkingen_g AS
 SELECT o."DB_ID",
    o."Identificatie",
    o.omschrijving,
    o.geometry,
    o.bedrijf,
    o."REWAB_DB_ID",
    o."REWAB_Code",
    o."REWAB_Type",
    o.wkr_versie,
    o."Stroomgebieddistrict",
    st_distance(p.geometry, o.geometry) AS st_distance,
    p.owmident
   FROM vw_gw_onttrekking_g o,
    vw_oppervlaktewaterlichaam_l_kaart p
UNION ALL
 SELECT o."DB_ID",
    o."Identificatie",
    o.omschrijving,
    o.geometry,
    o.bedrijf,
    o."REWAB_DB_ID",
    o."REWAB_Code",
    o."REWAB_Type",
    o.wkr_versie,
    o."Stroomgebieddistrict",
    st_distance(p.geometry, o.geometry) AS st_distance,
    p.owmident
   FROM vw_gw_onttrekking_g o,
    vw_oppervlaktewaterlichaam_v_kaart p;


--
-- Name: _vw_deelstroomgebieddistricten_shape; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW _vw_deelstroomgebieddistricten_shape AS
 SELECT DISTINCT ON (hydro_object.inspire_id_local_id) hydro_object.inspire_id_local_id AS "IDENT",
    hdo_names.name AS "NAAM",
    management_regulation_or_restriction_zone.geometry,
    river_basin_disrict.area_value AS "OPP",
    eenheid_type.code AS "OPP_EENH"
   FROM (((((hydro_object
     LEFT JOIN hdo_names ON ((hdo_names.hdo_id = hydro_object.hdo_id)))
     JOIN management_regulation_or_restriction_zone ON ((hydro_object.hdo_id = management_regulation_or_restriction_zone.mrz_id)))
     JOIN river_basin_disrict ON ((hydro_object.hdo_id = river_basin_disrict.rbd_id)))
     JOIN eenheid_type ON ((eenheid_type.eenh_id = river_basin_disrict.area_uom_id)))
     JOIN wkr_version ON ((wkr_version.wkrv_id = hydro_object.wkrv_id)))
  WHERE ((river_basin_disrict.part_of_district IS NOT NULL) AND (hydro_object.wkrv_id = 13))
  ORDER BY hydro_object.inspire_id_local_id, wkr_version.wkrv_id DESC;


--
-- Name: geological_formation_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE geological_formation_type (
    gfm_id integer NOT NULL,
    code character varying(50) NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: gw_vertical_orientation_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE gw_vertical_orientation_type (
    gvo_id integer NOT NULL,
    code character varying(50) NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: _vw_grondwaterlichamen_shape; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW _vw_grondwaterlichamen_shape AS
 SELECT hydro_object.inspire_id_local_id AS gwbident,
    hydro_object.inspire_id_namespace AS namespac,
    water_body.is_article_7 AS gwbcons,
    hdo_names.name AS gwbnaam,
    management_regulation_or_restriction_zone.geometry,
    hdo2.inspire_id_local_id AS sgbident,
    water_body.level_of_detail AS schaal,
    ground_water_body.area AS oppvte_km2,
    ground_water_body.is_transboundary AS grensovs,
    ground_water_body.average_depth_value AS gemdiepte_m,
    ground_water_body.average_thickness_value AS gemdikte_m,
    ground_water_body.capacity_value AS volme_km3,
    ground_water_body.horizon_id AS gwbhoriz,
    ground_water_body.is_layered AS gelaagd,
    ground_water_body.is_linked_to_terrestrial_ecosystems AS gwb_ter,
    geological_formation_type.code AS gwbaquif,
    gw_vertical_orientation_type.code AS gwbverto
   FROM ((((((((hydro_object
     LEFT JOIN hdo_names ON ((hdo_names.hdo_id = hydro_object.hdo_id)))
     LEFT JOIN management_regulation_or_restriction_zone ON ((management_regulation_or_restriction_zone.mrz_id = hydro_object.hdo_id)))
     LEFT JOIN water_body ON ((water_body.wbd_id = hydro_object.hdo_id)))
     JOIN hydro_object hdo2 ON ((hdo2.hdo_id = water_body.rbd_id)))
     LEFT JOIN ground_water_body ON ((ground_water_body.gwb_id = hydro_object.hdo_id)))
     JOIN substrate_type ON ((substrate_type.sub_id = ground_water_body.substrate_id)))
     LEFT JOIN geological_formation_type ON ((geological_formation_type.gfm_id = ground_water_body.geological_formation_id)))
     LEFT JOIN gw_vertical_orientation_type ON ((gw_vertical_orientation_type.gvo_id = ground_water_body.vertical_orientation_id)))
  WHERE (hydro_object.wkrv_id = 13);


--
-- Name: _vw_meetnet_meetpunt_g; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW _vw_meetnet_meetpunt_g AS
 SELECT ((vw_meetnetten.db_id)::text || (vw_meetpunten_g.db_id)::text) AS uniquekey,
    vw_meetnetten.db_id AS "Meetnet_DB_ID",
    vw_meetnetten.identificatie AS "Meetnet_Identificatie",
    vw_meetnetten.omschrijving AS "Meetnet_Omschrijving",
    vw_meetnetten."Toelichting:" AS "Meetnet_Toelichting",
    vw_meetpunten_g.db_id AS "Meetpunt_DB_ID",
    vw_meetpunten_g.identificatie AS "Meetpunt_Identificatie",
    vw_meetpunten_g.waterbeheerder_code AS "Meetpunt_Waterbeheerdercode",
    vw_meetpunten_g.waterbeheerder_omschrijving AS "Meetpunt_Omschrijving",
    vw_meetpunten_g.wkr_versie,
    vw_meetpunten_g.omschrijving,
    vw_meetpunten_g.toelichting,
    vw_meetpunten_g.geometry
   FROM ((network_facility
     LEFT JOIN vw_meetnetten ON ((vw_meetnetten.db_id = network_facility.emn_id)))
     LEFT JOIN vw_meetpunten_g ON ((vw_meetpunten_g.db_id = network_facility.emf_id)))
  ORDER BY vw_meetnetten.identificatie;


--
-- Name: sw_typology_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE sw_typology_type (
    styp_id integer NOT NULL,
    code character varying(12) NOT NULL,
    description character varying(90),
    swc_id integer NOT NULL,
    is_freshwater boolean DEFAULT true NOT NULL,
    icalt_id integer DEFAULT 12 NOT NULL,
    true_swc_id integer NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: _vw_oppervlaktewaterlichamen_g_type; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW _vw_oppervlaktewaterlichamen_g_type AS
 SELECT hydro_object.hdo_id AS db_id,
    hydro_object.inspire_id_local_id AS identificatie,
    hydro_object.inspire_id_namespace AS waterbeheerder_code,
    water_body.is_article_7 AS drinkwateronttrekking_jn,
    hdo_names.name AS omschrijving,
    management_regulation_or_restriction_zone.geometry,
    geometrytype(management_regulation_or_restriction_zone.geometry) AS geometry_type,
    hdo2.inspire_id_local_id AS stroomgebieddistrict,
    hydro_object.wkrv_id AS versie,
    surface_water_body.is_artificial AS is_kunstmatig,
    surface_water_body.is_heaviliy_modified AS is_sterk_veranderd,
    type.code AS type,
    typer.code AS referentietype
   FROM (((((((management_regulation_or_restriction_zone
     JOIN hydro_object ON ((management_regulation_or_restriction_zone.mrz_id = hydro_object.hdo_id)))
     JOIN water_body ON ((water_body.wbd_id = hydro_object.hdo_id)))
     LEFT JOIN hdo_names ON ((hdo_names.hdo_id = hydro_object.hdo_id)))
     JOIN hydro_object hdo2 ON ((hdo2.hdo_id = water_body.rbd_id)))
     JOIN surface_water_body ON ((surface_water_body.swb_id = hydro_object.hdo_id)))
     JOIN sw_typology_type type ON ((type.styp_id = surface_water_body.sw_typology_id)))
     JOIN sw_typology_type typer ON ((typer.styp_id = surface_water_body.sw_target_typology_id)));


--
-- Name: _vw_oppervlaktewaterlichamen_shape; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW _vw_oppervlaktewaterlichamen_shape AS
 SELECT hydro_object.hdo_id AS db_id,
    hydro_object.inspire_id_local_id AS owmident,
    hydro_object.inspire_id_namespace AS namespac,
    water_body.is_article_7 AS owmcons,
    hdo_names.name AS owmnaam,
    management_regulation_or_restriction_zone.geometry,
    hdo2.inspire_id_local_id AS sgbident,
        CASE
            WHEN (surface_water_body.is_artificial = true) THEN 'Kunstmatig'::text
            WHEN (surface_water_body.is_heaviliy_modified = true) THEN 'Sterk veranderd'::text
            ELSE 'Natuurlijk'::text
        END AS owmstat,
    surface_water_body.area_value AS oppvte,
    surface_water_body.length_value AS lengte,
    type.code AS owmtype,
    typer.code AS owmtyped,
    water_body.level_of_detail AS schaal,
    management_regulation_or_restriction_zone.begin_designation AS geldig_b,
    management_regulation_or_restriction_zone.end_designation AS geldig_e,
    geometrytype(management_regulation_or_restriction_zone.geometry) AS gtype
   FROM ((((((((surface_water_body
     LEFT JOIN hydro_object ON ((surface_water_body.swb_id = hydro_object.hdo_id)))
     LEFT JOIN hdo_names ON ((hdo_names.hdo_id = hydro_object.hdo_id)))
     LEFT JOIN wkr_version ON ((wkr_version.wkrv_id = hydro_object.wkrv_id)))
     LEFT JOIN management_regulation_or_restriction_zone ON ((management_regulation_or_restriction_zone.mrz_id = hydro_object.hdo_id)))
     LEFT JOIN water_body ON ((water_body.wbd_id = hydro_object.hdo_id)))
     LEFT JOIN hydro_object hdo2 ON ((hdo2.hdo_id = water_body.rbd_id)))
     LEFT JOIN sw_typology_type type ON ((type.styp_id = surface_water_body.sw_typology_id)))
     LEFT JOIN sw_typology_type typer ON ((typer.styp_id = surface_water_body.sw_target_typology_id)))
  WHERE (hydro_object.wkrv_id = 13)
  ORDER BY hydro_object.inspire_id_local_id, wkr_version.wkrv_id DESC;


--
-- Name: _vw_oppervlaktewaterlichamen_shape_v4; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW _vw_oppervlaktewaterlichamen_shape_v4 AS
 SELECT hydro_object.hdo_id AS db_id,
    hydro_object.inspire_id_local_id AS owmident,
    hydro_object.inspire_id_namespace AS namespac,
    water_body.is_article_7 AS owmcons,
    hdo_names.name AS owmnaam,
    management_regulation_or_restriction_zone.geometry,
    hdo2.inspire_id_local_id AS sgbident,
        CASE
            WHEN (surface_water_body.is_artificial = true) THEN 'Kunstmatig'::text
            WHEN (surface_water_body.is_heaviliy_modified = true) THEN 'Sterk veranderd'::text
            ELSE 'Natuurlijk'::text
        END AS owmstat,
    surface_water_body.area_value AS oppvte,
    surface_water_body.length_value AS lengte,
    type.code AS owmtype,
    typer.code AS owmtyped,
    water_body.level_of_detail AS schaal,
    management_regulation_or_restriction_zone.begin_designation AS geldig_b,
    management_regulation_or_restriction_zone.end_designation AS geldig_e,
    geometrytype(management_regulation_or_restriction_zone.geometry) AS gtype
   FROM ((((((((surface_water_body
     LEFT JOIN hydro_object ON ((surface_water_body.swb_id = hydro_object.hdo_id)))
     LEFT JOIN hdo_names ON ((hdo_names.hdo_id = hydro_object.hdo_id)))
     LEFT JOIN wkr_version ON ((wkr_version.wkrv_id = hydro_object.wkrv_id)))
     LEFT JOIN management_regulation_or_restriction_zone ON ((management_regulation_or_restriction_zone.mrz_id = hydro_object.hdo_id)))
     LEFT JOIN water_body ON ((water_body.wbd_id = hydro_object.hdo_id)))
     LEFT JOIN hydro_object hdo2 ON ((hdo2.hdo_id = water_body.rbd_id)))
     LEFT JOIN sw_typology_type type ON ((type.styp_id = surface_water_body.sw_typology_id)))
     LEFT JOIN sw_typology_type typer ON ((typer.styp_id = surface_water_body.sw_target_typology_id)))
  WHERE (hydro_object.wkrv_id = 4)
  ORDER BY hydro_object.inspire_id_local_id, wkr_version.wkrv_id DESC;


--
-- Name: protected_area_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE protected_area_type (
    pat_id integer NOT NULL,
    code character varying(12),
    sw_type boolean,
    gw_type boolean,
    description character varying(90) NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: wfd_protected_area; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE wfd_protected_area (
    wpa_id integer NOT NULL,
    geometry geometry(Geometry,28992),
    comment_value_status_prot_area character varying(50) NOT NULL,
    protected_area_type_id integer NOT NULL,
    protected_area_status_id integer NOT NULL,
    swb_art7_id integer,
    gwb_art7_id integer,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: _vw_register_beschermdegebieden_shape; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW _vw_register_beschermdegebieden_shape AS
 SELECT hydro_object.inspire_id_local_id AS besident,
    hdo_names.name AS besnaam,
    protected_area_type.description AS bessoort,
    wfd_protected_area.comment_value_status_prot_area AS richtlijn,
    mrz.geometry,
    hydro_object.wkrv_id AS versie,
    geometrytype(mrz.geometry) AS geometrytype,
    concat(row_number() OVER (ORDER BY hydro_object.inspire_id_local_id), hydro_object.hdo_id, hydro_object.inspire_id_local_id) AS "Unique_Key"
   FROM (((((hydro_object
     LEFT JOIN hdo_names ON ((hdo_names.hdo_id = hydro_object.hdo_id)))
     JOIN wkr_version ON ((wkr_version.wkrv_id = hydro_object.wkrv_id)))
     LEFT JOIN management_regulation_or_restriction_zone mrz ON ((mrz.mrz_id = hydro_object.hdo_id)))
     JOIN wfd_protected_area ON ((wfd_protected_area.wpa_id = hydro_object.hdo_id)))
     JOIN protected_area_type ON ((protected_area_type.pat_id = wfd_protected_area.protected_area_type_id)))
UNION ALL
 SELECT hydro_object.inspire_id_local_id AS besident,
    hdo_names.name AS besnaam,
    (('OnttrekkingMenselijkeConsumptie ('::text ||
        CASE
            WHEN ((hydro_object.hydro_object_type)::text = 'SurfaceWaterBody'::text) THEN 'Oppervlaktewater'::text
            ELSE 'Grondwater'::text
        END) || ')'::text) AS bessoort,
    'Kaderrichtlijn Water (2000/60/EC), Artikel 7'::text AS richtlijn,
    mrz.geometry,
    hydro_object.wkrv_id AS versie,
    geometrytype(mrz.geometry) AS geometrytype,
    concat(row_number() OVER (ORDER BY hydro_object.inspire_id_local_id), hydro_object.hdo_id, hydro_object.inspire_id_local_id) AS "Unique_Key"
   FROM ((((hydro_object
     LEFT JOIN hdo_names ON ((hdo_names.hdo_id = hydro_object.hdo_id)))
     JOIN wkr_version ON ((wkr_version.wkrv_id = hydro_object.wkrv_id)))
     LEFT JOIN management_regulation_or_restriction_zone mrz ON ((mrz.mrz_id = hydro_object.hdo_id)))
     JOIN water_body ON ((water_body.wbd_id = hydro_object.hdo_id)))
  WHERE (water_body.is_article_7 IS TRUE);


--
-- Name: _vw_stroomgebieddistricten_shape; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW _vw_stroomgebieddistricten_shape AS
 SELECT DISTINCT ON (hydro_object.inspire_id_local_id) hydro_object.inspire_id_local_id AS "IDENT",
    hdo_names.name AS "NAAM",
    management_regulation_or_restriction_zone.geometry,
    river_basin_disrict.area_value AS "OPP",
    eenheid_type.code AS "OPP_EENH"
   FROM (((((hydro_object
     LEFT JOIN hdo_names ON ((hdo_names.hdo_id = hydro_object.hdo_id)))
     JOIN management_regulation_or_restriction_zone ON ((hydro_object.hdo_id = management_regulation_or_restriction_zone.mrz_id)))
     JOIN river_basin_disrict ON ((hydro_object.hdo_id = river_basin_disrict.rbd_id)))
     JOIN eenheid_type ON ((eenheid_type.eenh_id = river_basin_disrict.area_uom_id)))
     JOIN wkr_version ON ((wkr_version.wkrv_id = hydro_object.wkrv_id)))
  WHERE (river_basin_disrict.international_rbd IS NOT NULL)
  ORDER BY hydro_object.inspire_id_local_id, wkr_version.wkrv_id DESC;


--
-- Name: vw_grondwaterlichaam_kaart; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW vw_grondwaterlichaam_kaart AS
 SELECT gwb.gwb_id AS db_id,
    hydro_object.inspire_id_local_id AS gwbident,
    mrz.geometry,
    hydro_object.wkrv_id AS versie
   FROM ((ground_water_body gwb
     LEFT JOIN hydro_object ON ((gwb.gwb_id = hydro_object.hdo_id)))
     LEFT JOIN management_regulation_or_restriction_zone mrz ON ((gwb.gwb_id = mrz.mrz_id)));


--
-- Name: _vw_test_buffer_ab_g; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW _vw_test_buffer_ab_g AS
 SELECT a."DB_ID",
    a."Identificatie",
    a.omschrijving,
    st_within(a.geometry, st_buffer(b.geometry, (10000)::double precision)) AS binnen_buffer,
    a.geometry,
    a.bedrijf,
    a."REWAB_DB_ID",
    a."REWAB_Code",
    a."REWAB_Type",
    a.wkr_versie,
    a."Stroomgebieddistrict"
   FROM vw_gw_onttrekking_g a,
    vw_grondwaterlichaam_kaart b
  WHERE (geometrytype(a.geometry) = 'MULTIPOINT'::text);


--
-- Name: activity_organisation_category; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE activity_organisation_category (
    isac_id integer NOT NULL,
    ocat_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: any_thematic_link; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE any_thematic_link (
    atl_id integer NOT NULL,
    emf_id integer NOT NULL,
    related_emf_id integer NOT NULL,
    comment text NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: any_thematic_link_atl_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE any_thematic_link_atl_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: any_thematic_link_atl_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE any_thematic_link_atl_id_seq OWNED BY any_thematic_link.atl_id;


--
-- Name: application; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE application (
    applicationid integer NOT NULL,
    applicationname character varying(235) NOT NULL,
    description character varying(256)
);


--
-- Name: application_applicationid_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE application_applicationid_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: application_applicationid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE application_applicationid_seq OWNED BY application.applicationid;


--
-- Name: basic_measure113a_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE basic_measure113a_type (
    bma_id integer NOT NULL,
    name character varying(90) NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: basic_measure113a_type_bma_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE basic_measure113a_type_bma_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: basic_measure113a_type_bma_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE basic_measure113a_type_bma_id_seq OWNED BY basic_measure113a_type.bma_id;


--
-- Name: bepaling_grens_type_bpg_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE bepaling_grens_type_bpg_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: bepaling_grens_type_bpg_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE bepaling_grens_type_bpg_id_seq OWNED BY bepaling_grens_type.bpg_id;


--
-- Name: bronnen; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE bronnen (
    bronnen_id integer NOT NULL,
    hdo_id integer NOT NULL,
    chs_id integer NOT NULL,
    wbpm_id integer NOT NULL,
    eenh_id integer NOT NULL,
    year integer NOT NULL,
    is_significant_wbm boolean DEFAULT false NOT NULL,
    is_significant_factsheet boolean DEFAULT false NOT NULL
);


--
-- Name: bronnen_bronnen_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE bronnen_bronnen_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: bronnen_bronnen_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE bronnen_bronnen_id_seq OWNED BY bronnen.bronnen_id;


--
-- Name: ca_role_code; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE ca_role_code (
    crc_id integer NOT NULL,
    role_code character varying(12) NOT NULL,
    description text,
    lgr_id integer DEFAULT 1
);


--
-- Name: ca_role_code_crc_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE ca_role_code_crc_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: ca_role_code_crc_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE ca_role_code_crc_id_seq OWNED BY ca_role_code.crc_id;


--
-- Name: chemical_exceedance; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE chemical_exceedance (
    sys_id integer NOT NULL,
    chs_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: chemische_stof_type_chs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE chemische_stof_type_chs_id_seq
    START WITH 3019
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: chemische_stof_type_chs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE chemische_stof_type_chs_id_seq OWNED BY chemische_stof_type.chs_id;


--
-- Name: classification_group_type_clsg_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE classification_group_type_clsg_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: classification_group_type_clsg_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE classification_group_type_clsg_id_seq OWNED BY classification_group_type.clsg_id;


--
-- Name: classification_type_cls_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE classification_type_cls_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: classification_type_cls_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE classification_type_cls_id_seq OWNED BY classification_type.cls_id;


--
-- Name: compartiment_type_cptm_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE compartiment_type_cptm_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: compartiment_type_cptm_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE compartiment_type_cptm_id_seq OWNED BY compartiment_type.cptm_id;


--
-- Name: competent_authority_roles; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE competent_authority_roles (
    ore_id integer NOT NULL,
    crc_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL,
    main boolean DEFAULT true,
    guid uuid DEFAULT uuid_in((md5(((random())::text || (now())::text)))::cstring) NOT NULL
);


--
-- Name: competentauthority_namespacetype_ca_ns_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE competentauthority_namespacetype_ca_ns_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: competentauthority_namespacetype_ca_ns_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE competentauthority_namespacetype_ca_ns_id_seq OWNED BY competentauthority_namespacetype.ca_ns_id;


--
-- Name: condition_of_gw_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE condition_of_gw_type (
    cog_id integer NOT NULL,
    code character varying(50) NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: condition_of_gw_type_cog_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE condition_of_gw_type_cog_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: condition_of_gw_type_cog_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE condition_of_gw_type_cog_id_seq OWNED BY condition_of_gw_type.cog_id;


--
-- Name: csvtransformation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE csvtransformation (
    csvtransformationid integer NOT NULL,
    csvtype character varying(256) NOT NULL,
    columnname character varying(256) NOT NULL,
    datatype character varying(15) NOT NULL,
    mandatory boolean NOT NULL,
    inputorder integer NOT NULL
);


--
-- Name: csvtransformation_csvtransformationid_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE csvtransformation_csvtransformationid_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: csvtransformation_csvtransformationid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE csvtransformation_csvtransformationid_seq OWNED BY csvtransformation.csvtransformationid;


--
-- Name: depth_range_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE depth_range_type (
    dpr_id integer NOT NULL,
    code character varying(50) NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: depth_range_type_dpr_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE depth_range_type_dpr_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: depth_range_type_dpr_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE depth_range_type_dpr_id_seq OWNED BY depth_range_type.dpr_id;


--
-- Name: domaintable_changes; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE domaintable_changes (
    domaintable_changes_id integer NOT NULL,
    wkp_table_name character varying(255) NOT NULL,
    ds_table_name character varying(255) NOT NULL,
    last_imported_date timestamp without time zone NOT NULL,
    isimported boolean DEFAULT false NOT NULL
);


--
-- Name: domaintable_changes_domaintable_changes_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE domaintable_changes_domaintable_changes_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: domaintable_changes_domaintable_changes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE domaintable_changes_domaintable_changes_id_seq OWNED BY domaintable_changes.domaintable_changes_id;


--
-- Name: eenheid_type_eenh_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE eenheid_type_eenh_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: eenheid_type_eenh_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE eenheid_type_eenh_id_seq OWNED BY eenheid_type.eenh_id;


--
-- Name: environmental_domain_code; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE environmental_domain_code (
    emd_id integer NOT NULL,
    code character varying(50) NOT NULL,
    description character varying(50) NOT NULL
);


--
-- Name: environmental_domain_code_emd_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE environmental_domain_code_emd_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: environmental_domain_code_emd_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE environmental_domain_code_emd_id_seq OWNED BY environmental_domain_code.emd_id;


--
-- Name: eu_article_43b_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE eu_article_43b_type (
    a43b_id integer NOT NULL,
    omschrijving character varying(100),
    show boolean,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: eu_article_43b_type_a43b_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE eu_article_43b_type_a43b_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: eu_article_43b_type_a43b_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE eu_article_43b_type_a43b_id_seq OWNED BY eu_article_43b_type.a43b_id;


--
-- Name: eu_depth_level_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE eu_depth_level_type (
    dlt_id integer NOT NULL,
    code character varying(50) NOT NULL,
    description character varying(50),
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: eu_depth_level_type_dlt_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE eu_depth_level_type_dlt_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: eu_depth_level_type_dlt_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE eu_depth_level_type_dlt_id_seq OWNED BY eu_depth_level_type.dlt_id;


--
-- Name: eu_function_43a_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE eu_function_43a_type (
    fu43_id integer NOT NULL,
    function character varying(150),
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: eu_fund_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE eu_fund_type (
    euf_id integer NOT NULL,
    code character varying(50) NOT NULL,
    description character varying(50) NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying,
    id integer
);


--
-- Name: eu_fund_type_euf_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE eu_fund_type_euf_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: eu_fund_type_euf_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE eu_fund_type_euf_id_seq OWNED BY eu_fund_type.euf_id;


--
-- Name: eu_intercalibration_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE eu_intercalibration_type (
    icalt integer NOT NULL,
    code character varying(50) NOT NULL,
    description text,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying,
    eu_xsd character varying(250)
);


--
-- Name: eu_monitoring_goal_type_eumg_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE eu_monitoring_goal_type_eumg_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: eu_monitoring_goal_type_eumg_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE eu_monitoring_goal_type_eumg_id_seq OWNED BY eu_monitoring_goal_type.eumg_id;


--
-- Name: eu_monitoring_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE eu_monitoring_type (
    mtt_id integer NOT NULL,
    code character varying(50) NOT NULL,
    description character varying(50),
    sw_or_gw character varying(2),
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: COLUMN eu_monitoring_type.sw_or_gw; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN eu_monitoring_type.sw_or_gw IS 'monitoring type for sw or gw?';


--
-- Name: eu_monitoring_type_mtt_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE eu_monitoring_type_mtt_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: eu_monitoring_type_mtt_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE eu_monitoring_type_mtt_id_seq OWNED BY eu_monitoring_type.mtt_id;


--
-- Name: eu_nl_code_to_sitecode_nts_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE eu_nl_code_to_sitecode_nts_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: eu_nl_code_to_sitecode; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE eu_nl_code_to_sitecode (
    nts_id integer DEFAULT nextval('eu_nl_code_to_sitecode_nts_id_seq'::regclass) NOT NULL,
    nl_code character varying(50),
    sitecode character varying(50),
    gebied character varying(100),
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: excemption_mechanism_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE excemption_mechanism_type (
    exme_id integer NOT NULL,
    omschrijving character varying(50),
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: excemption_mechanism_type_exme_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE excemption_mechanism_type_exme_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: excemption_mechanism_type_exme_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE excemption_mechanism_type_exme_id_seq OWNED BY excemption_mechanism_type.exme_id;


--
-- Name: faq_item; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE faq_item (
    faq_item_id integer NOT NULL,
    question character varying(2000) NOT NULL,
    answer character varying(2000) NOT NULL,
    isactive boolean NOT NULL,
    sortorder integer NOT NULL,
    last_changed_time timestamp without time zone NOT NULL,
    faq_thema_id integer NOT NULL,
    is_public boolean DEFAULT true NOT NULL
);


--
-- Name: faq_item_faq_item_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE faq_item_faq_item_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: faq_item_faq_item_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE faq_item_faq_item_id_seq OWNED BY faq_item.faq_item_id;


--
-- Name: faq_thema; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE faq_thema (
    faq_thema_id integer NOT NULL,
    thema character varying(255) NOT NULL,
    sortorder integer NOT NULL,
    last_changed_time timestamp without time zone NOT NULL
);


--
-- Name: faq_thema_faq_thema_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE faq_thema_faq_thema_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: faq_thema_faq_thema_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE faq_thema_faq_thema_id_seq OWNED BY faq_thema.faq_thema_id;


--
-- Name: generatedfactsheets; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE generatedfactsheets (
    id integer NOT NULL,
    cuid character varying(50) NOT NULL,
    oreid integer NOT NULL,
    name character varying(250) NOT NULL,
    datetime timestamp with time zone NOT NULL,
    factsheettype character varying(50) NOT NULL,
    wie character varying(100) NOT NULL
);


--
-- Name: generatedfactsheets_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE generatedfactsheets_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: generatedfactsheets_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE generatedfactsheets_id_seq OWNED BY generatedfactsheets.id;


--
-- Name: geo_reference_process; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE geo_reference_process (
    grp_id integer NOT NULL,
    mno_id integer NOT NULL,
    plaatsbep_app_id integer NOT NULL
);


--
-- Name: geo_reference_process_grp_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE geo_reference_process_grp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: geo_reference_process_grp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE geo_reference_process_grp_id_seq OWNED BY geo_reference_process.grp_id;


--
-- Name: geological_formation_type_gfm_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE geological_formation_type_gfm_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: geological_formation_type_gfm_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE geological_formation_type_gfm_id_seq OWNED BY geological_formation_type.gfm_id;


--
-- Name: grootheid_type_grh_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE grootheid_type_grh_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: grootheid_type_grh_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE grootheid_type_grh_id_seq OWNED BY grootheid_type.grh_id;


--
-- Name: gw_abstraction_point_status; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE gw_abstraction_point_status (
    asp_id integer NOT NULL,
    gwsy_id integer NOT NULL,
    gwst_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL,
    remarks text
);


--
-- Name: COLUMN gw_abstraction_point_status.gwst_id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN gw_abstraction_point_status.gwst_id IS 'id toestand_kwaliteit';


--
-- Name: gw_aggregated_pressure_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE gw_aggregated_pressure_type (
    gwap_id integer NOT NULL,
    name character varying(50) NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: gw_aggregated_pressure_type_gwap_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE gw_aggregated_pressure_type_gwap_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: gw_aggregated_pressure_type_gwap_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE gw_aggregated_pressure_type_gwap_id_seq OWNED BY gw_aggregated_pressure_type.gwap_id;


--
-- Name: gw_chemical_status_gwcs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE gw_chemical_status_gwcs_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: gw_chemical_status_gwcs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE gw_chemical_status_gwcs_id_seq OWNED BY gw_chemical_status.gwcs_id;


--
-- Name: gw_mon_stat_other_mon_use; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE gw_mon_stat_other_mon_use (
    gms_id integer NOT NULL,
    omut_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: gw_monitoring_station; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE gw_monitoring_station (
    gms_id integer NOT NULL,
    additional_requirements text,
    depth_sampled_id integer,
    station_level_id integer NOT NULL,
    station_type_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: gw_n2000_status; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE gw_n2000_status (
    wpa_id integer NOT NULL,
    gwsy integer NOT NULL,
    cls_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL,
    opt_id integer NOT NULL,
    remark character varying(255)
);


--
-- Name: gw_pollutants; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE gw_pollutants (
    gys_id integer NOT NULL,
    chs_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: gw_pressure_requiring_supp_add_measures; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE gw_pressure_requiring_supp_add_measures (
    gprm_id integer NOT NULL,
    gpg_id integer NOT NULL,
    comments character varying(2000),
    gprs_id integer NOT NULL,
    bma_id integer,
    obmb_id integer,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: gw_pressure_requiring_supp_add_measures_gprm_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE gw_pressure_requiring_supp_add_measures_gprm_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: gw_pressure_requiring_supp_add_measures_gprm_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE gw_pressure_requiring_supp_add_measures_gprm_id_seq OWNED BY gw_pressure_requiring_supp_add_measures.gprm_id;


--
-- Name: gw_pressure_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE gw_pressure_type (
    gprs_id integer NOT NULL,
    name character varying(50) NOT NULL,
    description character varying(90) NOT NULL,
    is_nl_only boolean DEFAULT false NOT NULL,
    pressure_category_id integer NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: COLUMN gw_pressure_type.is_nl_only; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN gw_pressure_type.is_nl_only IS 'Alleen relevant binnen NL?';


--
-- Name: gw_pressure_type_driver; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE gw_pressure_type_driver (
    gprs_id integer NOT NULL,
    driver_id integer NOT NULL
);


--
-- Name: gw_pressure_type_gprs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE gw_pressure_type_gprs_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: gw_pressure_type_gprs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE gw_pressure_type_gprs_id_seq OWNED BY gw_pressure_type.gprs_id;


--
-- Name: gw_pressures_preventing_good_status; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE gw_pressures_preventing_good_status (
    gpg_id integer NOT NULL,
    rbmp_id integer NOT NULL,
    gwap_id integer NOT NULL,
    is_basic_measures_enough boolean NOT NULL,
    comments text,
    percentage_failure_value double precision,
    percentage_failure_uom_id integer,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: COLUMN gw_pressures_preventing_good_status.gwap_id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN gw_pressures_preventing_good_status.gwap_id IS 'gw pressure';


--
-- Name: gw_pressures_preventing_good_status_gpg_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE gw_pressures_preventing_good_status_gpg_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: gw_pressures_preventing_good_status_gpg_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE gw_pressures_preventing_good_status_gpg_id_seq OWNED BY gw_pressures_preventing_good_status.gpg_id;


--
-- Name: gw_quantity_status_gwqs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE gw_quantity_status_gwqs_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: gw_quantity_status_gwqs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE gw_quantity_status_gwqs_id_seq OWNED BY gw_quantity_status.gwqs_id;


--
-- Name: gw_reason4chemical_failure; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE gw_reason4chemical_failure (
    grcf_id integer NOT NULL,
    value text NOT NULL
);


--
-- Name: gw_reason4chemical_failure_grcf_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE gw_reason4chemical_failure_grcf_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: gw_reason4chemical_failure_grcf_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE gw_reason4chemical_failure_grcf_id_seq OWNED BY gw_reason4chemical_failure.grcf_id;


--
-- Name: gw_reason4quantity_failure; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE gw_reason4quantity_failure (
    grqf_id integer NOT NULL,
    value text NOT NULL
);


--
-- Name: gw_reason4quantity_failure_grqf_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE gw_reason4quantity_failure_grqf_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: gw_reason4quantity_failure_grqf_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE gw_reason4quantity_failure_grqf_id_seq OWNED BY gw_reason4quantity_failure.grqf_id;


--
-- Name: gw_required_supp_measure; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE gw_required_supp_measure (
    gprm_id integer NOT NULL,
    smnl_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: gw_swb_status; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE gw_swb_status (
    swb_id integer NOT NULL,
    gwsy integer NOT NULL,
    cls_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL,
    opt_id integer NOT NULL,
    remark character varying(255)
);


--
-- Name: gw_test_value; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE gw_test_value (
    gtcc_id integer NOT NULL,
    nrmv_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: gw_testing_conclusion; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE gw_testing_conclusion (
    gtcc_id integer NOT NULL,
    gys_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL,
    eumg_id integer DEFAULT 2 NOT NULL
);


--
-- Name: gw_vertical_orientation_type_gvo_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE gw_vertical_orientation_type_gvo_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: gw_vertical_orientation_type_gvo_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE gw_vertical_orientation_type_gvo_id_seq OWNED BY gw_vertical_orientation_type.gvo_id;


--
-- Name: gwb_chem_exemp_pollutant; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE gwb_chem_exemp_pollutant (
    gwce_id integer NOT NULL,
    opt_id integer NOT NULL,
    is_causing_exemption boolean NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: gwb_chemical_exemption; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE gwb_chemical_exemption (
    gwce_id integer NOT NULL,
    gwb_id integer NOT NULL,
    obex_id integer NOT NULL,
    comment text,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: gwb_chemical_exemption_gwce_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE gwb_chemical_exemption_gwce_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: gwb_chemical_exemption_gwce_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE gwb_chemical_exemption_gwce_id_seq OWNED BY gwb_chemical_exemption.gwce_id;


--
-- Name: gwb_conceptual_model; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE gwb_conceptual_model (
    gcm_id integer NOT NULL,
    gwb_id integer NOT NULL,
    volgnr integer NOT NULL,
    omschrijving text NOT NULL,
    afbeelding bytea NOT NULL,
    extentie character varying(5) NOT NULL,
    last_change_time timestamp with time zone NOT NULL
);


--
-- Name: gwb_conceptual_model_gcm_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE gwb_conceptual_model_gcm_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: gwb_conceptual_model_gcm_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE gwb_conceptual_model_gcm_id_seq OWNED BY gwb_conceptual_model.gcm_id;


--
-- Name: gwb_pressure; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE gwb_pressure (
    gwbp_id integer NOT NULL,
    gwb_id integer NOT NULL,
    gprs_id integer NOT NULL,
    is_significant boolean NOT NULL,
    last_change_time timestamp without time zone NOT NULL,
    remark text,
    function character varying(250),
    effect text,
    prr_id integer DEFAULT 3 NOT NULL
);


--
-- Name: gwb_pressure_gprs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE gwb_pressure_gprs_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: gwb_pressure_gprs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE gwb_pressure_gprs_id_seq OWNED BY gwb_pressure.gprs_id;


--
-- Name: gwb_pressure_gwbp_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE gwb_pressure_gwbp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: gwb_pressure_gwbp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE gwb_pressure_gwbp_id_seq OWNED BY gwb_pressure.gwbp_id;


--
-- Name: gwb_pressure_impact; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE gwb_pressure_impact (
    gwbp_id integer NOT NULL,
    impact_id integer NOT NULL
);


--
-- Name: gwb_quantitative_exemption; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE gwb_quantitative_exemption (
    gqe_id integer NOT NULL,
    gwb_id integer NOT NULL,
    obex_id integer NOT NULL,
    comment character varying(500),
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: gwb_quantitative_exemption_gqe_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE gwb_quantitative_exemption_gqe_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: gwb_quantitative_exemption_gqe_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE gwb_quantitative_exemption_gqe_id_seq OWNED BY gwb_quantitative_exemption.gqe_id;


--
-- Name: gwb_reason4chemical_failure; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE gwb_reason4chemical_failure (
    gys_id integer NOT NULL,
    grcf_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: gwb_reason4quantity_failure; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE gwb_reason4quantity_failure (
    gys_id integer NOT NULL,
    grqf_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: gwb_yearly_status_gys_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE gwb_yearly_status_gys_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: gwb_yearly_status_gys_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE gwb_yearly_status_gys_id_seq OWNED BY gwb_yearly_status.gys_id;


--
-- Name: hab_vog_to_sitecode; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE hab_vog_to_sitecode (
    nl_code character varying(50),
    sitecode character varying(50)
);


--
-- Name: hdo_identfiers; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE hdo_identfiers (
    hdo_id integer NOT NULL,
    local_id character varying(36) NOT NULL,
    namespace_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: hoedanigheid_type_hdh_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE hoedanigheid_type_hdh_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: hoedanigheid_type_hdh_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE hoedanigheid_type_hdh_id_seq OWNED BY hoedanigheid_type.hdh_id;


--
-- Name: hulp_chemischestof; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE hulp_chemischestof (
    chs_id integer DEFAULT nextval('chemische_stof_type_chs_id_seq'::regclass) NOT NULL,
    cas_nr character varying(12) NOT NULL,
    naam character varying(90) NOT NULL,
    code character varying(12) NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying,
    id integer
);


--
-- Name: hulp_eenheid; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE hulp_eenheid (
    eenh_id integer,
    code character varying(50),
    omschrijving character varying(50),
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50),
    id integer
);


--
-- Name: hulp_grootheid; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE hulp_grootheid (
    grh_id integer DEFAULT nextval('grootheid_type_grh_id_seq'::regclass) NOT NULL,
    code character varying(50) NOT NULL,
    omschrijving character varying(90) NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying,
    id integer
);


--
-- Name: hulp_hoedanigheid_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE hulp_hoedanigheid_type (
    hdh_id integer DEFAULT nextval('hoedanigheid_type_hdh_id_seq'::regclass) NOT NULL,
    code character varying(12) NOT NULL,
    omschrijving character varying(90) NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying,
    id integer
);


--
-- Name: object_type_obj_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE object_type_obj_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: object_type_obj_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE object_type_obj_id_seq OWNED BY object_type.obj_id;


--
-- Name: hulp_object; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE hulp_object (
    obj_id integer DEFAULT nextval('object_type_obj_id_seq'::regclass) NOT NULL,
    code character varying(12) NOT NULL,
    omschrijving character varying(90) NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying,
    id integer
);


--
-- Name: typering_type_typ_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE typering_type_typ_id_seq
    START WITH 26616
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: typering_type_typ_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE typering_type_typ_id_seq OWNED BY typering_type.typ_id;


--
-- Name: hulp_typering; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE hulp_typering (
    typ_id integer DEFAULT nextval('typering_type_typ_id_seq'::regclass) NOT NULL,
    code character varying(12) NOT NULL,
    omschrijving character varying(90) NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying,
    id integer
);


--
-- Name: hydro_object_hdo_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE hydro_object_hdo_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: hydro_object_hdo_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE hydro_object_hdo_id_seq OWNED BY hydro_object.hdo_id;


--
-- Name: importrule; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE importrule (
    importruleid integer NOT NULL,
    importtypeid integer NOT NULL,
    name character varying(50) NOT NULL,
    fileextension character varying(3) NOT NULL,
    origin character varying(30) NOT NULL,
    transformation character varying(50) NOT NULL,
    linkedimportruleid integer,
    inputorder integer NOT NULL
);


--
-- Name: importrule_importruleid_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE importrule_importruleid_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: importrule_importruleid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE importrule_importruleid_seq OWNED BY importrule.importruleid;


--
-- Name: importtype; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE importtype (
    importtypeid integer NOT NULL,
    name character varying(50) NOT NULL,
    fileextension character varying(3) NOT NULL,
    transformation character varying(50) NOT NULL
);


--
-- Name: importtype_importtypeid_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE importtype_importtypeid_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: importtype_importtypeid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE importtype_importtypeid_seq OWNED BY importtype.importtypeid;


--
-- Name: info_stream_activity; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE info_stream_activity (
    isac_id integer NOT NULL,
    ims_id integer NOT NULL,
    name character varying(50) NOT NULL,
    description text,
    deadline_data_delivery date NOT NULL,
    deadline_reporting date NOT NULL,
    is_completed boolean NOT NULL,
    completion_date date NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: info_stream_activity_isac_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE info_stream_activity_isac_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: info_stream_activity_isac_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE info_stream_activity_isac_id_seq OWNED BY info_stream_activity.isac_id;


--
-- Name: info_stream_legal_background; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE info_stream_legal_background (
    ims_id integer NOT NULL,
    lgr_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: information_stream; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE information_stream (
    ims_id integer NOT NULL,
    name character varying(50) NOT NULL,
    descrption text
);


--
-- Name: information_stream_ims_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE information_stream_ims_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: information_stream_ims_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE information_stream_ims_id_seq OWNED BY information_stream.ims_id;


--
-- Name: kaarten_sgbp; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE kaarten_sgbp (
    ksgbp_id integer NOT NULL,
    naam character varying(255),
    categorie character varying(255),
    url text,
    order_id integer,
    last_changed_date timestamp without time zone,
    map_ref text NOT NULL,
    page character varying(50) NOT NULL
);


--
-- Name: kaarten_sgbp_ksgbp_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE kaarten_sgbp_ksgbp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: kaarten_sgbp_ksgbp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE kaarten_sgbp_ksgbp_id_seq OWNED BY kaarten_sgbp.ksgbp_id;


--
-- Name: kwaliteitsoordeel_type_kwod_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE kwaliteitsoordeel_type_kwod_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: kwaliteitsoordeel_type_kwod_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE kwaliteitsoordeel_type_kwod_id_seq OWNED BY kwaliteitsoordeel_type.kwod_id;


--
-- Name: legislation_level_type_lgl_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE legislation_level_type_lgl_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: legislation_level_type_lgl_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE legislation_level_type_lgl_id_seq OWNED BY legislation_level_type.lgl_id;


--
-- Name: legislation_reference_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE legislation_reference_type (
    lgr_id integer NOT NULL,
    legal_name character varying(90) NOT NULL,
    publication_date timestamp without time zone NOT NULL,
    legislation_level_id integer NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying,
    url character varying(255)
);


--
-- Name: legislation_reference_type_lgr_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE legislation_reference_type_lgr_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: legislation_reference_type_lgr_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE legislation_reference_type_lgr_id_seq OWNED BY legislation_reference_type.lgr_id;


--
-- Name: level_of_area_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE level_of_area_type (
    loa_id integer NOT NULL,
    code character varying(12) NOT NULL,
    order_of_rank integer NOT NULL,
    description character varying(50) NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying,
    id integer
);


--
-- Name: COLUMN level_of_area_type.order_of_rank; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN level_of_area_type.order_of_rank IS 'Rangorde; MemberState=1, RBD=2, Sub-Unit=3 , Waterbody=4';


--
-- Name: level_of_area_type_loa_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE level_of_area_type_loa_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: level_of_area_type_loa_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE level_of_area_type_loa_id_seq OWNED BY level_of_area_type.loa_id;


--
-- Name: logging_loggingid_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE logging_loggingid_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: logging_loggingid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE logging_loggingid_seq OWNED BY logging.loggingid;


--
-- Name: management_regulation_or_restriction_zone_collection; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE management_regulation_or_restriction_zone_collection (
    mzc_id integer NOT NULL,
    inspire_id_local_id character varying(36) NOT NULL,
    inspire_id_namespace_id integer NOT NULL,
    wkrv_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: management_regulation_or_restriction_zone_collection_mzc_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE management_regulation_or_restriction_zone_collection_mzc_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: management_regulation_or_restriction_zone_collection_mzc_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE management_regulation_or_restriction_zone_collection_mzc_id_seq OWNED BY management_regulation_or_restriction_zone_collection.mzc_id;


--
-- Name: measure_finance; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE measure_finance (
    mtm_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL,
    sum numeric(16,2) NOT NULL,
    mft_id integer NOT NULL
);


--
-- Name: measure_finance_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE measure_finance_type (
    mtf_id integer NOT NULL,
    omschrijving character varying(50),
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: measure_per_abstraction_point; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE measure_per_abstraction_point (
    mtm_id integer NOT NULL,
    asp_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: measure_per_man_protected_area; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE measure_per_man_protected_area (
    mtm_id integer NOT NULL,
    wpa_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: measure_per_man_reg_or_restr_zone; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE measure_per_man_reg_or_restr_zone (
    mtm_id integer NOT NULL,
    mrz_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: measure_progress; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE measure_progress (
    mtm_id integer NOT NULL,
    mst_id integer NOT NULL,
    reason_substanstial_delay text,
    amount_value double precision NOT NULL,
    last_change_time timestamp without time zone NOT NULL,
    year integer NOT NULL
);


--
-- Name: measure_progress_completed; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE measure_progress_completed (
    measure_progress_completedid integer NOT NULL,
    mtm_id integer NOT NULL,
    year_completed integer NOT NULL,
    completed boolean NOT NULL
);


--
-- Name: measure_progress_completed_measure_progress_completedid_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE measure_progress_completed_measure_progress_completedid_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: measure_progress_completed_measure_progress_completedid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE measure_progress_completed_measure_progress_completedid_seq OWNED BY measure_progress_completed.measure_progress_completedid;


--
-- Name: measure_status_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE measure_status_type (
    mst_id integer NOT NULL,
    code character varying(12) NOT NULL,
    omschrijving character varying(90),
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: measure_status_type_mst_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE measure_status_type_mst_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: measure_status_type_mst_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE measure_status_type_mst_id_seq OWNED BY measure_status_type.mst_id;


--
-- Name: measurement_regime_type_mmr_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE measurement_regime_type_mmr_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: measurement_regime_type_mmr_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE measurement_regime_type_mmr_id_seq OWNED BY measurement_regime_type.mmr_id;


--
-- Name: membership; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE membership (
    membershipid integer NOT NULL,
    wkpuserid integer NOT NULL,
    applicationid integer NOT NULL,
    password character varying(128) NOT NULL,
    passwordformat integer NOT NULL,
    passwordsalt character varying(128) NOT NULL,
    email character varying(256),
    passwordquestion character varying(256),
    passwordanswer character varying(128),
    isapproved boolean NOT NULL,
    islockedout boolean NOT NULL,
    createdate timestamp with time zone NOT NULL,
    lastlogindate timestamp with time zone NOT NULL,
    lastpasswordchangeddate timestamp with time zone NOT NULL,
    lastlockoutdate timestamp with time zone NOT NULL,
    failedpasswordattemptcount integer NOT NULL,
    failedpasswordattemptwindowstart timestamp with time zone NOT NULL,
    failedpasswordanswerattemptcount integer NOT NULL,
    failedpasswordanswerattemptwindowsstart timestamp with time zone NOT NULL,
    comment character varying(256)
);


--
-- Name: membership_membershipid_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE membership_membershipid_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: membership_membershipid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE membership_membershipid_seq OWNED BY membership.membershipid;


--
-- Name: mnf_parameter; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE mnf_parameter (
    mnf_id integer NOT NULL,
    name character varying(50) NOT NULL,
    value character varying(50) NOT NULL,
    value_uom_id integer,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: monitored_measure; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE monitored_measure (
    mtm_id integer NOT NULL,
    monitored_measure_type character varying(50) NOT NULL,
    level_of_measure_id integer NOT NULL,
    prime_competent_authority_id integer,
    derived_from_measure_id integer,
    last_change_time timestamp without time zone NOT NULL,
    rpv_id integer
);


--
-- Name: COLUMN monitored_measure.monitored_measure_type; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN monitored_measure.monitored_measure_type IS 'geeft het subtype v.d. monitored_measure aan';


--
-- Name: COLUMN monitored_measure.rpv_id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN monitored_measure.rpv_id IS 'Deze rpv_id geeft de ''Uitvoering in'' van de maatregel aan.';


--
-- Name: monitored_measure_eu_fund; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE monitored_measure_eu_fund (
    mtm_id integer NOT NULL,
    euf_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: monitored_measure_mtm_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE monitored_measure_mtm_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: monitored_measure_mtm_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE monitored_measure_mtm_id_seq OWNED BY monitored_measure.mtm_id;


--
-- Name: monitoring_feature_report_to; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE monitoring_feature_report_to (
    mnf_id integer NOT NULL,
    lgr_id integer NOT NULL,
    report_date timestamp without time zone NOT NULL,
    observation_required boolean NOT NULL,
    observing_capability_required boolean NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: monitoring_object_genealogy; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE monitoring_object_genealogy (
    mno_id_supersedes integer NOT NULL,
    mno_id_superseded_by integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: monitoring_object_hierarchy; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE monitoring_object_hierarchy (
    mno_id_narrower integer NOT NULL,
    mno_id_broader integer NOT NULL,
    linking_time timestamp without time zone NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: monitoring_object_mno_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE monitoring_object_mno_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: monitoring_object_mno_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE monitoring_object_mno_id_seq OWNED BY monitoring_object.mno_id;


--
-- Name: monitoring_object_other_ids; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE monitoring_object_other_ids (
    moi_id integer NOT NULL,
    mno_id integer NOT NULL,
    hydro_id_local_id character varying(36) NOT NULL,
    hydro_id_ore_id integer NOT NULL
);


--
-- Name: monitoring_object_other_ids_moi_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE monitoring_object_other_ids_moi_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: monitoring_object_other_ids_moi_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE monitoring_object_other_ids_moi_id_seq OWNED BY monitoring_object_other_ids.moi_id;


--
-- Name: monitoring_object_quality_element_moqe_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE monitoring_object_quality_element_moqe_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: monitoring_object_quality_element_moqe_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE monitoring_object_quality_element_moqe_id_seq OWNED BY monitoring_object_quality_element.moqe_id;


--
-- Name: monitoring_use; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE monitoring_use (
    gms_id integer NOT NULL,
    mtt_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: mv_oordeel_chemie_owm; Type: MATERIALIZED VIEW; Schema: public; Owner: -
--

CREATE MATERIALIZED VIEW mv_oordeel_chemie_owm AS
 WITH oordeel AS (
         SELECT DISTINCT ON (sys.sys_id, swcs.opt_id) sys.sys_id,
            sys.swb_id,
            sys.year_of_status,
            swcs.opt_id,
            swcs.swcs_id,
            swcs.css_id,
            hdo_swb.hdo_id,
            hdo_swb.wkrv_id,
            hdo_swb.inspire_id_local_id
           FROM ((sw_chemical_substance_status swcs
             JOIN swb_yearly_status sys ON ((swcs.sys_id = sys.sys_id)))
             JOIN hydro_object hdo_swb ON ((hdo_swb.hdo_id = sys.swb_id)))
          WHERE (swcs.eumg_id = 3)
        ), opt AS (
         SELECT observed_property_type.opt_id AS "DB_ID",
            typering_type.code AS "Tpering_Code",
            grootheid_type.code AS "Grootheid_Code",
            chemische_stof_type.code AS "ChemischeStof_code"
           FROM (((observed_property_type
             LEFT JOIN grootheid_type ON ((grootheid_type.grh_id = observed_property_type.quantity_id)))
             LEFT JOIN (chemische_stof_type
             JOIN substance_group_element ON ((chemische_stof_type.chs_id = substance_group_element.chs_id))) ON ((substance_group_element.ssge_id = observed_property_type.substance_group_id)))
             LEFT JOIN typering_type ON ((typering_type.typ_id = observed_property_type.indicator_id)))
        )
 SELECT oordeel.swb_id,
    oordeel.inspire_id_local_id AS "Waterlichaam_identificatie",
    oordeel.wkrv_id AS "Waterlichaam_Versie",
    hdo_rbd.inspire_id_local_id AS stroomgebieddistrict,
    oordeel.year_of_status AS "Rapportagejaar",
    opt."Tpering_Code",
    opt."Grootheid_Code",
    opt."ChemischeStof_code",
    classification_type.description AS "Oordeel",
    geometrytype(mrz.geometry) AS geometry_type,
    ('CH'::text || oordeel.css_id) AS "Unique_Key"
   FROM ((((((oordeel
     JOIN management_regulation_or_restriction_zone mrz ON ((oordeel.swb_id = mrz.mrz_id)))
     JOIN water_body wb ON ((wb.wbd_id = mrz.mrz_id)))
     JOIN river_basin_disrict rbd ON ((rbd.rbd_id = wb.rbd_id)))
     JOIN hydro_object hdo_rbd ON ((rbd.rbd_id = hdo_rbd.hdo_id)))
     JOIN classification_type ON ((oordeel.swcs_id = classification_type.cls_id)))
     JOIN opt ON ((opt."DB_ID" = oordeel.opt_id)))
  WITH NO DATA;


--
-- Name: mv_oordeel_ecologie_owm; Type: MATERIALIZED VIEW; Schema: public; Owner: -
--

CREATE MATERIALIZED VIEW mv_oordeel_ecologie_owm AS
 WITH oordeel AS (
         SELECT DISTINCT ON (sys.sys_id, swes.opt_id) sys.sys_id,
            sys.swb_id,
            sys.year_of_status,
            swes.wbpm_id,
            swes.opt_id,
            swes.eumg_id,
            swes.swes_id,
            swes.ecs_id,
            hdo_swb.hdo_id,
            hdo_swb.wkrv_id,
            hdo_swb.inspire_id_local_id
           FROM ((sw_ecological_status swes
             JOIN swb_yearly_status sys ON ((swes.sys_id = sys.sys_id)))
             JOIN hydro_object hdo_swb ON ((hdo_swb.hdo_id = sys.swb_id)))
          WHERE (swes.eumg_id = 3)
        ), opt AS (
         SELECT observed_property_type.opt_id AS "DB_ID",
            typering_type.code AS "Tpering_Code",
            grootheid_type.code AS "Grootheid_Code",
            chemische_stof_type.code AS "ChemischeStof_code"
           FROM (((observed_property_type
             LEFT JOIN grootheid_type ON ((grootheid_type.grh_id = observed_property_type.quantity_id)))
             LEFT JOIN (chemische_stof_type
             JOIN substance_group_element ON ((chemische_stof_type.chs_id = substance_group_element.chs_id))) ON ((substance_group_element.ssge_id = observed_property_type.substance_group_id)))
             LEFT JOIN typering_type ON ((typering_type.typ_id = observed_property_type.indicator_id)))
        )
 SELECT oordeel.swb_id,
    oordeel.inspire_id_local_id AS "Waterlichaam_identificatie",
    oordeel.wkrv_id AS "Waterlichaam_Versie",
    hdo_rbd.inspire_id_local_id AS stroomgebieddistrict,
    oordeel.year_of_status AS "Rapportagejaar",
    oordeel.opt_id AS "Waargenomen_Eigenschap_DB_ID",
    opt."Tpering_Code",
    opt."Grootheid_Code",
    opt."ChemischeStof_code",
    classification_type.description AS "Oordeel",
    oordeel.eumg_id AS "Oordeel_Type_ID",
    oordeel.wbpm_id AS "WaardebepalingsMethode_ID",
    geometrytype(mrz.geometry) AS geometry_type,
    ('EC'::text || oordeel.ecs_id) AS "Unique_Key"
   FROM ((((((oordeel
     JOIN management_regulation_or_restriction_zone mrz ON ((oordeel.swb_id = mrz.mrz_id)))
     JOIN water_body wb ON ((wb.wbd_id = oordeel.swb_id)))
     JOIN river_basin_disrict rbd ON ((rbd.rbd_id = wb.rbd_id)))
     JOIN hydro_object hdo_rbd ON ((rbd.rbd_id = hdo_rbd.hdo_id)))
     JOIN classification_type ON ((oordeel.swes_id = classification_type.cls_id)))
     JOIN opt ON ((opt."DB_ID" = oordeel.opt_id)))
  WITH NO DATA;


--
-- Name: mzc_legal_basis; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE mzc_legal_basis (
    mzc_id integer NOT NULL,
    lgr_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: namespace_type_ns_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE namespace_type_ns_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: namespace_type_ns_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE namespace_type_ns_id_seq OWNED BY namespace_type.ns_id;


--
-- Name: natural_background_levels; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE natural_background_levels (
    nbl_id integer NOT NULL,
    gwb_id integer NOT NULL,
    opt_id integer NOT NULL,
    priority boolean NOT NULL,
    concentration_value double precision NOT NULL,
    concentration_uom_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: natural_background_levels_nbl_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE natural_background_levels_nbl_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: natural_background_levels_nbl_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE natural_background_levels_nbl_id_seq OWNED BY natural_background_levels.nbl_id;


--
-- Name: norm; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE norm (
    nrm_id integer NOT NULL,
    naam_namespace_id integer NOT NULL,
    lokale_naam character varying(50) NOT NULL,
    observed_property integer NOT NULL,
    opmerking text,
    uri character varying(255),
    defined_at_level_id integer,
    norm_groep_id integer NOT NULL,
    wkrv_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: norm_feature; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE norm_feature (
    nrm_id integer NOT NULL,
    hdo_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: norm_groep_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE norm_groep_type (
    nmgp_id integer NOT NULL,
    nmkd_id integer NOT NULL,
    code character varying(12) NOT NULL,
    omschrijving character varying(90) NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying,
    id integer
);


--
-- Name: norm_groep_type_nmgp_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE norm_groep_type_nmgp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: norm_groep_type_nmgp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE norm_groep_type_nmgp_id_seq OWNED BY norm_groep_type.nmgp_id;


--
-- Name: norm_hulp_mapping; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE norm_hulp_mapping (
    nhm_id integer NOT NULL,
    parameter_typering_code character varying(20) NOT NULL,
    lokale_naam character varying(50) NOT NULL,
    opt_id integer NOT NULL,
    typ_id integer,
    eenh_id integer NOT NULL,
    grh_id integer,
    chs_id integer,
    hdh_id integer NOT NULL,
    cptm_id integer NOT NULL,
    wbm_id integer NOT NULL,
    sortering integer NOT NULL
);


--
-- Name: norm_hulp_mapping_nhm_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE norm_hulp_mapping_nhm_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: norm_hulp_mapping_nhm_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE norm_hulp_mapping_nhm_id_seq OWNED BY norm_hulp_mapping.nhm_id;


--
-- Name: norm_kader_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE norm_kader_type (
    nmkd_id integer NOT NULL,
    code character varying(12) NOT NULL,
    omschrijving character varying(90) NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: norm_kader_type_nmkd_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE norm_kader_type_nmkd_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: norm_kader_type_nmkd_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE norm_kader_type_nmkd_id_seq OWNED BY norm_kader_type.nmkd_id;


--
-- Name: norm_nrm_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE norm_nrm_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: norm_nrm_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE norm_nrm_id_seq OWNED BY norm.nrm_id;


--
-- Name: norm_value; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE norm_value (
    nrmv_id integer NOT NULL,
    nrm_id integer NOT NULL,
    value_processing_method integer NOT NULL,
    cptm_id integer NOT NULL,
    lowerbound_value double precision,
    lowerbound_uom_id integer,
    upperbound_value double precision,
    upperbound_uom_id integer,
    begin_lifespan_version timestamp without time zone NOT NULL,
    end_lifespan_version timestamp without time zone,
    opmerking text,
    uri character varying(255),
    opname_datum timestamp without time zone,
    norm_klasse_id integer NOT NULL,
    lowerbound_limit_symbol_id integer,
    upperbound_limit_symbol_id integer
);


--
-- Name: norm_value_nrmv_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE norm_value_nrmv_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: norm_value_nrmv_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE norm_value_nrmv_id_seq OWNED BY norm_value.nrmv_id;


--
-- Name: normpakket; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE normpakket (
    nmpk_id integer NOT NULL,
    norm_groep_id integer NOT NULL,
    norm_kader_id integer NOT NULL,
    opmerking text,
    uri character varying(255)
);


--
-- Name: COLUMN normpakket.uri; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN normpakket.uri IS 'Koppeling (hyperlink) naar een locatie waar aanvullende informatie gevonden / verkregen kan worden.';


--
-- Name: normpakket_nmpk_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE normpakket_nmpk_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: normpakket_nmpk_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE normpakket_nmpk_id_seq OWNED BY normpakket.nmpk_id;


--
-- Name: object_group_ojg_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE object_group_ojg_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: object_group_ojg_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE object_group_ojg_id_seq OWNED BY object_group.ojg_id;


--
-- Name: object_state_column_required; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE object_state_column_required (
    ost_id integer NOT NULL,
    table_name text NOT NULL,
    column_name text NOT NULL,
    required boolean NOT NULL
);


--
-- Name: object_state_column_required_ost_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE object_state_column_required_ost_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: object_state_column_required_ost_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE object_state_column_required_ost_id_seq OWNED BY object_state_column_required.ost_id;


--
-- Name: object_state_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE object_state_type (
    ost_id integer NOT NULL,
    code character varying(50) NOT NULL,
    decsription text NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: object_state_type_ost_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE object_state_type_ost_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: object_state_type_ost_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE object_state_type_ost_id_seq OWNED BY object_state_type.ost_id;


--
-- Name: objectives_exemption_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE objectives_exemption_type (
    obex_id integer NOT NULL,
    name character varying(50) NOT NULL,
    description text,
    article_nr character varying(3),
    article_description character varying(50),
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: objectives_exemption_type_obex_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE objectives_exemption_type_obex_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: objectives_exemption_type_obex_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE objectives_exemption_type_obex_id_seq OWNED BY objectives_exemption_type.obex_id;


--
-- Name: obs_ctx_role_type_ocr_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE obs_ctx_role_type_ocr_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: obs_ctx_role_type_ocr_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE obs_ctx_role_type_ocr_id_seq OWNED BY obs_ctx_role_type.ocr_id;


--
-- Name: observation_context_role_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE observation_context_role_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: observation_context_role_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE observation_context_role_id_seq OWNED BY observation_context.role_id;


--
-- Name: observation_obs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE observation_obs_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: observation_obs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE observation_obs_id_seq OWNED BY observation.obs_id;


--
-- Name: observation_parameter; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE observation_parameter (
    obs_id integer NOT NULL,
    name text NOT NULL,
    value text NOT NULL
);


--
-- Name: observation_process_copy_dietmar; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE observation_process_copy_dietmar (
    obp_id integer NOT NULL,
    ore_id integer,
    last_change_time timestamp without time zone NOT NULL,
    wbpm_id integer,
    sensing_location_type_id integer,
    sample_pre_treatment_method_id integer,
    sample_destruction_method_id integer,
    certification_id integer,
    analytical_technique_id integer,
    accreditation_org_id integer,
    nen3610_id_namespace_id integer
);


--
-- Name: observation_process_copy_dietmar_obp_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE observation_process_copy_dietmar_obp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: observation_process_copy_dietmar_obp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE observation_process_copy_dietmar_obp_id_seq OWNED BY observation_process_copy_dietmar.obp_id;


--
-- Name: observed_property_type_acc; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE observed_property_type_acc (
    opt_id integer,
    observed_property_type_class character varying(50),
    result_type character varying(50),
    hoedanigheid_id integer,
    object_group_id integer,
    quantity_id integer,
    taxa_group_id integer,
    substance_group_id integer,
    indicator_id integer,
    classification_group_id integer,
    remarks text,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50)
);


--
-- Name: observed_property_type_opt_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE observed_property_type_opt_id_seq
    START WITH 5915
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: observed_property_type_opt_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE observed_property_type_opt_id_seq OWNED BY observed_property_type.opt_id;


--
-- Name: observing_capability_observation_ocbs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE observing_capability_observation_ocbs_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: observing_capability_observation_ocbs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE observing_capability_observation_ocbs_id_seq OWNED BY observing_capability_observation.ocbs_id;


--
-- Name: observing_capability_osc_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE observing_capability_osc_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: observing_capability_osc_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE observing_capability_osc_id_seq OWNED BY observing_capability.osc_id;


--
-- Name: observing_capability_responsible_party_ocrp_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE observing_capability_responsible_party_ocrp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: observing_capability_responsible_party_ocrp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE observing_capability_responsible_party_ocrp_id_seq OWNED BY observing_capability_responsible_party.ocrp_id;


--
-- Name: observing_capability_sample; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE observing_capability_sample (
    ocsa_id integer NOT NULL,
    smpl_id integer NOT NULL,
    osc_id integer NOT NULL,
    is_approved boolean DEFAULT false NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: observing_capability_sample_ocsa_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE observing_capability_sample_ocsa_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: observing_capability_sample_ocsa_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE observing_capability_sample_ocsa_id_seq OWNED BY observing_capability_sample.ocsa_id;


--
-- Name: operational_activity_period; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE operational_activity_period (
    emf_id integer NOT NULL,
    activity_begin timestamp without time zone NOT NULL,
    activity_end timestamp without time zone,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: opt_class_result_type_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE opt_class_result_type_type (
    observed_property_type_class_type character varying(50) NOT NULL,
    result_type_type character varying(50) NOT NULL,
    last_changed_date timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: TABLE opt_class_result_type_type; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE opt_class_result_type_type IS 'Lijst van mogelijke waarden en combinaties van opt.observed_property_type_class en opt.result_type.
Toegevoegd door SF 2016-08-24';


--
-- Name: organisation_category_type_ocat_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE organisation_category_type_ocat_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: organisation_category_type_ocat_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE organisation_category_type_ocat_id_seq OWNED BY organisation_category_type.ocat_id;


--
-- Name: organisatorische_eenheid_ore_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE organisatorische_eenheid_ore_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: organisatorische_eenheid_ore_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE organisatorische_eenheid_ore_id_seq OWNED BY organisatorische_eenheid.ore_id;


--
-- Name: organisatorische_eenheid_wkpusergroup; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE organisatorische_eenheid_wkpusergroup (
    organisatorische_eenheid_wkpusergroupid integer NOT NULL,
    wkpusergroupid integer NOT NULL,
    ore_id integer NOT NULL
);


--
-- Name: organisatorische_eenheid_wkpu_organisatorische_eenheid_wkpu_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE organisatorische_eenheid_wkpu_organisatorische_eenheid_wkpu_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: organisatorische_eenheid_wkpu_organisatorische_eenheid_wkpu_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE organisatorische_eenheid_wkpu_organisatorische_eenheid_wkpu_seq OWNED BY organisatorische_eenheid_wkpusergroup.organisatorische_eenheid_wkpusergroupid;


--
-- Name: other_basic_measure113b_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE other_basic_measure113b_type (
    obmb_id integer NOT NULL,
    name character varying(90) NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: other_basic_measure113b_type_obmb_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE other_basic_measure113b_type_obmb_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: other_basic_measure113b_type_obmb_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE other_basic_measure113b_type_obmb_id_seq OWNED BY other_basic_measure113b_type.obmb_id;


--
-- Name: other_monitoring_use_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE other_monitoring_use_type (
    omut_id integer NOT NULL,
    code character varying(12) NOT NULL,
    description character varying(90),
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: other_monitoring_use_type_omut_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE other_monitoring_use_type_omut_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: other_monitoring_use_type_omut_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE other_monitoring_use_type_omut_id_seq OWNED BY other_monitoring_use_type.omut_id;


--
-- Name: page; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE page (
    page_id integer NOT NULL,
    name character varying(50) NOT NULL,
    thema character varying(50) NOT NULL,
    richtlijn character varying(50) NOT NULL,
    start_date timestamp with time zone,
    end_date timestamp with time zone
);


--
-- Name: page_group; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE page_group (
    pg_id integer NOT NULL,
    name character varying(50) NOT NULL,
    start_date timestamp with time zone,
    end_date timestamp with time zone
);


--
-- Name: page_group_pg_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE page_group_pg_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: page_group_pg_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE page_group_pg_id_seq OWNED BY page_group.pg_id;


--
-- Name: page_page_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE page_page_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: page_page_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE page_page_id_seq OWNED BY page.page_id;


--
-- Name: page_pagegroup; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE page_pagegroup (
    pagepg_id integer NOT NULL,
    pg_id integer NOT NULL,
    page_id integer NOT NULL
);


--
-- Name: page_pagegroup_pagepg_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE page_pagegroup_pagepg_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: page_pagegroup_pagepg_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE page_pagegroup_pagepg_id_seq OWNED BY page_pagegroup.pagepg_id;


--
-- Name: parameter_aquo_ds_20160105; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE parameter_aquo_ds_20160105 (
    code character varying(12) NOT NULL,
    omschrijving character varying(100) NOT NULL,
    casnummer character varying(12) NOT NULL,
    groep character varying(60) NOT NULL,
    id integer NOT NULL,
    d_begin date NOT NULL,
    d_eind date,
    d_status character varying(40)
);


--
-- Name: TABLE parameter_aquo_ds_20160105; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE parameter_aquo_ds_20160105 IS 'Parameter: Contains properties of a substance, organism or object that can be measured or determined.';


--
-- Name: COLUMN parameter_aquo_ds_20160105.code; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN parameter_aquo_ds_20160105.code IS 'a property of a system, medium, organism or object that can be measured or determined.';


--
-- Name: COLUMN parameter_aquo_ds_20160105.omschrijving; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN parameter_aquo_ds_20160105.omschrijving IS 'a property of a system, medium, organism or object that can be measured or determined.';


--
-- Name: COLUMN parameter_aquo_ds_20160105.casnummer; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN parameter_aquo_ds_20160105.casnummer IS 'A coding of a substance which makes recognition possible in case of multiple trading names.';


--
-- Name: COLUMN parameter_aquo_ds_20160105.groep; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN parameter_aquo_ds_20160105.groep IS 'Group to which a parameter belongs. The group can be chemical substance, physical property or object .';


--
-- Name: parameter_use_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE parameter_use_type (
    prus_id integer NOT NULL,
    name character varying(50) NOT NULL,
    description text,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: parameter_use_type_prus_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE parameter_use_type_prus_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: parameter_use_type_prus_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE parameter_use_type_prus_id_seq OWNED BY parameter_use_type.prus_id;


--
-- Name: physical_alteration_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE physical_alteration_type (
    pat_id integer NOT NULL,
    description character varying(255),
    remark character varying(255),
    order_id integer,
    last_changed_date timestamp without time zone
);


--
-- Name: physical_alteration_type_pat_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE physical_alteration_type_pat_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: physical_alteration_type_pat_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE physical_alteration_type_pat_id_seq OWNED BY physical_alteration_type.pat_id;


--
-- Name: plaatsbepalingsapparaat_type_pba_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE plaatsbepalingsapparaat_type_pba_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: plaatsbepalingsapparaat_type_pba_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE plaatsbepalingsapparaat_type_pba_id_seq OWNED BY plaatsbepalingsapparaat_type.pba_id;


--
-- Name: planned_feature_monitoring; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE planned_feature_monitoring (
    pmf_id integer NOT NULL,
    hdo_id integer NOT NULL,
    qem_id integer,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: planned_feature_monitoring_pmf_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE planned_feature_monitoring_pmf_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: planned_feature_monitoring_pmf_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE planned_feature_monitoring_pmf_id_seq OWNED BY planned_feature_monitoring.pmf_id;


--
-- Name: pollutant_trend; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE pollutant_trend (
    pltr_id integer NOT NULL,
    gwys_id integer NOT NULL,
    opt_id integer NOT NULL,
    comment character varying(2000),
    last_change_time timestamp without time zone NOT NULL,
    depth_m integer DEFAULT 10 NOT NULL,
    cls_id integer NOT NULL
);


--
-- Name: pollutant_trend_pltr_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE pollutant_trend_pltr_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: pollutant_trend_pltr_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE pollutant_trend_pltr_id_seq OWNED BY pollutant_trend.pltr_id;


--
-- Name: pom_base_measure113a; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE pom_base_measure113a (
    pbm_id integer NOT NULL,
    rbmp_id integer NOT NULL,
    bma_id integer NOT NULL,
    implemented_id integer NOT NULL,
    summary text NOT NULL,
    comments text,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: pom_base_measure113a_pbm_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE pom_base_measure113a_pbm_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: pom_base_measure113a_pbm_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE pom_base_measure113a_pbm_id_seq OWNED BY pom_base_measure113a.pbm_id;


--
-- Name: pom_other_basic_measure113b; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE pom_other_basic_measure113b (
    pobb_id integer NOT NULL,
    rbmp_id integer NOT NULL,
    obmb_id integer NOT NULL,
    is_implemented boolean NOT NULL,
    description character varying(2000),
    comments character varying(2000),
    associated_link_desc text,
    associated_link_uri character varying(255),
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: pressure_category_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE pressure_category_type (
    pcat_id integer NOT NULL,
    code character varying(50) NOT NULL,
    omschrijving character varying(90) NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: pressure_category_type_pcat_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE pressure_category_type_pcat_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: pressure_category_type_pcat_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE pressure_category_type_pcat_id_seq OWNED BY pressure_category_type.pcat_id;


--
-- Name: pressure_relevance_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE pressure_relevance_type (
    prr_id integer NOT NULL,
    omschrijving character varying(50) NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: pressure_relevance_type_prr_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE pressure_relevance_type_prr_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: pressure_relevance_type_prr_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE pressure_relevance_type_prr_id_seq OWNED BY pressure_relevance_type.prr_id;


--
-- Name: process_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE process_type (
    prc_id integer NOT NULL,
    code character varying(12) NOT NULL,
    description character varying(90),
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: process_type_prc_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE process_type_prc_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: process_type_prc_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE process_type_prc_id_seq OWNED BY process_type.prc_id;


--
-- Name: profile; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE profile (
    profileid integer NOT NULL,
    wkpuserid integer NOT NULL,
    propertynames character varying(4000) NOT NULL,
    propertyvaluestrings character varying(4000) NOT NULL,
    propertyvaluebinary bytea,
    lastupdateddate timestamp without time zone NOT NULL
);


--
-- Name: profile_profileid_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE profile_profileid_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: profile_profileid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE profile_profileid_seq OWNED BY profile.profileid;


--
-- Name: program_monitoring_object; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE program_monitoring_object (
    program_mno_id integer NOT NULL,
    object_mno_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: projection; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE projection (
    pmfp_id integer NOT NULL,
    pmf_id integer NOT NULL,
    monitoring_goal_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: projection_pmfp_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE projection_pmfp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: projection_pmfp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE projection_pmfp_id_seq OWNED BY projection.pmfp_id;


--
-- Name: protected_area_type_pat_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE protected_area_type_pat_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: protected_area_type_pat_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE protected_area_type_pat_id_seq OWNED BY protected_area_type.pat_id;


--
-- Name: qe_ecological_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE qe_ecological_type (
    qeel_id integer NOT NULL,
    name character varying(50) NOT NULL,
    description text,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: qe_ecological_type_qeel_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE qe_ecological_type_qeel_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: qe_ecological_type_qeel_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE qe_ecological_type_qeel_id_seq OWNED BY qe_ecological_type.qeel_id;


--
-- Name: quality_element_observation_qeo_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE quality_element_observation_qeo_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: quality_element_observation_qeo_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE quality_element_observation_qeo_id_seq OWNED BY quality_element_observation.qeo_id;


--
-- Name: quality_element_qem_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE quality_element_qem_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: quality_element_qem_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE quality_element_qem_id_seq OWNED BY quality_element.qem_id;


--
-- Name: quality_element_sample_qes_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE quality_element_sample_qes_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: quality_element_sample_qes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE quality_element_sample_qes_id_seq OWNED BY quality_element_sample.qes_id;


--
-- Name: reason_change_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE reason_change_type (
    rct_id integer NOT NULL,
    description character varying(255),
    remark character varying(255),
    order_id integer,
    wie character varying(255),
    last_changed_date timestamp without time zone
);


--
-- Name: reason_change_type_rct_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE reason_change_type_rct_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: reason_change_type_rct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE reason_change_type_rct_id_seq OWNED BY reason_change_type.rct_id;


--
-- Name: rel_hdo_role_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE rel_hdo_role_type (
    rhr_id integer NOT NULL,
    description character varying(50) NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: rel_role_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE rel_role_type (
    rrt_id integer NOT NULL,
    description character varying(50) NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: rel_samp_feat_role_type_rsfr_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE rel_samp_feat_role_type_rsfr_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: rel_samp_feat_role_type_rsfr_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE rel_samp_feat_role_type_rsfr_id_seq OWNED BY rel_samp_feat_role_type.rsfr_id;


--
-- Name: related_hydro_object; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE related_hydro_object (
    from_hdo integer NOT NULL,
    to_hdo integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL,
    comment character varying(200),
    rrt_id integer NOT NULL
);


--
-- Name: related_monitoring_object; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE related_monitoring_object (
    from_mno integer NOT NULL,
    to_mno integer NOT NULL,
    rrt_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL,
    comment character varying(200)
);


--
-- Name: relation_gwb_swb; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE relation_gwb_swb (
    gwb_id integer NOT NULL,
    swb_id integer NOT NULL,
    relation_type_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL,
    gwsw_id integer NOT NULL
);


--
-- Name: relation_gwb_swb_gwsw_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE relation_gwb_swb_gwsw_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: relation_gwb_swb_gwsw_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE relation_gwb_swb_gwsw_id_seq OWNED BY relation_gwb_swb.gwsw_id;


--
-- Name: relation_ore_wbd; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE relation_ore_wbd (
    ore_wbd_id integer NOT NULL,
    ore_id integer NOT NULL,
    wbd_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: relation_ore_wbd_ore_wbd_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE relation_ore_wbd_ore_wbd_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: relation_ore_wbd_ore_wbd_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE relation_ore_wbd_ore_wbd_id_seq OWNED BY relation_ore_wbd.ore_wbd_id;


--
-- Name: relation_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE relation_type (
    rlt_id integer NOT NULL,
    code character varying(24) NOT NULL,
    description character varying(90) NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: relation_type_rlt_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE relation_type_rlt_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: relation_type_rlt_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE relation_type_rlt_id_seq OWNED BY relation_type.rlt_id;


--
-- Name: report_version; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE report_version (
    rpv_id integer NOT NULL,
    rpp_id integer NOT NULL,
    begin_lifespan_version timestamp without time zone NOT NULL,
    end_lifespan_version timestamp without time zone,
    ost_id integer NOT NULL,
    is_public_data boolean NOT NULL,
    wkrv_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: report_version_rpv_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE report_version_rpv_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: report_version_rpv_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE report_version_rpv_id_seq OWNED BY report_version.rpv_id;


--
-- Name: reporting_period; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE reporting_period (
    rpp_id integer NOT NULL,
    leg_ref_id integer NOT NULL,
    period_start date NOT NULL,
    period_end date,
    description text NOT NULL,
    last_change_time timestamp without time zone NOT NULL,
    isactive boolean DEFAULT true NOT NULL
);


--
-- Name: reporting_period_rpp_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE reporting_period_rpp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: reporting_period_rpp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE reporting_period_rpp_id_seq OWNED BY reporting_period.rpp_id;


--
-- Name: result_acquisition_source_type_ras_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE result_acquisition_source_type_ras_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: result_acquisition_source_type_ras_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE result_acquisition_source_type_ras_id_seq OWNED BY result_acquisition_source_type.ras_id;


--
-- Name: river_basin_management_plan; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE river_basin_management_plan (
    rbmp_id integer NOT NULL,
    rbd_id integer NOT NULL,
    wkrv_id integer NOT NULL,
    databases_and_repositories_description character varying(255),
    general_supporting_documents character varying(255),
    name character varying(255) NOT NULL,
    summary_of_programmes text NOT NULL,
    summary_preparation_first_update text NOT NULL,
    summary_processes_and_procedures text NOT NULL,
    table_of_contents text NOT NULL,
    pom_general_additional_comments text,
    last_change_time timestamp without time zone NOT NULL,
    pom_reference character varying(255)
);


--
-- Name: COLUMN river_basin_management_plan.databases_and_repositories_description; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN river_basin_management_plan.databases_and_repositories_description IS 'must be valid URL';


--
-- Name: COLUMN river_basin_management_plan.general_supporting_documents; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN river_basin_management_plan.general_supporting_documents IS 'must be valid URL';


--
-- Name: river_basin_management_plan_rbmp_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE river_basin_management_plan_rbmp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: river_basin_management_plan_rbmp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE river_basin_management_plan_rbmp_id_seq OWNED BY river_basin_management_plan.rbmp_id;


--
-- Name: role; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE role (
    roleid integer NOT NULL,
    applicationid integer NOT NULL,
    rolename character varying(256) NOT NULL,
    description character varying(256)
);


--
-- Name: role_roleid_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE role_roleid_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: role_roleid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE role_roleid_seq OWNED BY role.roleid;


--
-- Name: sampled_feature; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE sampled_feature (
    hdo_id integer NOT NULL,
    mnf_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: sampling_proces_smp_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE sampling_proces_smp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: sampling_proces_smp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE sampling_proces_smp_id_seq OWNED BY sampling_proces.smp_id;


--
-- Name: specialised_emf_type_semf_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE specialised_emf_type_semf_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: specialised_emf_type_semf_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE specialised_emf_type_semf_id_seq OWNED BY specialised_emf_type.semf_id;


--
-- Name: station_level_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE station_level_type (
    slt_id integer NOT NULL,
    code character varying(12) NOT NULL,
    description character varying(90),
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: station_level_type_slt_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE station_level_type_slt_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: station_level_type_slt_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE station_level_type_slt_id_seq OWNED BY station_level_type.slt_id;


--
-- Name: station_type_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE station_type_type (
    stt_id integer NOT NULL,
    code character varying(12) NOT NULL,
    description character varying(90),
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: station_type_type_stt_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE station_type_type_stt_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: station_type_type_stt_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE station_type_type_stt_id_seq OWNED BY station_type_type.stt_id;


--
-- Name: subsite_type_sst_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE subsite_type_sst_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: subsite_type_sst_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE subsite_type_sst_id_seq OWNED BY subsite_type.sst_id;


--
-- Name: substance_group_ssg_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE substance_group_ssg_id_seq
    START WITH 3151
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: substance_group_ssg_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE substance_group_ssg_id_seq OWNED BY substance_group.ssg_id;


--
-- Name: supp_add_measure_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE supp_add_measure_type (
    smnl_id integer NOT NULL,
    rbmp_id integer NOT NULL,
    namespace_id integer NOT NULL,
    local_id character varying(50) NOT NULL,
    measure_name character varying(100) NOT NULL,
    measure_description character varying(2000),
    comment character varying(5000),
    associated_link_desc character varying(255),
    associated_link_uri character varying(255),
    is_additional_measure boolean,
    legislation_ref_id integer NOT NULL,
    amount_value double precision NOT NULL,
    amount_uom_id integer NOT NULL,
    initiative_party text,
    smeu_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL,
    initiative_party_ocat_id integer NOT NULL,
    "is_N2000_relevant" boolean DEFAULT false NOT NULL,
    is_abstraction_relevant boolean DEFAULT false NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying,
    process_info text
);


--
-- Name: COLUMN supp_add_measure_type.initiative_party; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN supp_add_measure_type.initiative_party IS 'If multiple responsibleParties involved: 
 If ResonsibleParty(s) from ''waterboards'' then ''waterboards''; if responsibleParty also from Rijkswaterstaat then add ''; waterboards''; if responsibleParty also from Provinces then add ''; provinces''';


--
-- Name: sw_abstraction_point; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE sw_abstraction_point (
    sasp_id integer NOT NULL,
    rewab_id integer NOT NULL,
    swat_id integer NOT NULL,
    waterabstraction_from character varying(255),
    last_change_time time without time zone NOT NULL
);


--
-- Name: sw_abstracion_point_sasp_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE sw_abstracion_point_sasp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: sw_abstracion_point_sasp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE sw_abstracion_point_sasp_id_seq OWNED BY sw_abstraction_point.sasp_id;


--
-- Name: sw_abstraction_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE sw_abstraction_type (
    swat_id integer NOT NULL,
    description character varying(50),
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: sw_aggregated_pressure_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE sw_aggregated_pressure_type (
    swap_id integer NOT NULL,
    name character varying(90) NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: sw_aggregated_pressure_type_swap_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE sw_aggregated_pressure_type_swap_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: sw_aggregated_pressure_type_swap_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE sw_aggregated_pressure_type_swap_id_seq OWNED BY sw_aggregated_pressure_type.swap_id;


--
-- Name: sw_category_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE sw_category_type (
    swc_id integer NOT NULL,
    name character varying(50) NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: sw_category_type_swc_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE sw_category_type_swc_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: sw_category_type_swc_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE sw_category_type_swc_id_seq OWNED BY sw_category_type.swc_id;


--
-- Name: sw_chemical_substance_status_css_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE sw_chemical_substance_status_css_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: sw_chemical_substance_status_css_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE sw_chemical_substance_status_css_id_seq OWNED BY sw_chemical_substance_status.css_id;


--
-- Name: sw_ecological_status_ecs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE sw_ecological_status_ecs_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: sw_ecological_status_ecs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE sw_ecological_status_ecs_id_seq OWNED BY sw_ecological_status.ecs_id;


--
-- Name: sw_measure43_function; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE sw_measure43_function (
    me43_id integer NOT NULL,
    smee_id integer NOT NULL,
    last_change_time timestamp without time zone
);


--
-- Name: sw_measure43_nl_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE sw_measure43_nl_type (
    me43_id integer NOT NULL,
    omschrijving character varying(255),
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: sw_pressure_requiring_supp_add_measures; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE sw_pressure_requiring_supp_add_measures (
    sprm_id integer NOT NULL,
    comments text,
    spg_id integer NOT NULL,
    sprs_id integer NOT NULL,
    bma_id integer,
    obmb_id integer,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: sw_pressure_requiring_supp_add_measures_sprm_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE sw_pressure_requiring_supp_add_measures_sprm_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: sw_pressure_requiring_supp_add_measures_sprm_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE sw_pressure_requiring_supp_add_measures_sprm_id_seq OWNED BY sw_pressure_requiring_supp_add_measures.sprm_id;


--
-- Name: sw_pressure_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE sw_pressure_type (
    sprs_id integer NOT NULL,
    name character varying(50) NOT NULL,
    description character varying(90) NOT NULL,
    is_only_nl boolean DEFAULT false NOT NULL,
    pressure_category_id integer NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: sw_pressure_type_driver; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE sw_pressure_type_driver (
    sprs_id integer NOT NULL,
    driver_id integer NOT NULL
);


--
-- Name: sw_pressure_type_sprs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE sw_pressure_type_sprs_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: sw_pressure_type_sprs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE sw_pressure_type_sprs_id_seq OWNED BY sw_pressure_type.sprs_id;


--
-- Name: sw_pressure_type_type_category; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE sw_pressure_type_type_category (
    swc_id integer NOT NULL,
    sprs_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: sw_pressures_preventing_good_status; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE sw_pressures_preventing_good_status (
    spg_id integer NOT NULL,
    rbmp_id integer NOT NULL,
    swap_id integer NOT NULL,
    is_basic_measures_enough boolean NOT NULL,
    comments text,
    percentage_failure_rw_value double precision,
    percentage_failure_rw_uom_id integer,
    percentage_failure_lw_value double precision,
    percentage_failure_lw_uom_id integer,
    percentage_failure_tw_value double precision,
    percentage_failure_tw_uom_id integer,
    percentage_failure_cw_value double precision,
    percentage_failure_cw_uom_id integer,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: COLUMN sw_pressures_preventing_good_status.swap_id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN sw_pressures_preventing_good_status.swap_id IS 'sw pressure';


--
-- Name: sw_pressures_preventing_good_status_spg_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE sw_pressures_preventing_good_status_spg_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: sw_pressures_preventing_good_status_spg_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE sw_pressures_preventing_good_status_spg_id_seq OWNED BY sw_pressures_preventing_good_status.spg_id;


--
-- Name: sw_required_supp_measure; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE sw_required_supp_measure (
    sprm_id integer NOT NULL,
    smnl_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: sw_supp_measure_eu_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE sw_supp_measure_eu_type (
    smeu_id integer NOT NULL,
    name character varying(100) NOT NULL,
    eenh_id integer NOT NULL,
    code character varying(4) NOT NULL,
    hoofdcategorie character varying(32) NOT NULL,
    index smallint NOT NULL,
    klasse character varying(32) NOT NULL,
    subcategorie character varying(100) NOT NULL,
    harmonisatie character varying(32) NOT NULL,
    code_sgbp character varying(50),
    artikel_sgbp character varying(5),
    tablkop_sgbp character varying(100),
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: COLUMN sw_supp_measure_eu_type.name; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN sw_supp_measure_eu_type.name IS 'One from the list: legal, economic, negotiated, emission, practice, abstraction, demand, efficiency, construction, desalination, rehabilitation, recharge, educational, research, other';


--
-- Name: sw_supp_measure_eu_type_smeu_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE sw_supp_measure_eu_type_smeu_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: sw_supp_measure_eu_type_smeu_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE sw_supp_measure_eu_type_smeu_id_seq OWNED BY sw_supp_measure_eu_type.smeu_id;


--
-- Name: sw_test_value; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE sw_test_value (
    stcc_id integer NOT NULL,
    nrmv_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: sw_typology_type_styp_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE sw_typology_type_styp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: sw_typology_type_styp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE sw_typology_type_styp_id_seq OWNED BY sw_typology_type.styp_id;


--
-- Name: swb_art43b_excemption; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE swb_art43b_excemption (
    swb_id integer NOT NULL,
    a43b_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: swb_chem_exemp_pollutant; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE swb_chem_exemp_pollutant (
    swce_id integer NOT NULL,
    chs_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: swb_exemption; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE swb_exemption (
    swce_id integer NOT NULL,
    swb_id integer NOT NULL,
    obex_id integer NOT NULL,
    comment text NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: swb_chemical_exemption_swce_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE swb_chemical_exemption_swce_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: swb_chemical_exemption_swce_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE swb_chemical_exemption_swce_id_seq OWNED BY swb_exemption.swce_id;


--
-- Name: swb_ecol_exemp_qe; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE swb_ecol_exemp_qe (
    swce_id integer NOT NULL,
    opt_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: swb_measures_43a; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE swb_measures_43a (
    swee_id integer NOT NULL,
    swb_id integer NOT NULL,
    fu43_id integer NOT NULL,
    motivation text NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: swb_ecological_exemption_swee_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE swb_ecological_exemption_swee_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: swb_ecological_exemption_swee_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE swb_ecological_exemption_swee_id_seq OWNED BY swb_measures_43a.swee_id;


--
-- Name: swb_excemption_mechanism_44; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE swb_excemption_mechanism_44 (
    swce_id integer NOT NULL,
    exme_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: swb_physical_alteration; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE swb_physical_alteration (
    swb_id integer NOT NULL,
    pat_id integer NOT NULL
);


--
-- Name: swb_pressure_swbp_id; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE swb_pressure_swbp_id
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: swb_pressure; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE swb_pressure (
    swbp_id integer DEFAULT nextval('swb_pressure_swbp_id'::regclass) NOT NULL,
    swb_id integer NOT NULL,
    sprs_id integer NOT NULL,
    is_significant boolean NOT NULL,
    last_change_time timestamp without time zone NOT NULL,
    remark text,
    function character varying(250),
    effect text
);


--
-- Name: COLUMN swb_pressure.swbp_id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN swb_pressure.swbp_id IS 'swb_pressure_swpr_id_seq';


--
-- Name: swb_pressure_impact; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE swb_pressure_impact (
    swbp_id integer NOT NULL,
    impact_id integer NOT NULL
);


--
-- Name: wb_prognosis; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE wb_prognosis (
    wbpr_id integer NOT NULL,
    year integer DEFAULT 2021 NOT NULL,
    opt_id integer NOT NULL,
    cls_id integer NOT NULL,
    last_change_time timestamp without time zone NOT NULL,
    swb_id integer NOT NULL
);


--
-- Name: swb_prognosis_swpr_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE swb_prognosis_swpr_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: swb_prognosis_swpr_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE swb_prognosis_swpr_id_seq OWNED BY wb_prognosis.wbpr_id;


--
-- Name: swb_yearly_status_sys_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE swb_yearly_status_sys_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: swb_yearly_status_sys_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE swb_yearly_status_sys_id_seq OWNED BY swb_yearly_status.sys_id;


--
-- Name: system_configuration; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE system_configuration (
    sc_id integer NOT NULL,
    name character varying(255),
    xml_setting text,
    type integer,
    wie character varying(255),
    last_changed_date timestamp without time zone
);


--
-- Name: system_configuration_sc_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE system_configuration_sc_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: system_configuration_sc_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE system_configuration_sc_id_seq OWNED BY system_configuration.sc_id;


--
-- Name: taxa_group_acc; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE taxa_group_acc (
    txg_id integer,
    name character varying(90),
    group_type character varying(1),
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50)
);


--
-- Name: taxa_group_element_acc; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE taxa_group_element_acc (
    txg_id integer,
    txn_id integer
);


--
-- Name: taxa_group_geen_opt; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE taxa_group_geen_opt (
    txg_id integer,
    name character varying(90),
    group_type character varying(1),
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50)
);


--
-- Name: taxa_group_txg_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE taxa_group_txg_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: taxa_group_txg_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE taxa_group_txg_id_seq OWNED BY taxa_group.txg_id;


--
-- Name: taxon_type_txn_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE taxon_type_txn_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: taxon_type_txn_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE taxon_type_txn_id_seq OWNED BY taxon_type.txn_id;


--
-- Name: thema_actie_organisatorische_eenheid_voortgang; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE thema_actie_organisatorische_eenheid_voortgang (
    taov_id integer NOT NULL,
    ta_id integer NOT NULL,
    ore_id integer NOT NULL,
    completed_date timestamp without time zone NOT NULL
);


--
-- Name: thema_actie_organisatorische_eenheid_voortgang_taov_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE thema_actie_organisatorische_eenheid_voortgang_taov_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: thema_actie_organisatorische_eenheid_voortgang_taov_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE thema_actie_organisatorische_eenheid_voortgang_taov_id_seq OWNED BY thema_actie_organisatorische_eenheid_voortgang.taov_id;


--
-- Name: thema_acties; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE thema_acties (
    ta_id integer NOT NULL,
    t_id integer NOT NULL,
    name character varying(200) NOT NULL,
    year integer NOT NULL,
    start_date timestamp without time zone,
    end_date timestamp without time zone NOT NULL,
    comment character varying(1000)
);


--
-- Name: thema_acties_ta_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE thema_acties_ta_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: thema_acties_ta_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE thema_acties_ta_id_seq OWNED BY thema_acties.ta_id;


--
-- Name: thema_overzicht_groep_organisatorische_eenheden; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE thema_overzicht_groep_organisatorische_eenheden (
    tog_id integer NOT NULL,
    ore_id integer NOT NULL
);


--
-- Name: thema_overzicht_groep_river_basin_disrict; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE thema_overzicht_groep_river_basin_disrict (
    tog_id integer NOT NULL,
    rbd_id integer NOT NULL
);


--
-- Name: thema_overzicht_groep_wkpusers; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE thema_overzicht_groep_wkpusers (
    tog_id integer NOT NULL,
    wkpuserid integer NOT NULL
);


--
-- Name: thema_overzicht_groepen; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE thema_overzicht_groepen (
    tog_id integer NOT NULL,
    name character varying(50) NOT NULL,
    comment character varying(1000)
);


--
-- Name: thema_overzicht_groepen_tog_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE thema_overzicht_groepen_tog_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: thema_overzicht_groepen_tog_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE thema_overzicht_groepen_tog_id_seq OWNED BY thema_overzicht_groepen.tog_id;


--
-- Name: thema_overzicht_statussen; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE thema_overzicht_statussen (
    tos_id integer NOT NULL,
    t_id integer NOT NULL,
    name character varying(50) NOT NULL,
    start_range double precision NOT NULL,
    end_range double precision NOT NULL,
    comment character varying(1000)
);


--
-- Name: thema_overzicht_statussen_tos_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE thema_overzicht_statussen_tos_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: thema_overzicht_statussen_tos_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE thema_overzicht_statussen_tos_id_seq OWNED BY thema_overzicht_statussen.tos_id;


--
-- Name: themas; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE themas (
    t_id integer NOT NULL,
    name character varying(50) NOT NULL,
    comment character varying(1000)
);


--
-- Name: themas_t_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE themas_t_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: themas_t_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE themas_t_id_seq OWNED BY themas.t_id;


--
-- Name: transformation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE transformation (
    transformationid integer NOT NULL,
    name character varying(50) NOT NULL,
    domaintablename character varying(50),
    importruleid integer,
    importruleasimportid integer,
    inputorder integer
);


--
-- Name: transformation_transformationid_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE transformation_transformationid_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: transformation_transformationid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE transformation_transformationid_seq OWNED BY transformation.transformationid;


--
-- Name: valid_column_uom; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE valid_column_uom (
    vcu_id integer NOT NULL,
    table_name character varying(50) NOT NULL,
    column_name character varying(50) NOT NULL,
    uom_id integer NOT NULL,
    begin_lifespan timestamp without time zone NOT NULL,
    end_lifespan timestamp without time zone,
    last_change_time timestamp without time zone NOT NULL
);


--
-- Name: validation; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE validation (
    validationid integer NOT NULL,
    name character varying(50) NOT NULL,
    xsd character varying(50) NOT NULL
);


--
-- Name: validation_importtype; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE validation_importtype (
    validation_importtypeid integer NOT NULL,
    importtypeid integer NOT NULL,
    validationid integer NOT NULL
);


--
-- Name: validation_importtype_validation_importtypeid_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE validation_importtype_validation_importtypeid_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: validation_importtype_validation_importtypeid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE validation_importtype_validation_importtypeid_seq OWNED BY validation_importtype.validation_importtypeid;


--
-- Name: validation_validationid_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE validation_validationid_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: validation_validationid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE validation_validationid_seq OWNED BY validation.validationid;


--
-- Name: volumestroom_type; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE volumestroom_type (
    vst_id integer NOT NULL,
    code character varying(12) NOT NULL,
    omschrijving character varying(90) NOT NULL,
    d_begin timestamp without time zone,
    d_eind timestamp without time zone,
    last_changed_date timestamp without time zone,
    d_status character varying(50) DEFAULT 'Gepubliceerd'::character varying
);


--
-- Name: volumestroom_type_bronnen; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE volumestroom_type_bronnen (
    vtb_id integer NOT NULL,
    bronnen_id integer NOT NULL,
    vst_id integer NOT NULL,
    waarde numeric
);


--
-- Name: volumestroom_type_bronnen_vtb_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE volumestroom_type_bronnen_vtb_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: volumestroom_type_bronnen_vtb_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE volumestroom_type_bronnen_vtb_id_seq OWNED BY volumestroom_type_bronnen.vtb_id;


--
-- Name: volumestroom_type_vst_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE volumestroom_type_vst_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: volumestroom_type_vst_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE volumestroom_type_vst_id_seq OWNED BY volumestroom_type.vst_id;


--
-- Name: vw_achtergrondwaarden_gwl; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW vw_achtergrondwaarden_gwl AS
 SELECT natural_background_levels.nbl_id AS "DB_ID",
    hdo_gwb.hdo_id AS "Grondwaterlichaam_DB_ID",
    hdo_gwb.inspire_id_local_id AS "Grondwaterlichaam_Identificatie",
    hdon_gwb.name AS "Grondwaterlichaam_Omschrijving",
    vw_waargenomen_eigenschap."Grootheid_Code",
    vw_waargenomen_eigenschap."Grootheid_Omschrijving",
    vw_waargenomen_eigenschap."ChemischeStof_code",
    vw_waargenomen_eigenschap."ChemischeStof_Omschrijving",
    natural_background_levels.priority AS "PrioritaireStof_JN",
    vw_waargenomen_eigenschap."Hoedanigheid_Code",
    vw_waargenomen_eigenschap."Hoedanigheid_Omschrijving",
    natural_background_levels.concentration_value AS "Achtergrondwaarde",
    eenheid_type.code AS "Eenheid_Code",
    eenheid_type.omschrijving AS "Eenheid_Omschrijving"
   FROM ((((natural_background_levels
     LEFT JOIN hydro_object hdo_gwb ON ((hdo_gwb.hdo_id = natural_background_levels.gwb_id)))
     LEFT JOIN hdo_names hdon_gwb ON ((hdo_gwb.hdo_id = hdon_gwb.hdo_id)))
     LEFT JOIN vw_waargenomen_eigenschap ON ((vw_waargenomen_eigenschap."DB_ID" = natural_background_levels.opt_id)))
     LEFT JOIN eenheid_type ON ((eenheid_type.eenh_id = natural_background_levels.concentration_uom_id)))
  ORDER BY hdo_gwb.inspire_id_local_id, vw_waargenomen_eigenschap."ChemischeStof_code";


--
-- Name: vw_am_inspire; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW vw_am_inspire AS
 SELECT DISTINCT ON (hydro_object.inspire_id_namespace, hydro_object.inspire_id_local_id, hydro_object.wkrv_id) ((((('NL.WBHCODE.'::text || hydro_object.inspire_id_namespace) || '.'::text) || (hydro_object.inspire_id_local_id)::text) || '.'::text) || hydro_object.wkrv_id) AS inspireid,
    ('NL.WBHCODE.'::text || hydro_object.inspire_id_namespace) AS inspireid_namespace,
    hydro_object.inspire_id_local_id AS inspireid_localid,
    hydro_object.wkrv_id AS inspireid_version,
    hydro_object.inspire_id_local_id AS thematic_id,
    'WFD_EU_Code'::text AS thematic_id_identifierscheme,
    hdo_names.name AS name_text,
    hdo_names.language AS name_language,
    'http://inspire.ec.europa.eu/codelist/NativenessValue/endonym'::text AS name_nativeness,
    'http://inspire.ec.europa.eu/codelist/NameStatusValue/official'::text AS name_namestatus,
        CASE
            WHEN (hydro_object.inspire_id_namespace > 99) THEN namespace_type.descrption
            WHEN (hydro_object.inspire_id_namespace = 99) THEN 'Ministerie van Infrastructuur en Millieu'::character varying
            ELSE organisatorische_eenheid.naam
        END AS name_sourceofname,
    mrz.geometry_etrs89 AS st_transform,
    geometrytype(mrz.geometry_etrs89) AS geometry_type,
    ((((('DP'::text || (hydro_object.inspire_id_namespace)::text) || '.'::text) || (hydro_object.inspire_id_local_id)::text) || '.'::text) || (hydro_object.wkrv_id)::text) AS designation_id,
    mrz.begin_designation,
    mrz.end_designation,
        CASE
            WHEN (mrz.end_designation IS NULL) THEN 'after'::text
            ELSE NULL::text
        END AS indeterminate_end_designation,
        CASE
            WHEN ((hydro_object.hydro_object_type)::text = 'RiverBasinDistrict'::text) THEN 'http://inspire.ec.europa.eu/codelist/ZoneTypeCode/riverBasinDistrict'::text
            ELSE 'http://inspire.ec.europa.eu/codelist/ZoneTypeCode/waterBodyForWFD'::text
        END AS zonetype,
        CASE
            WHEN ((hydro_object.hydro_object_type)::text = 'RiverBasinDistrict'::text) THEN NULL::character varying
            ELSE hydro_object.hydro_object_type
        END AS specialisedzonetype,
    'http://inspire.ec.europa.eu/codelist/EnvironmentalDomain/water'::text AS environmentaldomain,
        CASE
            WHEN (hydro_object.inspire_id_namespace > 99) THEN namespace_type.descrption
            WHEN (hydro_object.inspire_id_namespace = 99) THEN 'Ministerie van Infrastructuur en Millieu'::character varying
            ELSE organisatorische_eenheid.naam
        END AS competentauthority_organisationname,
    'http://inspire.ec.europa.eu/codelist/RelatedPartyRoleValue/authority'::text AS competentauthority_role,
    wkr_version.begin_lifespan_version AS beginlifespanversion,
    wkr_version.end_lifespan_version AS endlifespanversion,
    ((((('LB'::text || (hydro_object.inspire_id_namespace)::text) || '.'::text) || (hydro_object.inspire_id_local_id)::text) || '.'::text) || (hydro_object.wkrv_id)::text) AS legalbasis_id,
    'Directive 2000/60/EC of the European Parliament and of the Council establishing a framework for the Community action in the field of water policy'::text AS legalbasis_name,
    'Water Framework Directive'::text AS legalbasis_shortname,
    '2000-10-23'::text AS legalbasis_date,
    'http://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32000L0060:EN:NOT'::text AS legalbasis_link,
    '2000/60/EC'::text AS legalbasis_identificationnumber,
    'European'::text AS legalbasis_level
   FROM (((((((management_regulation_or_restriction_zone mrz
     LEFT JOIN river_basin_disrict ON ((mrz.mrz_id = river_basin_disrict.rbd_id)))
     JOIN hydro_object ON ((hydro_object.hdo_id = mrz.mrz_id)))
     LEFT JOIN hdo_names ON ((hdo_names.hdo_id = mrz.mrz_id)))
     JOIN wkr_version ON ((wkr_version.wkrv_id = hydro_object.wkrv_id)))
     JOIN namespace_type ON ((namespace_type.ns_id = hydro_object.inspire_id_namespace)))
     LEFT JOIN competentauthority_namespacetype ON ((namespace_type.ns_id = competentauthority_namespacetype.ns_id)))
     LEFT JOIN organisatorische_eenheid ON ((organisatorische_eenheid.ore_id = competentauthority_namespacetype.ore_id)))
  WHERE (((river_basin_disrict.international_rbd IS NOT NULL) OR ((hydro_object.hydro_object_type)::text = ANY (ARRAY[('GroundWaterBody'::character varying)::text, ('SurfaceWaterBody'::character varying)::text]))) AND (hydro_object.wkrv_id = 4))
  ORDER BY hydro_object.inspire_id_namespace, hydro_object.inspire_id_local_id, hydro_object.wkrv_id DESC;


--
-- Name: vw_belastingen_gwl; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW vw_belastingen_gwl AS
 SELECT gwb_pressure.gwbp_id AS "DB_ID",
    vw_waterlichamen.db_id AS "Grondwaterlichaam_DB_ID",
    vw_waterlichamen.identificatie AS "Grondwaterlichaam_Identificatie",
    gw_pressure_type.description AS "Type",
    pressure_category_type.omschrijving AS "Categorie",
    gwb_pressure.is_significant AS "SignificantJN",
    pressure_relevance_type.omschrijving AS "Urgentie",
    drivers.naam AS "Functie",
    gwb_pressure.effect AS "Effecten",
    gwb_pressure.remark AS "Opmerking"
   FROM vw_waterlichamen,
    gwb_pressure,
    gw_pressure_type,
    pressure_category_type,
    pressure_relevance_type,
    gw_pressure_type_driver,
    domains.drivers
  WHERE ((vw_waterlichamen.db_id = gwb_pressure.gwb_id) AND (gw_pressure_type.gprs_id = gwb_pressure.gprs_id) AND (pressure_category_type.pcat_id = gw_pressure_type.pressure_category_id) AND (gwb_pressure.prr_id = pressure_relevance_type.prr_id) AND (gw_pressure_type.gprs_id = gw_pressure_type_driver.gprs_id) AND (gw_pressure_type_driver.driver_id = drivers.driver_id));


--
-- Name: vw_belastingen_gwl_csv; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW vw_belastingen_gwl_csv AS
 SELECT vw_grondwaterlichamen.identificatie AS "Grondwaterlichaam.Identificatie",
    vw_grondwaterlichamen.versie,
    gw_pressure_type.description AS "BelastingSoort",
    pressure_category_type.omschrijving AS "BelastingCategorie",
    gwb_pressure.is_significant AS "SignificantJN",
    pressure_relevance_type.omschrijving AS "Urgentie",
    gwb_pressure.function AS "Functie",
    gwb_pressure.effect AS "Effecten",
    gwb_pressure.remark AS "Opmerking"
   FROM vw_grondwaterlichamen,
    gwb_pressure,
    gw_pressure_type,
    pressure_category_type,
    pressure_relevance_type
  WHERE ((vw_grondwaterlichamen.db_id = gwb_pressure.gwb_id) AND (gw_pressure_type.gprs_id = gwb_pressure.gprs_id) AND (pressure_category_type.pcat_id = gw_pressure_type.pressure_category_id) AND (gwb_pressure.prr_id = pressure_relevance_type.prr_id));


--
