Free O Level Computer Science 2210 Handouts — Edvia College
← Free ResourcesEDVIA COLLEGEApply Now

Computer Science 2210 — chapter handouts

One handout per topic, in plain English. Read the handout before the textbook, not after it — each one takes about five minutes and is designed to make the idea land first, so the formal version has somewhere to stick.

10 handoutsCambridge O LevelPrintableFree to copy and share
Open the full 2210 study guide → Practice these → All subjects

Topics

  1. Data representation
  2. Data transmission
  3. Hardware
  4. Software
  5. The internet and its uses
  6. Automated and emerging technologies
  7. Algorithm design and problem-solving
  8. Programming
  9. Databases
  10. Boolean logic
Topic 1

Data representation

A computer has only one thing to work with — switches that are on or off — so everything else has to be built out of that.

Picture itImagine a row of eight light switches. That is all a computer really has. A photo of your family, a song, this sentence, the number 47 — every one of them is just a particular pattern of those switches being on or off. The cleverness is entirely in the agreed rules for reading the pattern.

Binary counts in powers of two

Each place is worth twice the one to its right: 128, 64, 32, 16, 8, 4, 2, 1. So 00101101 is 32 + 8 + 4 + 1 = 45. To go the other way, subtract the biggest power of two that fits, and repeat.

Hexadecimal is shorthand for humans

One hex digit stands for exactly four bits, so a byte is two hex digits. 1101 1110 becomes DE. Nothing changes inside the machine — hex is purely so that people reading colour codes, MAC addresses and memory dumps do not go cross-eyed.

Two's complement stores negative numbers

The leftmost bit becomes a sign: 0 for positive, 1 for negative. To negate a number, flip every bit and add one. In 8 bits, 00000101 is 5, so 11111011 is −5. This works because ordinary binary addition then gives the right answer with no special rules.

Text, images and sound all reduce to numbers

ASCII gives each character a code (7 bits, 128 characters); Unicode extends this to cover every writing system. An image is a grid of pixels, each storing a colour value — resolution is how many pixels, colour depth is how many bits per pixel. Sound is sampled many times a second, with sample rate and sample resolution deciding the fidelity.

Compression makes files smaller in two ways

Lossless (used in ZIP, PNG) rebuilds the original perfectly, typically by run-length encoding repeated data or storing a dictionary of repeats. Lossy (used in JPEG, MP3) permanently throws away detail people are unlikely to notice, so it shrinks much further but you can never get the original back.

The bit that catches people out1 byte is 8 bits, but the prefixes are the trap. In the syllabus, 1 kibibyte (KiB) is 2¹⁰ = 1024 bytes, while 1 kilobyte (kB) is 1000 bytes. Read which one the question is using before you multiply.

The grown-up words

What it meansWhat it is calledNote
A single 0 or 1bitThe smallest unit
Eight bitsbyteTwo hex digits
Base 16 shorthand for binaryhexadecimalOne digit = four bits
Method of storing negative binary numberstwo's complementFlip all bits, add 1
Code that maps characters to numbersASCIIUnicode covers all languages
Number of pixels in an imageresolutionMore pixels = larger file
Bits used per pixelcolour depthMore bits = more colours
Compression that loses no datalosslessZIP, PNG
Compression that discards detail permanentlylossyJPEG, MP3

Check you have got it

Convert 10110110 to denary and to hexadecimal.
Denary 182 (128 + 32 + 16 + 4 + 2). Hex B6 — split into 1011 (B) and 0110 (6).
Why would you use lossless rather than lossy compression for a spreadsheet?
Because every value must be recoverable exactly. Lossy compression permanently discards data, which would corrupt the figures; lossless rebuilds the file perfectly.
Edvia Free Resources · Computer Science 2210 · Topic 1 — free to copy and share
Topic 2

Data transmission

Sending data is easy; making sure it arrives in the right order and without errors is the actual job.

Picture itPosting a book one page at a time in separate envelopes. The pages may travel by different routes and turn up out of order, so each envelope needs a page number, a destination and a way of checking nothing was smudged in transit. That is packet switching, and it is how the internet moves everything.

