Quantcast
Channel: Active questions tagged referential-integrity - Database Administrators Stack Exchange
Viewing all articles
Browse latest Browse all 60

Create Constraint To Ensure Date Range Is Within Another Date Range

$
0
0

I am trying to create a scheduling application, and part of it requires the date range of a row to be within the date range of a row in another table, which it is referencing via a foreign key.

Note: This is Postgres.

The schema is as follows:

table_1:id Serialname Varchardate_range DATERANGE
table_2:id Serialname Varchardate_range DATERANGEtable_1_id - Foreign Key, this references the id of a record in table 1.

I am trying to figure out how to write a check constraint that enforces the rule that the date_range in table_2 has to be within the date_range of table_1.


Viewing all articles
Browse latest Browse all 60

Trending Articles