← QCE Digital Solutions Unit 3

Database server

A computer or program that stores a database and answers queries sent by other programs, such as a web server, by returning the matching data while keeping the stored data protected.

Understanding Database server in QCE Digital Solutions Unit 3

What it does: The program sends a query and the database server sends back the result rows, which are stored in the rows variable. A database server holds the data and replies to queries. Showing pages in a browser is the job of the browser, with pages supplied by the web server. Refusing an unauthorised query keeps the data safe. Returning query results is what happens when the request is allowed. The core idea is storing the database and answering queries from other programs. Drawing the interface is the job of the client or front end.

Common mistakes: sqlite3 has no open() function. A program connects to a database with sqlite3.connect('a.db') before it can send queries. fetchall is missing its brackets, so it is not called. It must be cur.fetchall() to return the query results as rows.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 15–119) and word search (Modules 15–176).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
What does a database server do?
Displays web pages to users in a browserStores a database and answers queries from other programs
Matches
The web server stores the database, so the database server is not needed.
↓
The database is stored on the database server, not the web server. The web server only sends queries and uses the results.
Applying
Meanings
Term
database server
Meaning
A computer or program that stores a database and answers queries sent by other programs, such as a web server, by returning the matching data while keeping the stored data protected.
Practice
-- Sent from the web server
Testing
Gaps
firstName, house FROM students;
Check Answer
Spots
1import sqlite3
2db = sqlite3.open('a.db')

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Camel' badge — Endurance Champion, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. What does a database server do?
A. Displays web pages to users in a browser
B. Stores a database and answers queries from other programs ✓
A database server holds the data and replies to queries. Showing pages in a browser is the job of the browser, with pages supplied by the web server.
2. A web app needs a student's marks. Which sends the SQL query to the database server?
A. The web server (server-side code) ✓
B. The user's monitor
Server-side code running on the web server sends the query to the database server. A monitor only displays output.
3. Which statement is correct about the web server and the database server?
A. They are separate roles, even if they sometimes run on the same computer ✓
B. They are always exactly the same thing
The web server handles page requests and the database server handles stored data. They are separate roles, and a small project may run both on one machine.
4. A query SELECT name FROM students WHERE house = 'Red' reaches the database server. What does it send back?
A. The whole database with every table
B. The rows that match the query ✓
A database server returns only the matching results (the query result), not the entire database.
5. Why do many systems keep the database on a database server instead of letting users open the data files directly?
A. To protect the stored data and control who can access it ✓
B. To make the data public so anyone can edit it
Protecting stored data is a key reason for a database server. It can check logins and permissions before it answers a query.

Match the Pairs

SELECT * FROM students WHERE house = 'Red'; → A query sent to the database server, which searches the stored students table and returns only the matching rows
db_server = "db.school.local" → The address of a database server, kept separate from the web server so the web app knows where to send its queries
A database server returns query results to the program that asked, such as a web server → rows = db.execute("SELECT name FROM products")
A database server protects stored data by only letting programs with the right login connect → db.connect(user="webapp", password="s3cret")
The web server stores the database, so the database server is not needed. → The database is stored on the database server, not the web server. The web server only sends queries and uses the results.
A user's browser connects straight to the database server and reads the tables. → Users do not connect directly to the database server. The web server sends queries on their behalf, which keeps the stored data protected.

Key Term

database server
A computer or program that stores a database and answers queries sent by other programs, such as a web server, by returning the matching data while keeping the stored data protected.

Fill in the Blanks

1. SELECT firstName, house FROM students;
Hint: Type the keyword a web server sends so the database server returns data.
2. GRANT SELECT ON students TO web_user;
Hint: Type the keyword that gives the web server's account permission to read only.
3. SELECT name, price FROM products WHERE stock = 0;
Hint: Type the name of the table the database server reads the matching rows from.
4. REVOKE DELETE ON students FROM web_user;
Hint: Type the permission being taken away to protect the stored data.
5. SELECT firstName, points FROM students WHERE points > 100 ORDER BY points DESC;
Hint: Type the keyword that returns the results with the highest value first.

Spot the Error

Question 1
A import sqlite3
B db = sqlite3.open('a.db')
C cur = db.cursor()
D cur.execute('SELECT * FROM t')
Line B — sqlite3 has no open() function. A program connects to a database with sqlite3.connect('a.db') before it can send queries.
Question 2
A cur = db.cursor()
B cur.execute('SELECT * FROM p')
C rows = cur.fetchall
D print(rows)
Line C — fetchall is missing its brackets, so it is not called. It must be cur.fetchall() to return the query results as rows.
Question 3
A -- sent to the database server
B SELECT name, price,
C FROM products
D WHERE stock > 0;
Line B — A trailing comma after the last field is a syntax error. The database server cannot run the query, so it returns no results. It should be SELECT name, price.
Question 4
A name = input('Name: ')
B sql = 'SELECT * FROM students'
C sql += ' WHERE firstName = ?'
D cur.execute(sql + name)
Line D — Joining user input straight into the SQL lets someone inject harmful commands and puts the stored data at risk. Pass the value as a parameter: cur.execute(sql, (name,)).
Question 5
A Browser requests the page
B Web server queries browser
C DB server returns the rows
D Web server builds the page
Line B — The web server does not store the data. It sends its query to the separate database server, not to the browser.

Student with a class code? Join your class →