sql model refactoring.