Refactored db.rb and created files for sql_db