Added foreign keys to joined classes and to related __init__ functions