Understand and identify suitable primary keys

IGCSE Computer Science (0478) – Core Concepts and Syllabus Guide

1. Data Representation

  • Binary, Decimal & Hexadecimal
    • Base‑2 (binary) uses digits 0‑1.
    • Base‑10 (decimal) is the everyday number system.
    • Base‑16 (hexadecimal) groups four binary bits into one hex digit (0‑9, A‑F).
  • Two’s‑Complement (signed integers)

    To represent negative numbers, invert all bits and add 1.

    Example: –23 in 8‑bit two’s‑complement  
    23 = 00010111 → invert = 11101000 → add 1 = 11101001
  • Logical Shifts
    • << (left shift) multiplies by 2 for each position.
    • >> (right shift) divides by 2 (floor) for each position.
  • Text Representation
    CharacterASCII (8‑bit)Unicode (hex)
    A0100 0001U+0041
    a0110 0001U+0061
    U+20AC
  • Sound
    • Sample rate (e.g., 44 kHz) = 44 000 samples per second.
    • Bit depth (e.g., 16‑bit) determines dynamic range.
    • File size = sample rate × bit depth × channels × duration (seconds) ÷ 8.
  • Images
    • Resolution = width × height (pixels).
    • Colour depth = bits per pixel (e.g., 24‑bit = 16 777 216 colours).
    • Uncompressed size = width × height × colour‑depth ÷ 8 (bytes).

2. Data Storage & Compression

  • File‑size formula (uncompressed):
    Size (bytes) = (bits per unit × number of units) ÷ 8
  • Lossless compression – original data can be perfectly restored.
    • Run‑Length Encoding (RLE): stores the length of repeated symbols.
  • Lossy compression – some data is permanently discarded for smaller size.
    • JPEG for images, MP3 for audio.
  • Example calculation
    Original image: 800 KB  
    Lossless RLE reduces to 600 KB (25 % reduction)  
    Lossy JPEG reduces to 200 KB (75 % reduction)

3. Data Transmission

  • Packet structure (simplified)
    Header | Payload (data) | Trailer
    • Header contains source/destination addresses and control bits.
    • Trailer often holds error‑detection codes.
  • Switching techniques
    • Circuit switching – dedicated path for the duration of a call.
    • Packet switching – data broken into packets, each routed independently.
  • USB (Universal Serial Bus)
    • Hot‑plug, supports up to 5 Gbps (USB 3.0).
    • Power delivery up to 100 W (USB‑PD).
  • Error‑detection methods
    MethodHow it worksTypical use
    Parity bitAdds a single bit to make total 1‑bits even (or odd)Simple serial links
    ChecksumSum of all bytes; receiver recomputes and comparesInternet Protocol (IP)
    ARQ (Automatic Repeat Request)Receiver asks sender to resend corrupted packetsTCP
  • Encryption basics
    • Symmetric – same key for encryption & decryption (e.g., AES).
    • Asymmetric – public key encrypts, private key decrypts (e.g., RSA).
    • HTTPS uses asymmetric key exchange then symmetric encryption for the session.

4. Hardware

  • CPU – Central Processing Unit
    • Performs the Fetch‑Decode‑Execute (FDE) cycle.
    • Modern CPUs have multiple cores (independent processing units).
    • Each core contains a small, fast cache (L1/L2) to store recently used data.
  • Instruction set – the set of binary commands the CPU understands (e.g., ARM, x86).
  • Embedded systems – computers built into other devices.
    • Example: Raspberry Pi used in a weather‑station prototype.

5. Input/Output Devices & Sensors

  • Keyboard, mouse, touch screen, scanner, printer, speaker, microphone.
  • Common sensors and the type of data they produce
    SensorPhysical quantityData type
    Temperature sensorHeatNumeric (°C)
    AccelerometerAccelerationNumeric (m/s²)
    CameraLightImage (pixel matrix)
    MicrophoneSound pressureAudio sample
  • Scenario question – Choose the most suitable sensor to record the temperature inside a greenhouse and justify your choice.

6. Storage Hardware

  • Primary storage – volatile, fast, directly accessed by CPU (RAM, cache).
  • Secondary storage – non‑volatile, larger capacity (HDD, SSD, optical disc, magnetic tape).
  • Solid‑State Drive (SSD) – uses flash memory, no moving parts, faster access than HDD.
  • Virtual memory – uses part of secondary storage to extend RAM; page‑fault handling swaps pages in/out.
  • Cloud storage
    • Advantages: access from anywhere, automatic backup, scalability.
    • Disadvantages: dependence on internet, possible privacy/security concerns, ongoing cost.

7. Network Hardware

  • Network Interface Card (NIC) – provides a physical connection to a network.
  • MAC address – unique hardware identifier (48‑bit hexadecimal).
  • IP address – logical address used for routing (IPv4 = 32‑bit, IPv6 = 128‑bit).
  • Router – forwards packets between different networks; uses IP addresses.
  • IPv4 vs IPv6
    FeatureIPv4IPv6
    Address length32 bits (e.g., 192.168.0.1)128 bits (e.g., 2001:0db8:85a3::8a2e:0370:7334)
    Number of addresses≈ 4.3 billion≈ 3.4 × 10³⁸
    Header complexityVariable, includes checksumSimpler, no checksum

