preliminary sql queries