How do I create a function constraint for denormalized data?
-- graduation_class table
graduation_class_id | graduation_year_id
123 1
456 2
-- user table
user_id | graduation_class_id | graduation_year_id
555 123 1
556 123 3 <--- bad data
557 456 2
A graduation class can only be assigned to a sign graduation year. The combination of the two is unique in the graduation_class table.
I want to create a function constraint on the graduation_year_id column on the user table to make sure the graduation_year_id is in sync with the proper id from the graduation_class table so that the record 556 in the user table will never happen.
** Please assume normalization is NOT a solution to this, or I wouldn't be asking this question! :) **