8. Software

  • System software – OS, device drivers, utilities; manages hardware resources.
  • Application software – programs that perform specific user‑oriented tasks (e.g., word processor, web browser).
  • Operating‑system functions
    • Process management, memory management, file system control, I/O handling, security.
  • Interrupts – signals that temporarily halt the CPU to service high‑priority events (e.g., keyboard press).
  • Programming language levels
    • Machine language (binary), assembly language, high‑level language (Python, Java).
  • Compilers vs. Interpreters
    AspectCompilerInterpreter
    TranslationWhole program → machine code before executionTranslates line‑by‑line at run‑time
    SpeedFaster after compilationSlower, but easier debugging
    Typical useC, C++Python, JavaScript
  • Integrated Development Environment (IDE) – combines editor, compiler/interpreter, debugger (e.g., Eclipse, VS Code).
  • Firmware – low‑level software stored in non‑volatile memory (e.g., BIOS/UEFI) that initializes hardware before the OS loads.

9. Databases – Primary Keys

9.1 What is a Primary Key?

A primary key is one field (or a combination of fields) that uniquely identifies every record in a table. Each table must have **exactly one** primary key, and the DBMS enforces uniqueness, non‑null, and stability rules.

9.2 Key Characteristics (Cambridge Syllabus Requirements)

  • Unique – no two records share the same key value.
  • Never NULL – every record must contain a value.
  • Stable – the value should not change over time.
  • Simple – preferably a single field; composite keys are used only when necessary.

9.3 Types of Primary Keys

  1. Natural key – an existing attribute (e.g., ISBN, National Insurance Number).
  2. Surrogate key – an artificial identifier, often an auto‑incrementing integer.
  3. Composite key – a combination of two or more fields when no single field is sufficient (e.g., (StudentID, CourseCode)).

9.4 Decision Checklist for Choosing a Primary Key

Criterion Why it matters (Cambridge focus) Good example Poor example
Uniqueness Ensures each record can be distinguished – essential for accurate retrieval and updates. StudentID (e.g., 20230045) FirstName
Non‑null Every record must have a value; NULL would break the uniqueness rule. Auto‑increment OrderNumber Optional PhoneNumber
Stability Key values should not need editing; changing a key can corrupt relationships. ISBN for books Address line (may change)
Simplicity Simple keys are faster to index, easier to join, and reduce storage overhead. Auto‑increment integer Combination of StreetName + HouseNumber

9.5 Natural vs. Surrogate Keys – When to Use Which?

Aspect Natural Key Surrogate Key
Source Existing data (ISBN, NationalID) System‑generated (auto‑increment integer)
Stability May change if the real‑world identifier changes Never changes once created
Length & Performance Often longer, can enlarge indexes Short, optimal for indexing
Sensitivity May expose personal data (e.g., NationalID) Opaque, no privacy concerns

9.6 When to Use Composite Keys

A composite key is appropriate when no single field can guarantee uniqueness.

Example – CourseRegistrations table

FieldData TypeNotes
StudentIDINTEGERFK to Students
CourseCodeVARCHAR(10)FK to Courses
RegistrationDateDATEAdditional attribute

Primary key: (StudentID, CourseCode) – a student cannot enrol in the same course more than once.

9.7 Common Pitfalls (Cambridge “What to avoid” list)

  • Using mutable data (phone number, address) as a primary key.
  • Choosing a field that can contain duplicate values (first name, city).
  • Relying on long natural keys that slow searches and joins.
  • Forgetting to enforce NOT NULL on the primary‑key column.
  • Creating a composite key that includes a field that may be NULL.

9.8 Sample Tables – Evaluating Potential Primary Keys

Students table

FieldData TypeCan it be a Primary Key?
StudentIDINTEGER (auto‑increment)Yes – unique, never null, stable
NationalIDVARCHAR(12)Yes – natural, but consider privacy
EmailVARCHAR(50)No – can change, may not be unique
FirstName, LastNameVARCHAR(30)No – not unique

LibraryBooks table

FieldData TypeCan it be a Primary Key?
ISBNVARCHAR(13)Yes – natural, unique, stable
TitleVARCHAR(100)No – duplicates possible
AccessionNumberINTEGER (auto‑increment)Yes – surrogate, useful if ISBN missing

9.9 Practice Questions (Exam‑style)

  1. Identify a suitable primary key for a LibraryBooks table that stores ISBN, Title, Author, and PublicationYear. Explain your choice.
  2. Explain why an auto‑incrementing OrderID is often preferred over using a customer's email address as the primary key in an Orders table.
  3. Given a table EmployeeProjects with fields EmployeeID, ProjectID, and HoursWorked, propose a primary key and justify your decision.
  4. For the CourseRegistrations example, rewrite the table using a surrogate key RegID. Discuss the advantages and disadvantages of this change.

10. Alignment with the Cambridge IGCSE (0478) Syllabus

  • All sections map directly to the syllabus topics (Data Representation, Data Transmission, Hardware, Software, and Database Design).
  • Key terminology (e.g., “primary key”, “two’s‑complement”, “virtual memory”) matches the exact wording used in the Cambridge specification.
  • Practice questions reflect the 1‑mark and 2‑mark style of Paper 2, preparing students for both short‑answer and extended‑response items.
  • Tables and examples provide the visual cues required for the “recognise and interpret” components of the exam.
Suggested diagram: An Entity‑Relationship diagram highlighting a primary key (underlined) and foreign‑key relationships between Students, Courses and CourseRegistrations.

Create an account or Login to take a Quiz

45 views
0 improvement suggestions

Log in to suggest improvements to this note.