Added querying and database construct