Data travels in packets

A packet has a header (sender and receiver addresses, packet number, how many packets in total), a payload (the actual data, often around 64 KiB) and a trailer (an end-of-packet marker and error-checking data). Packets can take different routes and are reassembled in order at the destination.

Serial and parallel, simplex and duplex

Serial sends one bit at a time down one wire — reliable over distance. Parallel sends several bits at once down several wires — fast but suffers skew and crosstalk over long runs. Simplex is one direction only, half-duplex is both directions but not at once, full-duplex is both directions simultaneously.

USB is the everyday example

USB is serial, is automatically detected, cannot be plugged in the wrong way round and supplies power. Its limits are cable length and the fact that older versions are much slower than modern alternatives.

Error detection methods

Parity adds a bit to make the number of 1s odd or even. Checksum sends a calculated total that is recalculated on arrival. Echo check sends the data back to be compared. Check digit validates typed codes like ISBNs and barcodes. ARQ uses acknowledgements and timeouts to trigger resending.

Encryption protects the content, not the delivery

Symmetric encryption uses the same key to encrypt and decrypt — fast, but the key has to be shared safely. Asymmetric uses a public key to encrypt and a private key to decrypt, which solves the key-sharing problem. Encrypted data that is intercepted is still meaningless without the key.

The bit that catches people outParity catches an odd number of flipped bits, but if two bits flip in the same byte the parity still checks out and the error sails through. No single error-detection method is a guarantee — that is why real systems layer several.

The grown-up words

What it meansWhat it is calledNote
Small unit data is broken into for transmissionpacketHeader, payload, trailer
One bit at a time down one wireserial transmissionReliable over distance
Several bits at once down several wiresparallel transmissionFast but suffers skew
Both directions at the same timefull-duplexe.g. a phone call
Extra bit making the 1s odd or evenparity bitMisses two flipped bits
Calculated total sent with the datachecksumRecalculated on arrival
Same key encrypts and decryptssymmetric encryptionKey sharing is the weakness
Public key encrypts, private key decryptsasymmetric encryptionSolves key sharing

Check you have got it

Why is serial transmission preferred over parallel for long-distance links?
Parallel wires suffer skew — bits sent together arrive at slightly different times — plus crosstalk between wires. Over distance this corrupts data, while serial sends one bit at a time in a guaranteed order.
A byte 1011010 is sent with even parity. What is the parity bit?
There are four 1s, which is already even, so the parity bit is 0.
Edvia Free Resources · Computer Science 2210 · Topic 2 — free to copy and share
Topic 3

Hardware

Every computer, from a phone to a supercomputer, is fetching an instruction, decoding it and executing it — over and over, billions of times a second.

Picture itA very fast, very obedient clerk with a tiny desk. The desk (registers) holds only what is being worked on right now. A filing shelf beside it (RAM) holds today's papers. A basement archive (storage) holds everything else. The clerk cannot read anything until it is on the desk — which is why moving data around costs so much time.

The fetch–decode–execute cycle

The program counter holds the address of the next instruction. That address goes into the MAR, the instruction comes back through the MDR into the CIR, the control unit decodes it, and the ALU performs any arithmetic or logic, using the accumulator to hold results. Then the cycle repeats.

Buses carry the traffic

The address bus carries memory addresses one way only. The data bus carries data both ways. The control bus carries timing and command signals. A wider address bus means more addressable memory; a wider data bus means more data moved per cycle.

Performance depends on more than clock speed

A higher clock speed means more cycles per second. More cores allow genuinely simultaneous work. A larger cache keeps frequently used instructions close to the CPU, avoiding slow trips to RAM. Increasing any one of these alone hits diminishing returns.

RAM and ROM do different jobs

RAM is volatile, read-write, and holds whatever is running now. ROM is non-volatile and holds the start-up instructions. Virtual memory uses part of the hard disk when RAM runs out — it prevents a crash but is much slower, causing 'disk thrashing' if overused.

Storage comes in three technologies

Magnetic (hard disks) — cheap per gigabyte, moving parts, large capacity. Optical (CD, DVD, Blu-ray) — a laser reads pits and lands, cheap and portable, low capacity. Solid state (SSD, flash) — no moving parts, fast, silent, durable, but more expensive and with a finite number of write cycles.

