Implements DatabaseJoinOrCreate, a handy helper that can create related objects before updating foreign keys.