Reputation: 1570
I have two tables that look like this:
CREATE TABLE "schema"."TableOne" (
"TableOneID" SERIAL PRIMARY KEY,
"TimeRange" TSTZRANGE
);
CREATE TABLE "schema"."TableTwo" (
"TableTwoID" SERIAL PRIMARY KEY,
"TableOneID" INTEGER FOREIGN KEY ("SoulID") REFERENCES "schema"."TableOne" ("TableOneID")
"TimeRange" TSTZRANGE
);
I want to make sure that any value in "TableTwo"."TimeRange"
is contained by the range in "TableOne"."TimeRange"
where "TableOne"."TableOneID" = "TableTwo"."TableOneID"
I have read the documentation (8.17.10. Constraints on Ranges) several times and can't find a way to make this happen... any ideas?
Upvotes: 1
Views: 79
Reputation: 95532
You can't yet do that in PostgreSQL. The pgsql-hackers listserv recommends using serializable transactions to change data, and using triggers to implement the constraints.
Upvotes: 1