Add helper function for comparing foreign keys