定义强度关系 pgadmin 4

问题描述 投票:0回答:1

我正在开发一个在表之间具有不同类型关系的数据库:1:M 和 M:N。我已经在 PG Admin 4 中通过外键定义了关系。

当我在QGIS中打开模型时,我只得到关联类型关系,但对于中间表(M:N关系,红色矩形)我需要组合强度关系。

relations and strenght relation type

知道如何在 PG Admin 4 中定义强度关系吗?

谢谢大家

这是其中之一的 SQL 代码示例:

#创建表Arret

DROP TABLE IF EXISTS sdt_transports.arret;

CREATE TABLE IF NOT EXISTS sdt_transports.arret
(
    objectid_arret integer NOT NULL DEFAULT nextval('sdt_transports.arret_objectid_arret_seq'::regclass),
    id_arret integer,
    nom_arret character varying(50) COLLATE pg_catalog."default",
    ref_etat_exploitation integer,
    abreviation_arret character varying(10) COLLATE pg_catalog."default",
    arret_regional smallint,
    arret_urbain smallint,
    sens_alle smallint,
    sens_retour smallint,
    url_horaire_passage character varying(255) COLLATE pg_catalog."default",
    url_horaire_passage_exception smallint,
    url_horaire_origine character varying(255) COLLATE pg_catalog."default",
    url_horaire_origine_exception smallint,
    url_horaire_destination character varying(255) COLLATE pg_catalog."default",
    url_horaire_destination_exception smallint,
    url_information character varying(255) COLLATE pg_catalog."default",
    url_information_exception smallint,
    niveau_equipement character varying(50) COLLATE pg_catalog."default",
    rem_equipement character varying(250) COLLATE pg_catalog."default",
    niveau_offre smallint,
    pers_montante smallint,
    pers_descente smallint,
    url_statistique character varying(255) COLLATE pg_catalog."default",
    url_statistique_exception smallint,
    no_localite smallint,
    commentaires character varying(250) COLLATE pg_catalog."default",
    niveau_service character varying(50) COLLATE pg_catalog."default",
    user_mise_a_jour character varying(255) COLLATE pg_catalog."default",
    date_mise_a_jour timestamp without time zone,
    x double precision,
    y double precision,
    geom geometry,
    CONSTRAINT arret_pkey PRIMARY KEY (objectid_arret)
)
WITH (
    OIDS = FALSE
);

#创建表格干部Horaire

DROP TABLE IF EXISTS sdt_transports.cadre_horaire;

CREATE TABLE IF NOT EXISTS sdt_transports.cadre_horaire
(
    objectid_cadre_horaire integer NOT NULL DEFAULT nextval('sdt_transports.cadre_horaire_objectid_cadre_horaire_seq'::regclass),
    id_cadre_horaire character varying(30) COLLATE pg_catalog."default",
    nom_cadre_horaire character varying(150) COLLATE pg_catalog."default",
    url_cadre_horaire character varying(255) COLLATE pg_catalog."default",
    url_cadre_horaire_exception smallint,
    commentaires character varying(250) COLLATE pg_catalog."default",
    user_mise_a_jour character varying(255) COLLATE pg_catalog."default",
    date_mise_a_jour timestamp without time zone,
    CONSTRAINT cadre_horaire_pkey PRIMARY KEY (objectid_cadre_horaire)
)
WITH (
    OIDS = FALSE

#创建Arret和Cadre Horaire之间的中间表

DROP TABLE IF EXISTS sdt_transports.link_arret_cadre_horaire;

CREATE TABLE IF NOT EXISTS sdt_transports.link_arret_cadre_horaire
(
    objectid_link_arret_cadre_horaire integer NOT NULL DEFAULT nextval('sdt_transports.link_arret_cadre_horaire_objectid_link_arret_cadre_horaire_seq'::regclass),
    objectid_arret integer,
    objectid_cadre_horaire integer,
    user_mise_a_jour character varying(255) COLLATE pg_catalog."default",
    date_mise_a_jour timestamp without time zone,
    CONSTRAINT link_arret_cadre_horaire_pkey PRIMARY KEY (objectid_link_arret_cadre_horaire)
)
WITH (
    OIDS = FALSE
);

#通过外键创建关系

ALTER TABLE IF EXISTS sdt_transports.link_arret_cadre_horaire
    ADD FOREIGN KEY (objectid_arret)
    REFERENCES sdt_transports.arret (objectid_arret) MATCH SIMPLE
    ON UPDATE NO ACTION
    ON DELETE NO ACTION
    NOT VALID;


ALTER TABLE IF EXISTS sdt_transports.link_arret_cadre_horaire
    ADD FOREIGN KEY (objectid_cadre_horaire)
    REFERENCES sdt_transports.cadre_horaire (objectid_cadre_horaire) MATCH SIMPLE
    ON UPDATE NO ACTION
    ON DELETE NO ACTION
    NOT VALID;
foreign-keys relationship postgis qgis pgadmin-4
1个回答
0
投票

doc 说:

关系强度决定了双方之间关系的强度 父层和子层。 default Association 类型意味着 父层简单地链接到子层,而 Composition 类型允许您在以下情况下复制子特征: 复制父项并在删除子项时 也被删除,导致所有级别的级联(意味着儿童 …的孩子也被删除)。

数据库端没有这样的设置来传播重复,因此无法检索它,只能推断默认的“关联”。

我们可以在代码中确认:Postgres(也不是Spatialite)中不会读取关系强度,因此使用默认的“关联”。

© www.soinside.com 2019 - 2024. All rights reserved.