成人快手

Query design

It is important to take time to design any queries that may need to be implemented later.

Query design does not need to include specific SQL (Structured Query Language) commands. SQL will only be used during implementation.

At the design stage at Higher level, it is necessary to state the following:

  • fields
  • tables
  • search criteria
  • sort order
  • calculations
  • grouping

Short hand can be used for the terms Ascending (ASC) and Descending (DESC).

Sports centre example

Example 1 - Availability query

Here is the design for a query that should return all sports areas that are available for use.

The areas' names should be listed in ascending order.

The query should return:

  • area name
  • whether it is available
  • the name of the manager responsible for that area

Query Design: List of Sports Areas by name in ascending order

Field(s)Area Name, Available, Manager
Table(s)Sports area
CriteriaAvailable = 鈥淭rue鈥
Sort OrderArea Name ASC
Field(s)
Area Name, Available, Manager
Table(s)
Sports area
Criteria
Available = 鈥淭rue鈥
Sort Order
Area Name ASC

Example 2 - Surface supplier query

Here is the design for a query that will return all sports areas where the surface used is grass and the supplier is the company called 'WeLay'.

The areas' IDs should be listed in descending order.

The query will list:

  • area ID
  • area name
  • surface type
  • supplier of the surface

Query Design:

Field(s)AreaID, AreaName, SurfaceType, Supplier
Table(s)Surface, Sports Area
CriteriaSurface Type = 鈥淕rass鈥 AND supplier = 鈥淲eLay鈥
Sort OrderAreaID DESC
Field(s)
AreaID, AreaName, SurfaceType, Supplier
Table(s)
Surface, Sports Area
Criteria
Surface Type = 鈥淕rass鈥 AND supplier = 鈥淲eLay鈥
Sort Order
AreaID DESC

Example 3 - Calculate cost to hire sports area query

Here is the design for a query that will return all sports areas with a HireCost less than 拢50 and which are available to hire. For this example, let鈥檚 assume that the person hiring can spend 拢50.

The hire cost should be listed in descending order.

The query will list:

  • area ID
  • area name
  • surface type
  • hire cost
  • whether it is availble

Query Design:

Field(s)AreaID, AreaName, SurfaceType, HireCost, Available
Table(s)Surface, Sports Area
CriteriaHireCost less than/equal to 50 AND Available= 鈥淭rue鈥
Sort OrderHireCost DESC
Field(s)
AreaID, AreaName, SurfaceType, HireCost, Available
Table(s)
Surface, Sports Area
Criteria
HireCost less than/equal to 50 AND Available= 鈥淭rue鈥
Sort Order
HireCost DESC