I have an Oracle database with three tables :
Table1 : Vehicle
- ID
- Type
- Item
Table2 : Car
- ID
- Brand
Table3 : Bus
- ID
- Bus Number
In table 1 :
- if the type of the vehicle is
Car
, I want the columnItem
to store anID
fromCar
table ; - if the type of the vehicle is
Bus
, I want the columnItem
to store anID
fromBus
table ;
This creates a problem when linking the tables with foreign keys constraints, because if, for example, I select a Car ID into Vehicle Table that doesn't exist in Bus Table, Oracle will raise an error.
What I'm doing actually is, I handle the tables without any relationships, but I'm facing the risk of inconsistency of data, in case a row from the tables Bus or Car are deleted.
Does anyone have an idea please ?