Attempting to work out the database/query relationship.