Could you clarify something? When comparing two forms of link notation for referential integrity, for example in a many-to-many relationship, the export to Postgres looks identical.
// for inline form
Table base1 {
id integer [pk]
}
Table child1 {
id integer [pk, ref: > base1.id]
}
// for short from
Table base2 {
id integer [pk]
}
Table child2 {
id integer [pk]
}
ref: child2.id > base2.id
CREATE TABLE "base1" (
"id" integer PRIMARY KEY
);
CREATE TABLE "child1" (
"id" integer PRIMARY KEY
);
CREATE TABLE "base2" (
"id" integer PRIMARY KEY
);
CREATE TABLE "child2" (
"id" integer PRIMARY KEY
);
ALTER TABLE "child1" ADD FOREIGN KEY ("id") REFERENCES "base1" ("id");
ALTER TABLE "child2" ADD FOREIGN KEY ("id") REFERENCES "base2" ("id");
However, if the same is done for a one-to-one relationship, the dependency swaps places.
// for inline form
Table base1 {
id integer [pk]
}
Table child1 {
id integer [pk, ref: - base1.id]
}
// for short from
Table base2 {
id integer [pk]
}
Table child2 {
id integer [pk]
}
ref: child2.id - base2.id
CREATE TABLE "base1" (
"id" integer PRIMARY KEY
);
CREATE TABLE "child1" (
"id" integer PRIMARY KEY
);
CREATE TABLE "base2" (
"id" integer PRIMARY KEY
);
CREATE TABLE "child2" (
"id" integer PRIMARY KEY
);
ALTER TABLE "child1" ADD FOREIGN KEY ("id") REFERENCES "base1" ("id");
ALTER TABLE "base2" ADD FOREIGN KEY ("id") REFERENCES "child2" ("id");
Is this correct?