The bit that catches people outEmbedded systems are computers too. The controller in a washing machine, a set of traffic lights or a car's engine management is a full CPU running a fixed program — the syllabus expects you to recognise these as computer systems, not just as appliances.

The grown-up words

What it meansWhat it is calledNote
Address of the next instructionprogram counterIncrements each cycle
Holds the address being accessedmemory address register (MAR)Address bus
Holds the data fetched or to be storedmemory data register (MDR)Data bus
Performs arithmetic and logicALUUses the accumulator
Volatile working memoryRAMContents lost on power off
Non-volatile start-up memoryROMHolds the bootstrap
Fast memory close to the CPUcacheReduces trips to RAM
Disk space used as extra RAMvirtual memorySlower than real RAM
Computer built into a larger deviceembedded systemFixed function

Check you have got it

Explain why adding more cache can speed up a computer.
Cache holds frequently used instructions and data physically close to the CPU. Fetching from cache is far faster than fetching from RAM, so the CPU spends less time waiting and more time executing.
Give one advantage and one disadvantage of an SSD over a hard disk drive.
Advantage: no moving parts, so it is faster, quieter and more resistant to being knocked. Disadvantage: it costs more per gigabyte and has a limited number of write cycles.
Edvia Free Resources · Computer Science 2210 · Topic 3 — free to copy and share
Topic 4

Software

Hardware can do nothing on its own — software is the set of instructions that makes it useful, and it comes in two layers.

Picture itA kitchen. The oven, hob and knives are hardware. The kitchen manager who decides who uses what and when, and keeps everything running, is the operating system. The recipes are application software. You need all three, and the manager runs whether anyone is cooking or not.

System software versus application software

System software runs the machine: the operating system, device drivers, utilities, compilers. Application software does a job for the user: word processors, browsers, spreadsheets, games. If it manages the computer it is system software; if it does a task for you it is application software.

What an operating system actually manages

Memory, files, hardware and peripherals, multitasking, security and user accounts, plus the user interface. It sits between the hardware and everything else, so applications never have to know what brand of printer is attached.

Booting starts with firmware

When power is applied, the bootstrap in ROM runs first. It checks the hardware and loads the operating system from storage into RAM. Only then can anything else start — which is why a corrupted OS still lets the machine power on but not get anywhere.

Interrupts let hardware ask for attention

An interrupt is a signal telling the CPU that something needs handling — a key pressed, a printer out of paper, a timer expiring. The CPU finishes the current instruction, saves its state, runs the interrupt service routine, then resumes exactly where it left off.

High-level and low-level languages

High-level languages are readable, portable and quick to write, but must be translated. Low-level (assembly, machine code) is hardware-specific and lets you control the machine precisely. A compiler translates the whole program once, producing a file that runs without it. An interpreter translates and runs line by line, stopping at the first error — better for developing, slower to run.

The bit that catches people outA compiler and an interpreter are not two ways of doing the same thing at different speeds. A compiler produces a standalone executable and reports all errors together; an interpreter needs to be present every time the program runs and halts at the first error it meets.

The grown-up words

What it meansWhat it is calledNote
Software that manages the computersystem softwareOS, drivers, utilities
Software that does a task for the userapplication softwareBrowser, word processor
Program in ROM that starts the machinebootstrapLoads the OS into RAM
Signal asking the CPU for attentioninterruptHandled by an ISR
Translates the whole program at oncecompilerProduces an executable
Translates and runs line by lineinterpreterStops at the first error
Language close to the hardwarelow-level languageAssembly, machine code
Readable, portable programming languagehigh-level languageMust be translated

Check you have got it

Why must the bootstrap be stored in ROM rather than RAM?
RAM is volatile and is empty when the computer is switched on. ROM is non-volatile, so the start-up instructions are still there and can load the operating system into RAM.
Give one reason a developer might use an interpreter while writing a program.
It reports errors one at a time as it reaches them, so mistakes can be found and fixed immediately without recompiling the whole program.
Edvia Free Resources · Computer Science 2210 · Topic 4 — free to copy and share
Topic 5

