Add group_foreign_keys function