I'm trying to create a constraint in java DB. I have two tables: task and subtask. These tables have 1:m relationship (task 1:m subtask). The constraint need to check that the start_date in subtask is not earlier than the start date in the task table. Not sure, how this can be done. My code:
ALTER TABLE subtask
ADD CONSTRAINT c1 CHECK(
s.start_date >= (SELECT t.start_date
FROM task t, subtask s
WHERE t.start_date = s.start_date)
)
This gives me error:
'subquery' may not appear in a CHECK CONSTRAINT definition because it may return non-deterministic results.
How can I express the constraint in SQL? Any help is appreciated.