We have a database structure like the one shown in the (very simplified) diagram below:
As you can see, there is a table Categories, holding data like this:
Id Description
1 Car
2 Truck
The table VehicleParts holds the data that correlates which vehicle has which part.
My question
How can I guarantee that one row in the VehicleParts table does not reference a Version of a Car and a Part of a Truck or vice versa?

CarandTruckare just example data of the table Categories. As they are only1 to Nrelationship, they can have 0 Models, 0 Versions, 0 Sets and 0 Parts; i.e. if the user add a new row on the categories table, "Motorcycles". – Guilherme Jul 07 '17 at 06:11CategoryIDto Versions, Parts and VehicleParts and modify Forein Key and Unique constraints appropriately. – ypercubeᵀᴹ Jul 07 '17 at 06:26CategoryID). There is redundnancy but you can't avoid it, if you want to enforce this kind of constraint. The other way would be to use triggers or restrict access to stored procedures (for INSERT/DELETE/UPDATE in the related tables) that take care / enforce it. – ypercubeᵀᴹ Jul 07 '17 at 06:37