I have two tables that model an inheritance relationship. This is expressed by a foreign key constraint on Derived.Id referencing Base.Id. Some columns in Base are essentially duplicated in Derived so they can be referenced in unique constraints and compound foreign keys. I would like to ensure the values for these columns are the same in both tables. Ideally, this would be done with a compound foreign key on Id + the column. But this prevents the values from being changed–it’s a catch-22 scenario.
How could I ensure these columns have the same values in both tables and allow them to be updated? I have complete flexibility, so I can change the tables’ schemas or do whatever else is necessary to make this possible.
I would only keep the columns in one of the tables,
baseif it applies to all objects.Can you give an example of the necessity of duplicating your columns with a concrete example, like base = car, has VIN, derived = myCar, has VIN.
Also, if the duplicated columns are part of the keys, use cascade update.