Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

6.8 (3 of 4): What a data system does

The whole lesson, free. Read it and have a go at the activities. To work the tasks and labs in the real lesson, press Start lab, with no account needed.

45 minutes

A quick check that you are not a bot, then your own lab opens on the interactive lesson.

Already have an account? Sign in

Please stock the hoodie

You use an online shop. The hoodie is sold out. You type: "Please stock the hoodie."

What happens to your message? The shop saves it. Later the shop counts how many people asked. If many people ask, the shop buys more hoodies. Then you can buy one.

That small story uses seven jobs. Every data system does them.

Key words

WordWhat it meansExample
Data systemA system that takes in, keeps and gives back data.An online shop
InputData going into the system.You type a request.
SearchTo find the data you want.Find every request for a hoodie.
SaveTo keep data so it is still there later.The request is stored.
IntegrateTo join data from different places.Put a customer name beside a request.
IndexA list that points to where data is, for fast finding.The index at the back of a book
OutputData coming out in a useful form.A list of the most asked items
Feedback loopWhat comes out changes what goes in next time.Stock the hoodie, and fewer people ask.
DatabaseAn organised store of data.The shop database

The cells students fill in are left blank in this preview.

Quick check: guess the job

Have a go

Quick check: guess the job

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

A data system does seven jobs

A data system does seven jobs.

  1. Input: data goes in.
  2. Search: find data.
  3. Save: keep data.
  4. Integrate: join data from different places.
  5. Organise: use an index so finding is fast.
  6. Output: show or send data.
  7. Feedback loop: what comes out changes what goes in.

The jobs as a loop

A loop: "Input: a request" leads to "Save in the database", then "Organise: index", then "Search", then "Integrate: add the customer name", then "Output: a report", which leads by "a decision" to "Feedback loop", which "changes" the input.A loop: "Input: a request" leads to "Save in the database", then "Organise: index", then "Search", then "Integrate: add the customer name", then "Output: a report", which leads by "a decision" to "Feedback loop", which "changes" the input.

Match the job to what it does

Have a go

Loading…

Your answers are marked here and are not kept. A college account keeps every student’s marks.

Try it: the seven jobs in code

Code: python
requests = []                      # Save: a list keeps the data
customers = {1: "Sam", 2: "Aisha"}

requests.append((1, "Hoodie"))     # Input: data goes in
requests.append((2, "Hoodie"))
requests.append((1, "Cap"))

for request in requests:           # Integrate: a name beside each request
    print(customers[request[0]], "asked for", request[1])

hoodie = []                        # Search: find the hoodie requests
for request in requests:
    if request[1] == "Hoodie":
        hoodie.append(request)
print("Hoodie requests:", len(hoodie))

requests.sort()                    # Organise: put the list in order
print(requests)                    # Output: show it

# Add one more request and run it again. See the output change.

Make a free account to save your work and track your progress.

The feedback loop

The output shows 2 requests for the hoodie and 1 for the cap. The shop decides to buy 20 hoodies. The decision changes the data: the stock goes up. When customers see it, fewer ask. The output has changed the input.

Watch: what a data system does

Press Play on the short film below. It starts with a request for a hoodie. Then it draws the seven jobs as a loop, shows an index and the small program, and ends with a myth.

Film: what a data system does

What a data system does

Every scene, as text

  1. Please stock the hoodie. You type: "Please stock the hoodie." (job: input). The shop saves it (job: save). That small story uses seven jobs.
  2. The jobs as a loop. Input, then Save, then Organise, then Search, then Integrate, then Output; Output leads to the Feedback loop (a decision), which leads back to Input (changes).
  3. An index makes finding fast. Index: a list that points to where data is, for fast finding. The index at the back of a book (how: look up a word, go to the page). An index on 5 million rows (so: no need to read every row).
  4. The small program, in run order. Three requests go in (job: input). "Sam asked for Hoodie" (job: integrate; why: the name is joined from customers). "Hoodie requests: 2" (job: search). The list is put in order (job: organise). The sorted list is printed (job: output).
  5. Myth (false): every step is save. That is not true: each step does its own job. Name the job when you see it. A list keeps the data (job: save). The teapot was asked for 3 times. So the shop buys 20 teapots. The decision changes the data: the stock goes up (job: feedback loop).

Your turn: a request list

A shop keeps a list of the products people ask for. Fill in four functions. The first adds a request. The second counts the requests for one product. The third gives back the product asked for most often. The fourth says if the shop should buy more. Press Run Tests to check your work.

Code: python
def add_request(requests, product):
    # Input and save: put one product name on the end of the list.
    # Give back the list.
    return None


def count_asks(requests, product):
    # Search: how many times is the product in the list?
    return -1


