adding insertion and checking the foreign key