I'm creating a database from an UML diagram. I trying to code a case I never had which is an (optional) one to (optional) one relationship.
I have two tables, let's call them A and B. A can have a reference to B through a 0..1 relationship. The problem is that B is supposed to be referenced by one A object at most.
I'm not sure how I should approach this. Should I put a reference to A in B and a reference to B in a? Should I only put only a reference to B in A (and force the other check in a trigger or in the code)?
If it can help, these links won't created often, and only one by one so there won't be performance issues if checks are done in the code or in triggers. But I'd rather forbid bad data through the database design than only through the code.