Fix self association issues in bake

This fixes 2 of the 3 issues in #4440. I'll make a separate issue for the foreign key constraints, as I feel it is worth discussing the interface before writing code.