Mission 1 · Spec 1.3.1
Compression, encryption and hashing
Lossy and lossless compression, run length encoding and dictionary coding; symmetric and asymmetric encryption; and hashing.
- Starter 5 min
- Learn 15 min
- Lab 20 min
- Quiz 10 min
- Exam 15 min
The padlock problem
You want a stranger to send you a secret. You can't meet to swap a key. How could you do it with padlocks?
Reveal
Post them an open padlock that only you have the key for. They lock the box and send it back. The open padlock is a public key; your key is the private key. That is asymmetric encryption.
Key ideas
Lossy vs lossless
Lossy removes data permanently for much smaller files (images, audio, video). Lossless allows exact reconstruction (text, code, databases).
Run length encoding
Replaces runs of repeated data with a count and the data. Lossless; effective when there are long runs.
Dictionary coding
Frequently occurring data (e.g. words) is stored once in a dictionary and replaced in the file by its index. Lossless.
Symmetric encryption
The same key encrypts and decrypts. Fast, but the key must be shared securely: if it's intercepted, all messages can be read.
Asymmetric encryption
A public key encrypts; only the matching private key decrypts. Solves the key-sharing problem. Signing with a private key and checking with the public key gives a digital signature.
Hashing
A one-way function producing a fixed-length value. Used to store passwords (compare hashes, never store the password) and to check data hasn't changed. Also used to find items in hash tables.
Run length encoding
Dictionary coding
Public-key encryption with small numbers
Hashing
Exam-style questions
1. Explain how asymmetric encryption allows two people who have never met to communicate securely.
[4 marks]Mark scheme
- Each person has a public key and a private key (1)
- The public key can be shared openly (1)
- The sender encrypts using the recipient's public key (1)
- Only the recipient's private key can decrypt it, so no secret key needs to be exchanged (1)
2. Explain why passwords should be stored as hashes rather than encrypted.
[3 marks]Mark scheme
- Hashing is one-way: the hash can't be reversed to reveal the password (1)
- Encrypted passwords could be decrypted if the key is stolen (1)
- At login the entered password is hashed and compared with the stored hash (1)
TUTOR NOTES
- Misconception: hashing is a type of encryption. Encryption is designed to be reversed; hashing isn't.
- Extension: why is symmetric encryption still used (e.g. HTTPS uses asymmetric to share a symmetric key)?
Mission 2 · Spec 1.3.2
Databases
Relational databases and keys, normalisation to third normal form, SQL, referential integrity, and transactions (ACID, record locking).
- Starter 5 min
- Learn 15 min
- Lab 25 min
- Quiz 10 min
- Exam 15 min
The last ticket
Two people click "buy" on the last concert ticket at exactly the same moment. What should the database do?
Reveal
It must make sure only one sale succeeds. Record locking stops the second transaction changing the record until the first finishes, and ACID properties make sure a transaction is all-or-nothing.
Key ideas
Keys
Primary key: uniquely identifies each record. Foreign key: a field linking to another table's primary key. Secondary key: an indexed field used to search quickly, e.g. surname.
Entity relationships
One-to-one, one-to-many, many-to-many. A many-to-many relationship is resolved with a link (junction) table.
Referential integrity
Every foreign key must match an existing primary key, e.g. you can't delete a customer who still has orders.
Capturing and exchanging data
Data can be captured by forms, OCR/OMR, sensors and barcodes, and exchanged using formats such as CSV, JSON and XML or via EDI.
| Normal form | Rules |
|---|---|
| 1NF | No repeating groups of attributes; every field is atomic; each record has a primary key |
| 2NF | In 1NF, and no partial dependencies (no non-key field depends on only part of a composite key) |
| 3NF | In 2NF, and no transitive (non-key) dependencies: every non-key field depends on "the key, the whole key and nothing but the key" |
ACID
Atomicity: all or nothing. Consistency: takes the database from one valid state to another. Isolation: concurrent transactions don't interfere. Durability: once committed, changes survive failures.
Redundancy
Duplicate copies of data held on separate systems/disks, so a failure doesn't lose data. (Different from data redundancy, which normalisation removes.)
SQL: joins
A real database runs in your browser.SQL: insert, delete, drop
ACID
Which normal form rule is broken?
Exam-style questions
1. Write an SQL statement using INNER JOIN to list the FirstName of every student and the Day their club meets.
[4 marks]Mark scheme
SELECT Students.FirstName, Clubs.Day(1)FROM Students(1)INNER JOIN Clubs(1)ON Students.ClubID = Clubs.ClubID(1)
2. Explain how record locking prevents problems when two users update the same record.
[3 marks]Mark scheme
- When a record is being edited it is locked (1)
- so no other user / transaction can change it until the first has finished (1)
- preventing one update overwriting another / lost updates (1)
TUTOR NOTES
- Exam habit: in normalisation questions, state which dependency you are removing.
- Misconception: record locking can't cause problems. It can cause deadlock.
Mission 3 · Spec 1.3.3
Networks
The TCP/IP stack, DNS, protocol layering, LANs and WANs, packet and circuit switching, network security and hardware, client-server and peer-to-peer.
- Starter 5 min
- Learn 15 min
- Lab 20 min
- Quiz 10 min
- Exam 15 min
Phone call vs letters
An old phone call reserved a whole line between two people. A letter shares roads with millions of others. Which uses the network more efficiently?
Reveal
The letter: packet switching shares links between many users. The reserved line is circuit switching: a dedicated path for the whole call, reliable but wasteful when idle.
Key ideas
TCP/IP stack
Application (HTTP, FTP, SMTP, POP3), Transport (TCP: splits into packets, port numbers, reliability), Network/Internet (IP addresses, routing), Link (MAC addresses, physical transmission).
Packet vs circuit switching
Packet: data split into packets that can take different routes and are reassembled; efficient, resilient. Circuit: a dedicated path for the duration; data arrives in order with consistent speed, but bandwidth is wasted when idle.
Security
Firewall: filters traffic using rules (ports, IP addresses). Proxy server: sits between users and the internet, hiding users' IP addresses, caching pages and filtering content. Encryption protects data in transit.
Hardware
NIC, switch, router, wireless access point, transmission media. Routers forward packets between networks using routing tables.
Client-server vs P2P
Client-server: central management, security and backup; server is a single point of failure. P2P: peers share directly; cheap and resilient, but harder to secure and manage.
DNS
Resolves domain names to IP addresses through a hierarchy of DNS servers; results are cached to speed up future lookups.
Down and up the stack
Packet switching
Which layer?
Exam-style questions
1. Compare packet switching and circuit switching.
[4 marks]Mark scheme
- Packet switching splits data into packets that may take different routes; circuit switching sets up a dedicated path (1)
- Packets are reassembled in order at the destination; in circuit switching data arrives in order (1)
- Packet switching uses bandwidth more efficiently / links shared; circuit switching reserves bandwidth even when idle (1)
- Packet switching can route around failures; circuit switching gives a consistent connection quality (1)
2. Describe two functions of a proxy server.
[4 marks]Mark scheme
- Acts as an intermediary so users' IP addresses are hidden (1) giving anonymity / security (1)
- Caches frequently requested pages (1) so they load faster and bandwidth is saved (1)
- Filters content (1) blocking access to certain websites (1)
- Max 4
TUTOR NOTES
- Terminology: OCR names the layers application, transport, network (internet) and link.
- Misconception: a firewall and a proxy do the same thing.
Mission 4 · Spec 1.3.4
Web technologies
HTML, CSS and JavaScript; search engine indexing; PageRank; and server-side versus client-side processing.
- Starter 5 min
- Learn 15 min
- Lab 25 min
- Quiz 10 min
- Exam 15 min
Why is Wikipedia always near the top?
Search for almost anything and Wikipedia appears near the top. Why might a search engine trust it so much?
Reveal
Millions of other pages link to it, including important ones. PageRank measures importance by the number and importance of the pages linking in.
Key ideas
HTML
Structure: html, head, title, body, h1–h3, p, img (src, height, width), a (href), div, form, input, ol/ul/li, script.
CSS
Presentation, inline or in a stylesheet: background-color, border, color, font-family, font-size, height, width. Selectors: element, .class, #id.
JavaScript
Behaviour: variables, selection, iteration, functions; changing page content with document.getElementById(...).innerHTML; alert().
Search engines
Crawlers (spiders) follow links, and an index records which words appear on which pages. Results are ranked using algorithms such as PageRank.
Client-side processing
Runs in the browser (JavaScript): fast feedback, reduces server load, but code is visible and can be bypassed, so it can't be trusted for security.
Server-side processing
Runs on the web server: accesses databases, hides code, secure validation; but increases server load and needs round trips.
Web page editor
PageRank
Client or server?
Exam-style questions
1. Explain why data entered in a web form should be validated on the server even if it has already been validated by JavaScript in the browser.
[3 marks]Mark scheme
- Client-side code can be viewed / modified / disabled by the user (1)
- so invalid or malicious data (e.g. SQL injection) could still be sent (1)
- Server-side validation can't be bypassed, protecting the database (1)
2. Describe how the PageRank algorithm decides the importance of a web page.
[3 marks]Mark scheme
- Based on the number of pages that link to it (1)
- and the PageRank / importance of those linking pages (1)
- A page's rank is shared between the pages it links to, and a damping factor is applied; the calculation is repeated until values settle (1)
TUTOR NOTES
- Lab prompt: in PageRank, make every page link to E. What happens to E's rank?
- Exam habit: OCR expects exact HTML tag names and CSS property names.