Changing SQL to reflect database model changes