making database functions and organizing sql methods