The internet and its uses

The internet is the wires; the World Wide Web is one of the things people send over them.

Picture itThe internet is the road network. The web is the delivery vans using it. Email, video calls and game traffic are all other vehicles on the same roads. People use "internet" and "web" as if they mean the same thing, and they do not.

How a page reaches your screen

You type a URL. DNS looks up the matching IP address. The browser requests the page using HTTP (or HTTPS if encrypted), the server sends back HTML, and the browser renders it. Each step is a separate service that can fail on its own.

IP addresses and MAC addresses identify different things

An IP address identifies a device on a network and can change — IPv4 is four numbers, IPv6 is eight hexadecimal groups and exists because IPv4 addresses ran out. A MAC address is fixed in the hardware and identifies the network card itself.

Cookies remember things between visits

Session cookies are held in memory and vanish when the browser closes — they keep a shopping basket alive. Persistent cookies are stored on disk and survive, remembering logins and preferences. Both raise privacy questions, which is why consent banners exist.

Digital certificates and HTTPS

A digital certificate, issued by a certificate authority, proves a website is who it claims to be. SSL/TLS uses it to set up an encrypted connection — that is the padlock. Encryption alone would still let you send your password securely to a criminal; the certificate is what checks who is at the other end.

Threats and their countermeasures

Malware (virus, worm, trojan, spyware, ransomware), phishing, pharming, brute-force attacks, DDoS, data interception and SQL injection. Defences include firewalls, anti-malware, strong and unique passwords, two-factor authentication, biometrics, encryption, privilege levels and simply keeping software patched.

The bit that catches people outEncryption does not stop data being stolen — it stops stolen data being readable. If an exam question asks how encryption protects data, say that intercepted data is meaningless without the key, not that it prevents interception.

The grown-up words

What it meansWhat it is calledNote
The global network of connected networksthe internetThe infrastructure
The collection of pages accessed over itWorld Wide WebOne service on the internet
Translates a domain name to an IP addressDNSDomain Name Service
Address identifying a device on a networkIP addressCan change; IPv4 or IPv6
Address built into the network hardwareMAC addressFixed to the device
Small file remembering a user between requestscookieSession or persistent
Proves a website's identitydigital certificateIssued by a certificate authority
Fake message tricking a user into giving detailsphishingPharming redirects instead
Flooding a server so it cannot respondDDoS attackDenial of service

Check you have got it

Explain the difference between phishing and pharming.
Phishing sends a fake message hoping the user clicks a link and hands over details. Pharming installs code that redirects the user to a fake site even when they type the correct address — no click needed.
Why does a padlock in the address bar require a certificate as well as encryption?
Encryption only scrambles the connection. The certificate, issued by a trusted authority, proves the site really is who it claims to be — otherwise you could have a perfectly secure connection to a criminal.
Edvia Free Resources · Computer Science 2210 · Topic 5 — free to copy and share
Topic 6

Automated and emerging technologies

A system that senses the world, decides something and acts on it — with no human in the loop — is automation; adding the ability to improve from experience is where AI begins.

Picture itA greenhouse. Sensors read temperature and humidity. A microprocessor compares each reading with a stored value. If it is too hot, it opens a vent. Nobody is watching, and the loop never stops. Now imagine it noticing that opening the vent at 2pm works badly in winter, and adjusting itself — that is the jump from automation to learning.

The sensing loop

Sensors give analogue readings; an ADC converts them to digital. The microprocessor compares each value against a stored setting. If action is needed it sends a signal, through a DAC if required, to an actuator — a motor, valve, heater or buzzer. Then it reads again, forever.

Sensors to know by name

Temperature, pressure, light, moisture/humidity, pH, gas, infrared, motion, magnetic field, proximity, level, and acoustic. Exam questions almost always ask which sensor suits a described situation — match the physical quantity being measured.

Monitoring versus control

A monitoring system reports readings but changes nothing — a patient monitor, a pollution logger. A control system acts on the readings automatically. Reading the question carefully matters: if no actuator is mentioned, it is monitoring.

Robotics