def most_asked(requests):
    # Output: give back the product that is in the list most often.
    # If two have the same count, give back the one that comes first in the list.
    # An empty list gives back an empty text "".
    return None


def needs_stock(requests, product, limit):
    # Feedback loop: the shop buys more when enough people ask.
    # Give back True if the product has been asked for limit times or more.
    return None

Make a free account to save your work, or press Start lab to work through the whole lesson.

Extra: Lab: the seven jobs in a real database

Note

Press Start the lab on the bar at the top and wait until it says it is running. The first start takes a little longer. Each Run button types its command into your own terminal. The commands run in order, so do not skip one.

Extra: Set up: trust the server, make sql short

Command
printf '[client]\nssl-verify-server-cert=0\n' > ~/.my.cnf; alias sql='mariadb -h db -u student -pstudent shop -t -e'

A command for the lesson’s lab terminal. It is shown here and not run.

Extra: Lab jobs 1 and 3: input and save

The lab has a shop database with real products and customers. You talk to it in SQL (a language for asking a store of tables for data). You add a new table, requests. It records who asked for which product, and when.

Run the first command to make the table. The second command is the input. The third reads the table back. The rows are saved: they are still there.

Extra: Make the requests table

Command
sql "CREATE TABLE requests (id INT AUTO_INCREMENT PRIMARY KEY, customer_id INT NOT NULL, product_id INT NOT NULL, asked_on DATE NOT NULL, FOREIGN KEY (customer_id) REFERENCES customers(id), FOREIGN KEY (product_id) REFERENCES products(id))"

A command for the lesson’s lab terminal. It is shown here and not run.

Extra: Input: five requests

Command
sql "INSERT INTO requests (customer_id, product_id, asked_on) VALUES (1, 17, '2026-10-01'), (2, 17, '2026-10-02'), (5, 27, '2026-10-03'), (1, 27, '2026-10-04'), (6, 17, '2026-10-05')"

A command for the lesson’s lab terminal. It is shown here and not run.

Extra: Save: read them back

Command
sql "SELECT * FROM requests"

A command for the lesson’s lab terminal. It is shown here and not run.

Extra: Lab job 2: search

To search is to find the data you want. WHERE keeps only the rows that match. Which products are sold out? A stock of 0 means none left.

Extra: Search: sold out products

Command
sql "SELECT id, name, stock FROM products WHERE stock = 0"

A command for the lesson’s lab terminal. It is shown here and not run.

Extra: Lab job 5: organise with an index

Think of the index at the back of a book. You do not read every page. You look up a word and go to the page.

A database index works the same. With an index on asked_on, the database finds a date without reading every row. With 5 rows you will not notice. With 5 million rows you will.

Extra: Organise: make an index

Command
sql "CREATE INDEX idx_requests_date ON requests (asked_on)"

A command for the lesson’s lab terminal. It is shown here and not run.

Extra: See the index

Command
sql "SHOW INDEX FROM requests"

A command for the lesson’s lab terminal. It is shown here and not run.

Extra: Lab jobs 4, 6, 7: integrate, output, feedback

The requests hold only numbers. The names are in other tables. A join puts them together. That is integrate.

The next command counts the requests for each product, biggest first. That is output.

The teapot was asked for 3 times. So the shop buys 20 teapots. The last two commands change the stock and check it. That is the feedback loop.

Extra: Integrate: names beside requests

Command
sql "SELECT customers.first_name, products.name, requests.asked_on FROM requests JOIN customers ON customers.id = requests.customer_id JOIN products ON products.id = requests.product_id ORDER BY requests.asked_on"

A command for the lesson’s lab terminal. It is shown here and not run.

Extra: Output: count the asks

Command
sql "SELECT products.name, COUNT(*) AS asks FROM requests JOIN products ON products.id = requests.product_id GROUP BY products.name ORDER BY asks DESC"

A command for the lesson’s lab terminal. It is shown here and not run.

Extra: Feedback: stock 20 teapots

Command
sql "UPDATE products SET stock = 20 WHERE id = 17"

A command for the lesson’s lab terminal. It is shown here and not run.

Extra: Check the new stock

Command
sql "SELECT id, name, stock FROM products WHERE id = 17"

A command for the lesson’s lab terminal. It is shown here and not run.

Key words crossword

Have a go

Loading…

Your answers are marked here and are not kept. A college account keeps every student’s marks.

Final check

Have a go

Final check

5 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Remember

Important

A data system does seven jobs: input, search, save, integrate, organise with an index, output, and a feedback loop. Name the job when you see it.

Teach this lesson with your class

On a college account your students work the tasks and the labs as well, and every mark is kept for you.