I have 2 tables, referenced through a FK.
users table (id as PK)
cars table (id as PK, userId as FK to users, unique relationship id-userId)
On a third table, I want to record some data from cars.but in case a car is not yet registered, the carId is null.
question: when I update the third table, how can I make sure the car belongs to that user? if I use a trigger on insert for validation, how to make sure the data remains consistent when the cars table is updated?
I add a diagram, to be more explicit.