Robots have sensors, a programmable controller and end effectors. They are good at repetitive, precise, dangerous or dirty work, run continuously and consistently. The trade-offs are high initial cost, loss of jobs, deskilling and inflexibility when the task changes.

Artificial intelligence in three layers

Narrow AI does one task well and is what actually exists today. Machine learning improves through exposure to data rather than explicit programming. Expert systems combine a knowledge base, a rule base, an inference engine and a user interface to give reasoned advice in one narrow field.

The bit that catches people outAn expert system does not think. It applies rules written by human experts to the facts it is given, and it can explain which rules it used. That explanation facility is a syllabus point in its own right — and it is what separates an expert system from a black box.

The grown-up words

What it meansWhat it is calledNote
Device that measures a physical quantitysensorOutput is analogue
Converts analogue readings to digitalADCSo the processor can use them
Device that carries out a physical actionactuatorMotor, valve, heater
System that reports but does not actmonitoring systemNo actuator
System that acts on its own readingscontrol systemClosed loop
Stored facts an expert system reasons overknowledge basePlus a rule base
Part that applies rules to reach a conclusioninference engineCore of an expert system
Improving performance from datamachine learningRather than explicit rules

Check you have got it

Name the sensor and actuator you would use in an automatic greenhouse vent.
A temperature sensor to measure the air, and a motor as the actuator to open and close the vent.
Why is an ADC needed in most control systems?
Sensors produce continuously varying analogue signals, but a microprocessor can only work with digital data, so the analogue reading must be converted first.
Edvia Free Resources · Computer Science 2210 · Topic 6 — free to copy and share
Topic 7

Algorithm design and problem-solving

Before you write a single line of code you should be able to say, in ordinary words, exactly what the program does — because that is the hard part.

Picture itGiving directions to someone who takes everything literally and cannot ask questions. "Turn left at the shop" is useless if there are two shops. An algorithm has to be that precise: every step unambiguous, every case covered, and a guaranteed end.

Decomposition and the three-part model

Break a problem into inputs, processes and outputs, then break each of those down further until every piece is small enough to write directly. Abstraction is deciding what to ignore — a train timetable app does not need to model the colour of the trains.

Pseudocode and flowcharts

A flowchart uses fixed shapes: an oval to start and stop, a parallelogram for input/output, a rectangle for a process, a diamond for a decision. Pseudocode is structured English. Both describe the same logic; the exam may ask you to convert between them.

The three control structures

Sequence — one step after another. Selection — IF...THEN...ELSE or CASE. Iteration — FOR (a known number of times), WHILE (test first, may run zero times), REPEAT...UNTIL (test last, always runs at least once). Every algorithm you will meet is built from these three.

Standard methods you should recognise

Totalling and counting. Finding maximum, minimum and average. Linear search — check each item in turn, works on unsorted data. Bubble sort — repeatedly compare and swap neighbours until a pass makes no swaps.

Testing means trying to break it

Use normal data (expected values), abnormal data (wrong type or out of range, should be rejected), extreme data (the largest and smallest values that are still valid) and boundary data (the pair of values either side of the limit). A trace table follows each variable through each iteration and is how you find a logic error by hand.

The bit that catches people outBoundary and extreme data are not the same thing. If valid marks are 0 to 100, the extreme data is 0 and 100. The boundary data is the pairs −1 and 0, and 100 and 101 — testing exactly where accept turns into reject.

The grown-up words

What it meansWhat it is calledNote
Breaking a problem into smaller partsdecompositionInputs, processes, outputs
Ignoring detail that does not matterabstractionKeeps the model manageable
Structured English description of an algorithmpseudocodeNot a real language
Loop that tests before runningWHILE loopMay execute zero times
Loop that tests after runningREPEAT UNTILAlways runs at least once
Checking each item in turnlinear searchWorks on unsorted data
Repeatedly swapping neighboursbubble sortStops when a pass makes no swaps
Table following variables through a programtrace tableFinds logic errors by hand
Values just either side of a limitboundary dataTests where accept becomes reject

Check you have got it

