how set up a database table and query it