AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Search the table

Week 17 · Unit 7: Be a data boss · 3 lessons
2

Searching with two rules

Computing 4: Unit 7, pp. 90–103
GoalAnswer questions that need two rules or a comparison of numbers.
New words
condition · a rule that a record must match to be in the answermore than · bigger than: 5 is more than 3 but 3 is not more than 3less than · smaller than: 2 is less than 3 but 3 is not less than 3
Explanation

Some questions have two conditions. First find the records that match the first condition. Then look only at those records and keep the ones that also match the second condition. With a number field you can ask “more than” or “less than”. Take care at the edges: “younger than 3” means ages 0, 1 and 2, but not 3. Always say which field you read to give the answer. When you have found the answer, read through the whole table once more to check that you did not miss a record.

NameAnimalAgeVaccinatedRoom
Belladog3YesA
Maxcat1NoB
Cocorabbit2YesB
Rexdog5YesA
Lunacat4YesC
Tikorabbit1NoC
Worked examples
NameAnimalVaccinated
BelladogYes
RexdogYes
Question: Which dogs are vaccinated? Step 1: keep only the records with Animal = dog. Step 2: of these, keep the records with Vaccinated = Yes. Both dogs are vaccinated, so the answer is Bella and Rex.
NameAgeLess than 3?
Bella3no
Max1yes
Coco2yes
Rex5no
Luna4no
Tiko1yes
Question: Which animals are younger than 3 years? We test every record in the Age field. 3 is not less than 3, so Bella is not in the answer. The answer is Max, Coco and Tiko.
Question: Which rabbits are in Room A? Step 1 finds Coco and Tiko. Step 2 keeps the ones in Room A, and neither is there. The answer is none.
Class activity

Two-rule hunt (in pairs): draw a table of six pets or toys with four fields, including one number field. Write four questions that need two rules, for example “Which toys are red and cost more than 5?”. Swap tables with your partner and answer each other’s questions. To check an answer, cross out every record that does not match the first rule, then the second rule. What is left is the answer.

Practice
1
Use the pet-shelter table. Which animals are in Room C and are not vaccinated?
2
Which plants in Bed 1 need sun? Which plants are taller than 30 cm? Take care at the edge.
PlantHeight (cm)Needs sunBed
Tomato60Yes1
Mint25No2
Bean45Yes2
Fern30No1
Sunflower150Yes1
Lettuce20Yes2
3
How many story books have more than 60 pages? Which two fields did you use?
TitleTypePagesOn shelf
Moon Gardenstory48Yes
Bridgesfacts64No
Rain Songstory120Yes
Beesfacts32Yes
Night Trainstory96No
4
Use the pet-shelter table. Write a question that has the answer “Coco” and needs two fields.