I think I finally got the foreign keys working properly.