Valid input is 1 to 12. Give one item each of normal, abnormal, extreme and boundary data.
Normal: 7. Abnormal: 'March' or 20. Extreme: 1 and 12. Boundary: 0 and 1, and 12 and 13.
When would a REPEAT UNTIL loop be a better choice than a WHILE loop?
When the body must run at least once before the condition can be tested — for example, asking the user for a password before checking whether it is correct.
Edvia Free Resources · Computer Science 2210 · Topic 7 — free to copy and share
Topic 8

Programming

Programming is turning your algorithm into instructions a machine will accept, and the machine is completely unforgiving about detail.

Picture itYou designed the recipe in the last chapter. Now you have to write it in a language where a missing comma means dinner does not happen. Nothing new is being invented here — the thinking was the algorithm. This is translation, plus a lot of care.

Data types must be chosen deliberately

Integer (whole numbers), real (decimals), char (one character), string (text), Boolean (TRUE/FALSE). Storing a phone number as an integer loses the leading zero; storing a price as an integer loses the pence. The type is a decision, not a formality.

Variables, constants and scope

A variable holds a value that can change; a constant holds one that must not. Declaring a value as a constant means one edit changes it everywhere and stops it being altered by accident.

Arrays store many values under one name

A one-dimensional array is a list — Marks[1] to Marks[30]. A two-dimensional array is a table with a row and a column index — Grid[3,5]. Arrays are what let a FOR loop process thirty students without thirty separate variables.

Procedures and functions build reusable blocks

A procedure carries out a task; a function carries out a task and returns a value. Both take parameters. They avoid repeated code, make programs readable, and let you test one piece at a time.

Validation and verification are different checks

Validation is automatic and checks the data is sensible: range, length, type, presence, format, check digit. Verification checks the data was entered accurately: double entry, or a visual check by a human. Validation cannot spot a correctly formatted wrong name; verification can.

The bit that catches people outA function returns a value; a procedure does not. If a question asks you to write something that calculates and gives back an average, it wants a function — writing a procedure that prints it instead misses the point of the question.

The grown-up words

What it meansWhat it is calledNote
Whole number data typeintegerNo decimal part
Number with a decimal partrealAlso called float
TRUE or FALSE valueBooleanUsed in conditions
Named store whose value can changevariableConstant cannot change
List of values under one nameone-dimensional arrayAccessed by index
Table of values with row and columntwo-dimensional arrayGrid[row, column]
Reusable block that returns a valuefunctionA procedure does not return
Value passed into a subroutineparameterMakes it reusable
Automatic check that data is sensiblevalidationRange, length, type, format
Check that data was entered accuratelyverificationDouble entry or visual check

Check you have got it

Why should a phone number be stored as a string rather than an integer?
Because a leading zero would be lost, the number may contain a + or spaces, and no arithmetic is ever performed on it.
Give a validation check and a verification check for a date of birth field.
Validation: a format check that it matches DD/MM/YYYY, or a range check that the year is sensible. Verification: asking the user to type it twice and comparing the entries.
Edvia Free Resources · Computer Science 2210 · Topic 8 — free to copy and share
Topic 9

Databases

A database is not a spreadsheet — it stores each fact once, in a structured way, so it can never disagree with itself.

Picture itA school stores every student's address in three separate spreadsheets. A family moves house and two get updated. Now the school has two different addresses for the same child and no way to tell which is right. A database solves that by storing the address once, in one place.

Tables, records and fields

A table holds data about one kind of thing. A record is one row — one student, one book. A field is one column — one property of that thing. Getting the table structure right is most of database design.

The primary key identifies a record uniquely

A primary key is a field whose value is different in every record — a student ID, an ISBN. It must never be blank and never repeat. A name is a poor key, because two people can share one.

Field types

Text/alphanumeric, character, Boolean, integer, real, date/time. Choosing correctly enables the right validation and the right sorting — dates stored as text sort alphabetically, which puts 10 January before 2 February.

Single-table versus relational

A single-table (flat file) database repeats data, wasting space and inviting inconsistency. A relational database splits it across linked tables, using a foreign key in one table to point at another table's primary key. Each fact is stored once, so it can only be right or wrong — never both.

SQL asks the questions

