[#33]: Initial SQL refactoring