Searching and Sorting databases

Searching and sorting a database

  1. Circle one field
  2. Circle one record

Searching and sorting a database

  1. Circle one field
  2. Circle one record

Data types

  • What data type is most suitable for storing a person’s forename?
  • Why would we use text rather than a number to store a mobile phone number such as 07500 100 200?
  • What data type is most suitable for storing a date of birth?
  • What data type should we use to store a car registration number?

Learning Intentions

  • Understand what searching and sorting are and why they are important for databases
  • Understand how to search a database
  • Understand how to sort a database

Success Criteria

  • I can design a search and/or sort query
  • I can explain the benefits of designing a query

What is a database?

  • A database is used when a large amount of information must be stored in some sort of order so that it can be accessed easily and quickly.

  • A database is a structured collection of similar information which you can search through. You can store a database manually or electronically.

Searching and sorting

  • We mentioned the way in which data is stored in a database is a structured collection of information about one topic.
  • Databases are designed to be easily searched and easily sorted.
  • When we are searching, we are trying to find something.
  • When we are sorting, we are putting the database in an order.

Searching a database

  • When we are searching a database, we are trying to find something.
  • This is an important feature of databases, especially as they get bigger and bigger.
  • Thinking about searching databases, what do you think happens when you search Google or Bing?
  • When you perform a search on the web, you are searching a giant database that the search engine holds.

Sorting a database

  • Sorting the database means putting it in a different order.
  • We call the order either ascending or descending.
  • Again, thinking about sorting databases, what do you think happens to the order of the data coming from a Google search?
  • When you perform a search on the web, Google will sort the data coming out in an order which puts the most relevant information first.

Sorting a database

  • Let’s assume we have a collection of information as shown in this graph. We can sort by ascending and descending order. Ascending means going from small to big whereas descending order means going from the biggest number to the smallest.

Searching and Sorting databases

  • Searching and sorting a database involves knowing what fields are needed, what the criteria is and what the sort order is.
  • Assume we have the James Bond Top Trumps database as shown below:
     

Searching and Sorting databases

  • Find everyone who has 100 Strength and sort them their Intelligence (going from small to big). Display the character’s name, strength, agility and intelligence. 

Searching and Sorting databases

  • Find everyone who has more than 30 Agility and sort them the CharacterName (going from Z to A). Display the character’s name, strength, agility and intelligence and a picture. 

Searching and Sorting databases

  • Find everyone who has more than 30 Agility and sort them the CharacterName (going from Z to A). Display the character’s name, strength, agility and intelligence and a picture. 
You can find your task on Google Classroom.
For this task you must open the James Bond characters database and use it to build queries.

Task

JB
4 Databases : 2.1 Search and Sorting databases
© J Balfour
Tools