SELECT chooses the fields, FROM names the table, WHERE filters the rows, ORDER BY sorts the result, and SUM, COUNT and AVG summarise. So: SELECT Name, Mark FROM Results WHERE Mark > 50 ORDER BY Mark DESC.

The bit that catches people outIn SQL, text values need quotes and numbers do not: WHERE Surname = 'Khan' but WHERE Mark > 50. Getting this wrong is the most common way an otherwise correct query is thrown out.

The grown-up words

What it meansWhat it is calledNote
Structure holding data about one kind of thingtableRows and columns
One row of a tablerecordOne student, one book
One column of a tablefieldOne property
Field with a unique value in every recordprimary keyNever blank, never repeated
Field pointing at another table's primary keyforeign keyCreates the relationship
Database of linked tablesrelational databaseAvoids duplicated data
Language for querying a databaseSQLSELECT, FROM, WHERE, ORDER BY
Clause that filters which records are returnedWHEREText needs quotes

Check you have got it

Write SQL to list the title and author of every book published after 2010, newest first.
SELECT Title, Author FROM Books WHERE Year > 2010 ORDER BY Year DESC;
Give one reason a student's name is a poor choice of primary key.
Two students can have the same name, so the value would not be unique — and names can change, which a primary key should not.
Edvia Free Resources · Computer Science 2210 · Topic 9 — free to copy and share
Topic 10

Boolean logic

Every decision a computer makes comes down to a handful of gates that take 0s and 1s in and give a 0 or a 1 out.

Picture itTwo switches wired to one lamp. Wire them in series and the lamp needs both switches on — that is AND. Wire them in parallel and either one lights it — that is OR. Every processor in the world is millions of that idea, stacked.

The six gates

NOT inverts its single input. AND gives 1 only when all inputs are 1. OR gives 1 when at least one input is 1. NAND is AND then inverted. NOR is OR then inverted. XOR gives 1 when the inputs are different.

Truth tables list every possibility

With n inputs there are 2n rows — 2 inputs give 4 rows, 3 inputs give 8. Write the input combinations in a fixed counting order (000, 001, 010, ...) so you cannot miss one, then work out each gate's output column by column.

Reading a logic circuit

Work left to right. Label the output of each gate, build a column for it in your truth table, and feed those columns into the next gate. Never try to jump from inputs straight to the final output — that is where mistakes happen.

Logic expressions

Written as A AND B, A OR NOT B, and so on. You should be able to go in all three directions: circuit to expression, expression to truth table, and problem description to circuit.

Logic in real systems

A safety system might only start a machine when the guard is closed AND the operator presses start AND the emergency stop is NOT pressed. Writing the sentence out in those words first, then drawing it, is far more reliable than drawing first.

The bit that catches people outXOR is not the same as OR. OR gives 1 when at least one input is 1, including when both are. XOR gives 1 only when the inputs differ, so 1 XOR 1 = 0. Marking that row wrong costs a mark on nearly every logic question.

The grown-up words

What it meansWhat it is calledNote
Output is 1 only when all inputs are 1AND gateSeries switches
Output is 1 when at least one input is 1OR gateParallel switches
Inverts a single inputNOT gate1 becomes 0
AND followed by an inverterNAND gateOutput 0 only when all inputs 1
OR followed by an inverterNOR gateOutput 1 only when all inputs 0
Output is 1 when inputs differXOR gate1 XOR 1 = 0
Table of every input combinationtruth table2 to the power n rows
Statement written with AND, OR, NOTlogic expressionEquivalent to the circuit

Check you have got it

How many rows does a truth table with three inputs have, and why?
Eight. Each input can be 0 or 1, so there are 2³ = 8 different combinations.
Write a logic expression for: the alarm sounds when the door is open AND the system is armed, or when the panic button is pressed.
(Door AND Armed) OR Panic.
Edvia Free Resources · Computer Science 2210 · Topic 10 — free to copy and share

Like how this is taught?

Every handout starts with the idea in plain English and only then the formal version. That is how every class at Edvia College works — for two full years of Cambridge A Levels.

Apply to Edvia → WhatsApp Admissions