← Back to subjects
⭐ 0
OCR A-level Computer Science (H446) Β· Exchanging data
Mini-Lesson

Exchanging data

This mini-lesson covers OCR 1.3 β€” Exchanging data: how data is squeezed, secured, stored in databases and moved across networks and the web.

  • Compression β€” lossy, lossless, RLE and dictionary encoding
  • Encryption and hashing
  • Databases β€” keys, normalisation, SQL, ACID and record locking
  • Networks β€” the TCP/IP stack, DNS, packet switching
  • Web technologies β€” HTML, CSS, JavaScript, PageRank, client vs server

Work through each screen, answer the questions as you go (some are recall, some are calculations you must actually work out) and collect ⭐ stars. Press Start when you're ready.

1.3 Β· Compression

Lossy and lossless compression

Lossless compression discards nothing β€” the original is restored bit for bit. Essential for text, code and executables.

  • Run-length encoding (RLE) β€” replace runs of identical values with a (value, count) pair. AAAAABBBCCCCCCCC (16 characters) becomes A5 B3 C8 (6 characters).
  • Dictionary encoding β€” build a dictionary of repeated sequences and transmit short index codes. The decoder rebuilds the same dictionary as it goes.

Lossy compression permanently discards data that human perception will not miss β€” MP3 removes inaudible frequencies, JPEG throws away fine colour detail. Far smaller files, and the discarded data is gone forever.

RLE's weakness: on data with no runs β€” ordinary English text, for instance β€” every single character becomes a (character, 1) pair, so the file gets bigger. No compression algorithm can shrink every possible input; that is a mathematical impossibility, not an engineering failure.

Calculate

Your turn β€” run-length encoding

1Apply run-length encoding to AAAAABBBCCCCCCCC (16 characters), writing each run as a letter followed by its count. How many characters does the encoded version contain?
characters
Hint: Each run becomes two characters: the letter and the count. Count the runs, then double it.
1.3 Β· Security

Encryption and hashing

SymmetricAsymmetric
One shared key encrypts and decryptsA public key encrypts; only the matching private key decrypts
Fast β€” used for the bulk of the dataSlow β€” used to exchange a symmetric key and to sign
The hard problem: how do you get the key to the other party securely?Solves it β€” the public key may be published openly

Digital signatures: the sender hashes the message and encrypts the hash with their private key. Anyone can decrypt it with the public key, hash the message themselves, and compare β€” proving both authenticity and integrity.

Hashing is one-way: it turns input of any size into a fixed-size digest that cannot be reversed. It is used to index hash tables and, crucially, to store passwords β€” so a stolen database yields nothing usable.

Hashing is not encryption. Encryption is designed to be reversed by whoever holds the key. Hashing is designed never to be reversed at all. Confusing them is the single commonest error in this topic.

1.3 Β· Databases

Relational databases and normalisation

A flat file holds everything in one table, so data is repeated in row after row. That redundancy causes update anomalies: change a customer's address and you must edit every row that mentions them β€” miss one and the database now contradicts itself.

A relational database splits data into linked tables:

  • Primary key β€” uniquely identifies each record; never null, never duplicated.
  • Foreign key β€” an attribute pointing at another table's primary key. Referential integrity means it must always match an existing record.
  • Secondary key / index β€” an extra index to speed up common searches.
FormRule
1NFAtomic values only β€” no repeating groups or lists in a cell
2NFIn 1NF, and no partial dependency on part of a composite key
3NFIn 2NF, and no transitive dependency (a non-key field depending on another non-key field)

The mantra: every non-key attribute depends on the key, the whole key, and nothing but the key. A many-to-many relationship must be resolved with a link table.

1.3 Β· Databases

SQL, transactions and ACID

SELECT Name, Grade FROM Student WHERE Grade >= 60 ORDER BY Grade DESC; SELECT Student.Name, Tutor.TutorName FROM Student INNER JOIN Tutor ON Student.TutorID = Tutor.TutorID; INSERT INTO Student (StudentID, Name) VALUES (105, 'Ada'); UPDATE Student SET TutorID = 4 WHERE StudentID = 105; DELETE FROM Student WHERE StudentID = 105;

A transaction must succeed or fail as one indivisible unit. The ACID guarantees:

  • Atomicity β€” all of it happens, or none of it does (a failure triggers a rollback);
  • Consistency β€” the database moves from one valid state to another; constraints still hold;
  • Isolation β€” concurrent transactions do not interfere;
  • Durability β€” once committed, the change survives a crash.

Record locking stops two users updating the same record at once (the lost update problem) β€” at the risk of deadlock, where each transaction waits for a lock the other holds. Redundancy (mirrored servers) protects against hardware failure.

