Fixed the foreign key constraint error and a typo inside insertPosition()