associating models with tables and primary keys