The most dangerous line in SQL: DELETE FROM Student; β€” with the WHERE clause forgotten, that removes every row. Write the WHERE clause first, then the rest.

Calculate

Your turn β€” the SQL result

2The Orders table holds these Total values: 20, 55, 60, 45, 100, 50.
SELECT COUNT(*) FROM Orders WHERE Total > 50;
What does this return?
Hint: Strictly greater than 50, so the order of exactly 50 does not count.
Quick check

ACID

?A transfer debits Β£100 from account A, then the server crashes before crediting account B. Which ACID property ensures the money is not lost?
1.3 Β· Networks

Networks and the TCP/IP stack

LayerJobExamples
ApplicationProtocols the user's program speaksHTTP, HTTPS, FTP, SMTP, POP3, IMAP
TransportSplits data into packets, adds port numbers, handles acknowledgements and retransmissionTCP, UDP
NetworkAdds source and destination IP addresses; routers forward packetsIP
LinkAdds MAC addresses for the physical hopEthernet, Wi-Fi

Packet switching: data is split into packets, each routed independently and possibly by a different route, then reassembled in order using their sequence numbers. This uses the network efficiently and routes automatically around failure and congestion. Circuit switching instead reserves a dedicated path for the whole call β€” guaranteed bandwidth, but the line sits idle whenever nobody is speaking.

DNS is a distributed, hierarchical database that resolves a domain name to an IP address. Client-server centralises control on a server; peer-to-peer makes every machine both client and server, with no single point of failure and capacity that grows with the number of peers.

Calculate

Your turn β€” transfer time

3A 2 MB file is sent over a link with a bit rate of 8 Mbps. Taking 1 MB = 8 Mbit and ignoring overheads, how many seconds does the transfer take?
seconds
Hint: Convert 2 megabytes into megabits first, then divide by the bit rate.
1.3 Β· The web

Web technologies

  • HTML β€” the structure and content of the page.
  • CSS β€” the presentation: colour, layout, typography. Separating it from HTML means one stylesheet can restyle a thousand pages.
  • JavaScript β€” behaviour, executed client-side in the browser.
Client-side processingServer-side processing
Runs in the browser; instant response; reduces server loadRuns on the server; the code and the database are never exposed
Can be read, altered or disabled by the user β€” so validation here is a convenience, never a security controlCannot be tampered with by the client; slower (a round trip)

Search engine indexing: web crawlers follow links, and the pages are indexed by keyword. PageRank then ranks them: a page is important if important pages link to it. A link from a highly ranked page passes on more weight than a link from an obscure one β€” which is why simply creating thousands of junk pages that link to you does not work.

The security rule you must never forget: always validate on the server, even if you have already validated on the client. Client-side code runs on a machine the attacker controls completely β€” they can simply switch it off and post whatever they like.

Quick check

Client vs server

?A registration form uses JavaScript to check that the password is at least 8 characters. Is client-side validation on its own sufficient?
Quick check

Compression

?Why does run-length encoding sometimes make a file larger?
Sort it

Which TCP/IP layer?

Tap an item, then tap the layer it belongs to.

πŸ“¨ Application

🚚 Transport

πŸ—ΊοΈ Network

Match it

Match the technique to its purpose

Tap an item on the left, then its partner on the right.

Purpose
Technique
Recap

The big ideas to know

Compression: lossless (RLE, dictionary) recovers exactly Β· lossy (MP3, JPEG) discards permanently Β· RLE can enlarge run-free data

Security: symmetric = fast, key exchange is the problem Β· asymmetric = solves it, slow Β· digital signatures Β· hashing is one-way

Databases: primary/foreign/secondary keys Β· referential integrity Β· 1NF, 2NF, 3NF Β· link table for many-to-many

SQL & ACID: SELECT/INSERT/UPDATE/DELETE/INNER JOIN Β· atomicity, consistency, isolation, durability Β· record locking, deadlock

Networks: TCP/IP stack: application, transport, network, link Β· packet vs circuit switching Β· DNS Β· client-server vs peer-to-peer

Web: HTML structure, CSS presentation, JavaScript behaviour Β· PageRank Β· always validate on the server

That is the whole of OCR 1.3. Press Finish to see your score.

πŸ†

Mini-lesson complete!

⭐⭐⭐

You've worked through Exchanging data for OCR A-level Computer Science (H446). πŸŽ‰

Your stars: 0 / 0

Next: test yourself in the Evaluate stage Confidence Quiz, then lock it in with Verify.

πŸ“£ Smashed it? Share your score

Challenge a mate to beat your stars, or show a parent how you got on.

β†’ Back to all subjects