generating tables for foreign keys