Added SQL queries

Added most of the sql queries to the code and made them go.