Searching and sorting
Databases - Lesson 2
Objectives
- To search a database for information
- To understand and explain fields and records in a database.
Lesson Resources
Lesson 1 - Understanding databases
Lesson 2 - Searching and sorting
Lesson 3 - Searching and charting
Lesson 4 - A class database
Lessons 5 & 6 - A team database
Introduction
Begin by recapping the previous lesson. Ask the students:
- What is a database?
- Why are databases useful?
- Where might you find a database being used?
- What sort of data might be in our school pupil database?
Introduce the lesson objectives at this point. Most of the lesson is focused on different ways to search existing databases, as well as learning the key terms of field and record. We will be moving on from branching databases to look at other, more common, layouts.
Parts of a database
Today we are going to look at other ways a database can be arranged. Try the interactive guide at BBC Bitesize to find out what these terms mean:
- Record - A set of data in a number of categories for one person, item, place etc
- Field - Each single piece of data in a database.
- Title
- Search
Take a look at the database in the example on BBC Bitesize(opens in new tab). It shows the organisation of toys in someone's bedroom, in the format of a table.

Ask the class - How is this layout different to the branching databases?
The table layout makes it easy to see a lot of information at once. Ask the class to answer the following questions, each time emphasising the vocabulary for record and field. For example, "Yes, we can see the answer in the location field of Bob's record"
- What is Bob’s location in the bedroom?
- What type of creature is Burt?
- Which toy is orange?
- What is the name of the Monster toy?
- Which toys live on the toy shelf?
Working with data
Take a look at this video(opens in new tab) from BBC Bitesize to find out more about how and why people work with data.
Emphasise that the whole point of a database is making data easy to use.
We can:
- Search it - Look for specific information
- Sort it - Put it into an order
- Group it - Put matching things together
- Filter it - Hide information we don’t need
Let’s take a look at a pre-made database ourselves. In Purple Mash go to Tools > 2Investigate.

Open the Examples,

Databases with data,

Card Mode,

The Minibeasts example.

Show the class how the contents of this database can be viewed as cards, each card is a record. How many cards are in this database?


You can also switch to the table view - How is this view different? Which is most useful? Why?


Sorting a database
Back in card mode, demonstrate how we can sort the database and put the records into an order of our choosing.
Choose sort at the top of the screen.

Choose the category to sort by.

Choose up (smallest to biggest/a-z) or down (biggest to smallest/ z-a).

Watch as the cards are sorted for you.

Show how this can also be done in table mode.

Grouping
Next, let's ask the computer to group the cards. Ask the class - What is the difference between sorting and grouping things?
Can you give me an example using the children in our class?
We could sort the children in the class by height, putting them in order. Or we could group them by eye colour, putting those with the same coloured eyes together.
Demonstrate grouping the minibeasts by habitat.
Choose Group.

Choose the category to group by.

Watch as the cards are put into groups for you.

Filtering
Finally, explain and demonstrate filtering. Filtering is about removing unnecessary data to make it easier to focus on the parts that you do want.
Choose Filter

Choose the category to filter by and how you wish to filter. There are a variety of options depending on the data, such as equals a specific value, greater than, less than, contains (key word or letter) etc. You can also add more than one filter at a time to further narrow down a search. For example, a minibeast where habitat contains the word flowers and legs equal 6.

The data will immediately be filtered in card or table view.

Clearing your searches and filters
If you have an active sort, filter, group or calculation, you will see a red notification on that button. Remember to clear these before your next search or you will not be searching the full data set on your next search/filter.

Main task
Ask the class to open another of the sample databases. Select Examples > Database with data > Table Mode > Animals.
This database cannot be viewed in Card mode.
Ask:
- What information can you see in this database?
- How many categories does it show for each record?
Point out that there are 117 records in this database and that the data is spread over five pages.
Introduce their task and the worksheet they will complete.
The local zoo have been in touch to ask for your help. Use the database to answer their questions and help them keep the zoo running smoothly.
Give each child a copy of the Zoo Data Detectives sheet(opens in new tab), or pair up any children that might benefit from support. Each question will ask them to search the database in different ways, making use of sorting, grouping and filtering. Hints for the best method are provided on each question.

Answers are provided in the teacher slides, for you to review with the class at the end.
To finish
Review the lesson and the understanding of the children against the objectives.
- What is a database?
- What is a record in a database?
- What is a field in a database?
- Give an example of when you sorted the data.
- Give an example of when you grouped the data.
- Give an example of when you filtered the data.
