Fix: multiple tables used for foreign keys check