One question, three tools
A teacher asks: "Which Year 9B pupils are in chess club?" The pupil list could be a table, a pile of documents or a spreadsheet.
Each store has its own search tool. Choosing the right one saves time.
Key words
| Word | What it means |
|---|---|
| SQL | the language used to search tables in a relational database |
| NoSQL | tools that search non-relational stores |
| Macro | a saved set of steps that runs on its own |
| Document | one record with its own fields |
| Query tool | software you use to search data |
| Relational database | tables linked by values they share |
The cells students fill in are left blank in this preview.
By the end of this lesson
Note
I can match SQL, NoSQL and macros to the data they query.
Starter
Have a go
Starter
3 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.
SQL searches relational tables
SQL searches the tables of a relational database. You say which columns, from which table, where the condition is true.
It is the right tool when data sits in tables with fixed columns.
Try it: the question in SQL
select name
from pupils
where form = '9B' and club = 'chess';
-- Try it: change chess to choir. What comes back?
NoSQL searches other kinds of store
NoSQL tools search non-relational stores, such as a collection of documents. The query describes the fields a document must have.
The tool depends on the store. One document store may take a query like {form: "9B", club: "chess"}.
Try it: the same question on documents
docs = [
{"name": "Sam", "form": "9B", "club": "chess"},
{"name": "Ada", "form": "9C"},
{"name": "Raj", "form": "9B"},
]
for doc in docs:
if "club" in doc and doc["form"] == "9B" and doc["club"] == "chess":
print(doc["name"])
# Try it: print the form of every pupil with a club.
Check
Have a go
Check
3 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.