Question

I have a parent-child set of tables. The parent table, interaction has columns id and start_time. The child table, meeting, has columns interaction_id and end_time.

I want to add a constraint that the end times of all meetings should be AFTER their respective start times. Can this be achieved in a check constraint with a SELECT statement, or should this be enforced differently (possibly at the application level)?

By the way I'm running the most recent version of SQL Server.

Was it helpful?

Solution

Check Constraints can enforce rules on Table Level but since you are trying to enforce a business rule between two tables you need to Create an Instead of Insert Trigger that fires and check the Records in your parent table that if it satisfies your business rule either case it will insert the date or not.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top