add foreign key logic for update and search