Database Queries

Teach any GCSE Computer Science class

We have put together a full GCSE Computer Science curriculum that will give you all the teaching materials you need to teach any topic.

Whether you’re a brand new Computer Science teacher, or you’ve been teaching ICT for years, our resources will save you hours and hours of lesson preparation every single week.

View the resources →

A query is a way of requesting information from the database. A database query can be either a select query or an action query. A select query is a query for retrieving data, while an action query requests additional actions to be performed on the data, like deletion, insertion, and updating.

For example, a manager can perform a query to select the employees who were hired 5 months ago. The results could be the basis for creating performance evaluations.

Methods for Creating Queries

Selecting Parameters from a Menu

  • In this method, the database system displays a list of parameters for you to choose from. This is the simplest way to create a query because there are menus that guide you, but it is also the least flexible.

Query by Example (QBE)

  • In this method, the system displays a blank record and lets you identify the fields and values that define the query.
  • This is a method of query creation that authorises the user to look for documents based on an example in the form of a selected text string, or in the form of a document name, or even a list of documents. Because the QBE system develops the actual query, QBE is easier to grasp than formal query languages, while still enabling powerful searches.
  • In terms of database management systems, QBE can be considered a ‘fill-in-the-blanks’ method of query creation. An example of QBE is the Microsoft Access Query Design Grid. The user inputs criteria into the form to create search conditions for as many fields as desired, in order to perform a search. A query is then automatically created to search the database for corresponding data.

Query Language

Many database systems expect you to make requests for information through a stylised query written in a specific query language. This is the most complicated method because it compels you to learn a specific language, but it is also the most flexible.
Query languages are used to create queries in a database.

Examples of Query Languages

Microsoft Structured Query Language (SQL) is the ideal query language. Other expansions of the language under the SQL query umbrella include:

  • MySQL
  • Oracle SQL
  • NuoDB

Query languages for other types of databases, such as NoSQL databases and graph databases, include the following:

  • Cassandra Query Language (CQL)
  • Neo4j’s Cypher
  • Data Mining Extensions (DMX)
  • XQuery

Power of Queries

A database has the possibility to uncover intricate movements and actions, but this power is only utilised through the use of query. A complex database contains multiple tables storing countless amounts of data. A query lets you filter it into a single table, so you can analyse it much more easily.

Queries also can execute calculations on your data, summarise your data for you, and even automate data management tasks. You can also evaluate updates to your data prior to committing them to the database, for still more versatility of usage.

Queries can perform a number of various tasks. Mainly, queries are used to search through data by filtering specific criteria. Other queries contain append, crosstab, delete, make table, parameter, totals, and update tools, each of which performs a specific function. For example, a parameter query executes the distinctions of a specific query, which triggers a user to enter a field value, and then it makes use of that value to make the criteria. In comparison, totals queries let users organise and summarise data.

In a relational database, which is composed of records or rows of data, the SQL SELECT statement query lets the user select data and deliver it to an application from the database. The resulting query is saved in a result-table, which is referred to as the result-set. The SELECT statement can be divided into other specific statements, like FROM, ORDER BY and WHERE. The SQL SELECT query can also group and combine data, which could be useful for creating analyses or summaries.