DesignDesigning INSERT, UPDATE and DELETE queries

Designing queries and establishing a data dictionary are important. Decisions should be informed by the Data Protection Act. Entities, attributes and relationships should be clearly defined.

Part ofComputing ScienceDatabase design and development

Designing INSERT, UPDATE and DELETE queries

Later, in the Implementation Guide you can read about use of INSERT, UPDATE and DELETE queries. Sometimes it is necessary to design these queries before use. The following brief examples all use the sports centre scenario.

When using these design templates, it is not always necessary to include data in the new/updated values or criteria rows. It depends upon the problem that the query is being designed to resolve.

Designing an INSERT query

Type of queryINSERT
TableSports area
New/updated value(s)AreaID = 17, AreaName = Tennis Court 7, SurfaceID = 2, HireCost = 15, Available = True, Manager = Frankie Kane
Criteria
Type of queryTable
INSERTSports area
Type of queryNew/updated value(s)
INSERTAreaID = 17, AreaName = Tennis Court 7, SurfaceID = 2, HireCost = 15, Available = True, Manager = Frankie Kane
Type of queryCriteria
INSERT

If implemented, this query would insert a new record into the Sports Area table, with the values for each attribute added to reflect those shown above.

Designing an UPDATE query

Type of queryUPDATE
TableSports area
New/updated value(s)Manager = Hannah Brooks
CriteriaAreaID = 17
Type of queryTable
UPDATESports area
Type of queryNew/updated value(s)
UPDATEManager = Hannah Brooks
Type of queryCriteria
UPDATEAreaID = 17

If implemented, this query would update the value of the Manager attribute (field) to become Hannah Brooks if the AreaID attribute (field) holds the value 17.

Designing a DELETE query

Type of queryDELETE
TableSports area
New/updated value(s)
CriteriaManager = Lily McLuskey
Type of queryTable
DELETESports area
Type of queryNew/updated value(s)
DELETE
Type of queryCriteria
DELETEManager = Lily McLuskey

If implemented, this query would delete the name Lily McLuskey from every record containing this name in the Manager field of the Sports Area table.