I have a table (tableA) that joins 3 other tables with primary keys 'vehicle','engine','transmission' I would like to be able to assign parts to one or more of these eg 'only this vehicle' or 'only this vehicle with this engine' or 'any vehicle with this engine'
My plan is to have a parts table (tableB) with also primary keys 'vehicle','engine','transmission' and I'd like to be able to insert for example:
4844, null, null
to assign a part to only 'vehicle' or4844, 240, null
to assign a part to 'only this vehicle with this engine'.
Is there some way I can enforce integrity at the database level so that.
- the fields that are filled in in tableB must reference fields in tableA.
- at least one of the fields must be filled in.
- the option exists not to insert data into them all?