SENIOR SCHOOL · GRADE 11

Computer Studies Student Notes

Grade 11 Computer Studies student notes organised by curriculum strand and sub-strand. Explore Strand 1.0: Foundation of Computer Studies; Strand 2.0: Computer Networking; Strand 3.0: Software Development online.

3 curriculum strands or themes11 sub-strands2026 Edition
On this page Strands and sub-strands
  1. Strand 1.0: Foundation of Computer Studies
    1. 1.1 Data Representation
    2. 1.2 Binary Arithmetic Operations
    3. 1.3 Logic Gates
    4. 1.4 Logic Circuits
  2. Strand 2.0: Computer Networking
    1. 2.1 Computer Network Standards and Protocols
    2. 2.2 Network Security
  3. Strand 3.0: Software Development
    1. 3.1 Object Oriented Programming (OOP) Concepts
    2. 3.2 Object Oriented Programming Implementation
    3. 3.3 Relational Database Fundamentals
    4. 3.4 Structured Query Language (SQL)
    5. 3.5 Web Development Fundamentals

About These Notes

This document is a complete set of study notes for Computer Studies in Grade 11 of Kenya’s Senior School. It follows the KICD Senior School Curriculum Design for Computer Studies, Grade 11 (draft), and covers every strand and sub-strand in that design. The notes explain each topic in clear, simple English and are illustrated with thirty-three diagrams, circuits, tables and screen examples drawn specially for these notes, with worked examples, tested Python, SQL, HTML and PHP code, and practice questions.

Who these notes are for

What the document covers

The notes are organised into the three strands of the curriculum, with eleven sub-strands in total, followed by a quick revision sheet.

Strand

Sub-strands

1.0 Foundation of Computer Studies

1.1 Data Representation · 1.2 Binary Arithmetic Operations · 1.3 Logic Gates · 1.4 Logic Circuits

2.0 Computer Networking

2.1 Network Standards and Protocols · 2.2 Network Security

3.0 Software Development

3.1 OOP Concepts · 3.2 OOP Implementation · 3.3 Relational Database Fundamentals · 3.4 SQL · 3.5 Web Development Fundamentals

How each sub-strand is laid out

How to use these notes

  1. Read the learning outcomes first, then study the explanations together with the figures.
  2. Attempt each practice set on your own, then check the answers and revise with the Quick Revision Sheet.

Copyright and Ownership

© 2026 Tr Boen. All rights reserved.

Owner: Tr Boen

Website: www.cbcteacher.co.ke

Telephone: 0722591434

These study notes are the property of Tr Boen. The copyright covers the whole document, including the explanations, tables, figures, illustrations, practice questions, answers, design and layout, and the Tr Boen logo. The work is protected under the copyright laws of Kenya and international copyright agreements.

Permitted use

Not permitted without written permission from Tr Boen

Requests for permission

To request permission, order more copies, or ask about licences for a whole school, please contact Tr Boen on 0722591434 or visit www.cbcteacher.co.ke. Please also report any unauthorised copies through the same contacts.

Curriculum acknowledgement

The structure, strands, sub-strands, learning outcomes and key inquiry questions follow the KICD Senior School Curriculum Design, Computer Studies Grade 11 (draft). The curriculum design remains the property of the Kenya Institute of Curriculum Development (KICD). These notes are an independent study aid written by Tr Boen; they are not an official KICD publication.

Strand 1.0: Foundation of Computer Studies

FOUNDATION

1.1 Data Representation

You should be able to: identify the units used to represent data in computers; explain the representation of different types of data in computers; describe the types of number systems used in computers (decimal, binary, octal and hexadecimal); convert numbers between different number systems; represent data using different coding schemes (ASCII, EBCDIC and BCD); and acknowledge the importance of data representation in computers.

Why computers use binary

A computer is made of millions of tiny electronic switches called transistors. A switch has only two states: off and on. These two states are written as 0 and 1, so every piece of data inside a computer (a letter, a photo, a song or a video) is stored as a pattern of 0s and 1s. This is called binary representation. A single 0 or 1 is called a bit (short for binary digit).

Data is raw facts and figures, such as the marks 45, 67 and 82. Information is data that has been processed so that it has meaning, such as "The class average is 64.7".

Units of data measurement

Bits are too small to count files, so they are grouped into larger units. A group of 8 bits is a byte, and a byte can store one character such as the letter A. A group of 4 bits is called a nibble.

Figure 1.1: Units of data measurement, each 1,024 times larger than the one before

Figure 1.1: Units of data measurement, each 1,024 times larger than the one before

Unit

Symbol

Size

Typical example

Bit

b

0 or 1

One on/off signal

Byte

B

8 bits

One character, e.g. "A"

Kilobyte

KB

1,024 bytes

A short text message or a small email

Megabyte

MB

1,024 KB

A photo or a 3-minute song

Gigabyte

GB

1,024 MB

A movie or a phone's memory

Terabyte

TB

1,024 GB

A large hard disk

Units are used in three main ways:

DO NOT CONFUSE B AND B

A small b means bit and a capital B means byte. A 100 Mbps connection moves 100 megabits per second, which is only about 12.5 megabytes per second (100 ÷ 8).

Types of data

Type of data

How it is represented

Text

Each character is given a binary code, for example the letter A is 01000001 in ASCII

Numbers

Stored directly as binary numbers

Images

A grid of tiny dots called pixels; each pixel's colour is stored as a binary number

Audio

The sound wave is measured thousands of times a second (sampling) and each measurement is stored as a binary number

Video

A fast series of images (frames) together with an audio track

Number systems

A number system is a way of writing numbers using a set of digits. Its base (or radix) is the number of different digits it uses. In every system the position of a digit decides its value (positional value): each place is worth the base raised to a power.

Figure 1.2: The four number systems used in computing

Figure 1.2: The four number systems used in computing

System

Base

Digits used

Where it is used

Decimal

10

0 to 9

Everyday counting and money

Binary

2

0 and 1

Inside the computer's circuits

Octal

8

0 to 7

Short form of binary (groups of 3 bits), e.g. Unix file permissions

Hexadecimal

16

0 to 9 and A to F

Short form of binary (groups of 4 bits), e.g. colour codes and memory addresses

In hexadecimal the letters stand for numbers above 9: A = 10, B = 11, C = 12, D = 13, E = 14, F = 15.

Decimal

Binary

Octal

Hexadecimal

0

0000

0

0

5

0101

5

5

8

1000

10

8

10

1010

12

A

15

1111

17

F

16

10000

20

10

Converting between number systems

1. Decimal to binary (repeated division by 2). Divide the number by 2 again and again, writing down each remainder. Stop when the quotient is 0. Read the remainders from the bottom to the top.

Figure 1.3: Converting 25 (decimal) to binary by repeated division

Figure 1.3: Converting 25 (decimal) to binary by repeated division

So 25 in decimal is 11001 in binary. The same method works for other bases: divide by 8 for octal and by 16 for hexadecimal.

WORKED EXAMPLES

156 to octal: 156 ÷ 8 = 19 remainder 4; 19 ÷ 8 = 2 remainder 3; 2 ÷ 8 = 0 remainder 2. Reading upwards gives 234 in octal.

500 to hexadecimal: 500 ÷ 16 = 31 remainder 4; 31 ÷ 16 = 1 remainder 15 (F); 1 ÷ 16 = 0 remainder 1. Reading upwards gives 1F4 in hexadecimal.

2. Binary, octal or hexadecimal to decimal (add up the positional values). Multiply each digit by the value of its place and add the results.

WORKED EXAMPLES

101101 (binary) to decimal: the place values from the right are 1, 2, 4, 8, 16, 32. So 1×32 + 0×16 + 1×8 + 1×4 + 0×2 + 1×1 = 32 + 8 + 4 + 1 = 45.

2B (hexadecimal) to decimal: 2×16 + 11×1 = 32 + 11 = 43.

234 (octal) to decimal: 2×64 + 3×8 + 4×1 = 128 + 24 + 4 = 156.

3. Binary to octal and hexadecimal (grouping). Because 8 = 2³ and 16 = 2⁴, binary can be converted by grouping bits. For octal group the bits in threes from the right. For hexadecimal group them in fours. Add zeros at the left if needed.

Conversion

Working

Answer

101110011 to octal

101, 110, 011 = 5, 6, 3

563

11010111 to hexadecimal

1101, 0111 = D, 7

D7

745 (octal) to binary

7 = 111, 4 = 100, 5 = 101

111100101

3AF (hex) to binary

3 = 0011, A = 1010, F = 1111

001110101111

To convert between octal and hexadecimal, go through binary. For example, 345 (octal) = 011 100 101 = 0 1110 0101 = E5 (hexadecimal).

Coding schemes

A coding scheme is an agreed table that gives every character (letter, digit or symbol) its own binary code, so that different computers can exchange text.

Figure 1.4: Three coding schemes and the code for the letter A

Figure 1.4: Three coding schemes and the code for the letter A

Scheme

Full name

Bits per character

Notes

ASCII

American Standard Code for Information Interchange

7 bits (128 characters); extended ASCII uses 8 bits (256)

Most common on personal computers; A = 65, a = 97, 0 = 48

EBCDIC

Extended Binary Coded Decimal Interchange Code

8 bits (256 characters)

Used on IBM mainframe computers; A = C1 in hexadecimal

BCD

Binary Coded Decimal

4 bits for each decimal digit

Used where exact decimal digits matter, such as calculators and digital clocks

Encoding the word CAT in ASCII: C = 67 = 01000011, A = 65 = 01000001, T = 84 = 01010100. So CAT is stored as 01000011 01000001 01010100, which is 3 bytes.

Encoding 59 in BCD: 5 = 0101 and 9 = 1001, so 59 is stored as 0101 1001.

UNICODE

ASCII cannot represent every language. Unicode (for example UTF-8) uses more bits so that it can store the letters of Kiswahili, Arabic, Chinese and emojis in the same file.

Size of images and sound

Importance of data representation

Community activity

Design a short poster or leaflet for your school community that explains bits and bytes and the unit of memory in a phone, and show how a name such as "TOM" is written in binary using ASCII.

✎ Practice: Data representation

  1. Define a bit and a byte.
  2. How many bytes are there in 2 KB?
  3. State two reasons why computers use the binary system.
  4. Convert 37 (decimal) to binary.
  5. Convert 1101101 (binary) to decimal.
  6. Convert 255 (decimal) to hexadecimal.
  7. Convert 10110110 (binary) to hexadecimal.
  8. Write the word HI in ASCII binary (H = 72, I = 73).
  9. A photo is 1,000 pixels wide and 500 pixels high with 8 bits per pixel. Calculate its size in bytes.

ANSWERS

  1. A bit is a single binary digit, 0 or 1. A byte is a group of 8 bits.
  2. 2 × 1,024 = 2,048 bytes.
  3. Electronic circuits have two states (on and off); two-state circuits are cheap, fast and reliable and are easy to design.
  4. 37 ÷ 2 = 18 r 1; 18 ÷ 2 = 9 r 0; 9 ÷ 2 = 4 r 1; 4 ÷ 2 = 2 r 0; 2 ÷ 2 = 1 r 0; 1 ÷ 2 = 0 r 1. Reading upwards: 100101.
  5. 64 + 32 + 0 + 8 + 4 + 0 + 1 = 109.
  6. 255 ÷ 16 = 15 r 15; 15 ÷ 16 = 0 r 15. So FF.
  7. 1011 = B and 0110 = 6, so B6.
  8. H = 72 = 01001000 and I = 73 = 01001001. HI = 01001000 01001001.
  9. 1,000 × 500 × 8 ÷ 8 = 500,000 bytes (about 488 KB).

Key inquiry questions: Why are different data units important in computing? How are different types of data represented in computer systems?

FOUNDATION

1.2 Binary Arithmetic Operations

You should be able to: explain the fundamental concepts of binary arithmetic operations and their significance in computing; represent signed and unsigned binary numbers in one's and two's complement; perform arithmetic operations on unsigned and signed binary numbers; and appreciate the use of binary operations in computers.

Why binary arithmetic matters

Inside the processor, the Arithmetic and Logic Unit (ALU) adds, subtracts and compares numbers using binary arithmetic. Every calculation you do on a calculator, a phone or a school computer, from adding marks to working out a bank balance, is finally done with 0s and 1s.

Binary addition

Binary addition follows four simple rules.

Addition

Result

Carry

0 + 0

0

0

0 + 1

1

0

1 + 0

1

0

1 + 1

0

1 (because 1 + 1 = 10 in binary)

When three 1s meet in a column (1 + 1 + carry 1), the result is 1 with a carry of 1.

Figure 1.5: Adding 1011 and 0110, working from right to left

Figure 1.5: Adding 1011 and 0110, working from right to left

WORKED EXAMPLE

Add 1011 and 0110. Column 1: 1 + 0 = 1. Column 2: 1 + 1 = 0 carry 1. Column 3: 0 + 1 + 1 = 0 carry 1. Column 4: 1 + 0 + 1 = 0 carry 1. The last carry becomes a new digit: 10001.

Check in decimal: 11 + 6 = 17, and 10001 = 16 + 1 = 17. ✓

Another example: 1101 + 1011 = 11000 (13 + 11 = 24).

Binary subtraction

Subtraction

Result

0 − 0

0

1 − 0

1

1 − 1

0

0 − 1

1 with a borrow of 1 from the next column

Example: 1101 − 0110 = 0111 (13 − 6 = 7).

Subtraction by borrowing is slow for a computer, so computers subtract by adding the complement of a number. This also solves the problem of writing negative numbers.

Unsigned and signed binary numbers

Three methods are used to represent signed numbers. The examples use 8 bits.

Method

How it works

+5

−5

8-bit range

Sign and magnitude

Sign bit, then the size of the number

00000101

10000101

−127 to +127

One's complement

Negative number = flip every bit of the positive number

00000101

11111010

−127 to +127

Two's complement

Negative number = one's complement + 1

00000101

11111011

−128 to +127

Two's complement is the method most computers use because it has only one zero and subtraction becomes ordinary addition.

Figure 1.6: Finding the two's complement of 5 to represent −5

Figure 1.6: Finding the two's complement of 5 to represent −5

To read a negative two's complement number back: flip the bits, add 1 and put a minus sign. For example 11111011 becomes 00000100, plus 1 gives 00000101 = 5, so the number is −5.

Subtraction using two's complement

To calculate A − B, find the two's complement of B and add it to A. If there is a carry out of the leftmost bit, discard it.

WORKED EXAMPLE: 9 − 5 IN 8 BITS

9 = 00001001 and 5 = 00000101. The two's complement of 5 is 11111011 (this is −5).

Add: 00001001 + 11111011 = 1 00000100. Discard the carry (the leftmost 1). The answer is 00000100 = 4. ✓

Subtraction using one's complement

Find the one's complement of B and add it to A. If there is a carry out of the leftmost bit, add it back to the answer (the end-around carry).

WORKED EXAMPLE: 9 − 5 USING ONE'S COMPLEMENT

9 = 00001001 and one's complement of 5 = 11111010. Add: 00001001 + 11111010 = 1 00000011. Add the end-around carry: 00000011 + 1 = 00000100 = 4. ✓

Overflow

Overflow happens when the answer is too large for the number of bits available. In 4 bits, 1111 + 0001 = 10000 needs 5 bits, so the leftmost 1 is lost and the computer wrongly gets 0000. Programmers avoid this by using more bits.

Where binary operations are used

Community activity

Sensitise your peers in a computer club about binary arithmetic by running a short quiz: each member adds two binary numbers and checks the answer in decimal.

✎ Practice: Binary arithmetic

  1. Add 1010 and 0111.
  2. Add 1111 and 0011.
  3. Subtract 1001 from 1110.
  4. Write −6 in 8-bit sign and magnitude.
  5. Write −6 in 8-bit one's complement.
  6. Write −6 in 8-bit two's complement.
  7. Use two's complement to work out 12 − 7 in 8 bits.
  8. State the range of numbers that can be stored in 8 bits using two's complement.

ANSWERS

  1. 1010 + 0111 = 10001 (10 + 7 = 17).
  2. 1111 + 0011 = 10010 (15 + 3 = 18).
  3. 1110 − 1001 = 0101 (14 − 9 = 5).
  4. 6 = 00000110, so −6 = 10000110.
  5. Flip 00000110 to get 11111001.
  6. One's complement 11111001, add 1 to get 11111010.
  7. 12 = 00001100. 7 = 00000111, so −7 = 11111001. Add: 00001100 + 11111001 = 1 00000101. Discard the carry. Answer 00000101 = 5.
  8. −128 to +127.

Key inquiry questions: What are the practical applications of binary arithmetic operations in real-life situations? How are signed and unsigned binary numbers in one's and two's complement represented in computing?

FOUNDATION

1.3 Logic Gates

You should be able to: describe logic gates as used in computer systems; create a truth table from logic gates; analyse truth tables to predict the outputs; derive a Boolean expression from a truth table; and appreciate the use of logic gates in real-life situations.

What is a logic gate?

A logic gate is a small electronic circuit that takes one or more binary inputs (0 or 1) and produces one binary output according to a fixed rule. Logic gates are the building blocks of digital circuits. A processor contains billions of them. In logic, 1 means true (high voltage, switch on) and 0 means false (low voltage, switch off).

A truth table lists every possible combination of inputs and the output for each. A gate with n inputs has 2ⁿ rows, so a two-input gate has 4 rows and a three-input circuit has 8 rows.

The seven basic gates

Figure 1.7: Symbols of the seven basic logic gates

Figure 1.7: Symbols of the seven basic logic gates

Gate

Boolean expression

Rule in words

AND

A · B

Output is 1 only when both inputs are 1

OR

A + B

Output is 1 when at least one input is 1

NOT

Ā (or A′)

Output is the opposite of the input

NAND

(A · B)′

NOT AND: output is 0 only when both inputs are 1

NOR

(A + B)′

NOT OR: output is 1 only when both inputs are 0

XOR

A ⊕ B

Output is 1 when the inputs are different

XNOR

(A ⊕ B)′

Output is 1 when the inputs are the same

Truth tables of the gates

A

B

AND

OR

NAND

NOR

XOR

XNOR

0

0

0

0

1

1

0

1

0

1

0

1

1

0

1

0

1

0

0

1

1

0

1

0

1

1

1

1

0

0

0

1

The NOT gate has one input: when A = 0 the output is 1, and when A = 1 the output is 0.

REAL-LIFE MODELS OF GATES

AND: two switches in series with a bulb: the bulb lights only when both are on. OR: two switches in parallel: the bulb lights when either one is on. NOT: a security light that is on when the daylight sensor is off.

Universal gates. NAND and NOR are called universal gates because any other gate can be built using only NAND gates or only NOR gates. This makes chips cheaper to manufacture.

Deriving a Boolean expression from a truth table

Follow these steps (the sum of products method):

  1. Pick every row where the output is 1.
  2. For each such row write a product (AND) term. A variable that is 1 is written as it is; a variable that is 0 is written with a bar (NOT).
  3. Join the terms with OR (+).

A

B

Output F

0

0

0

0

1

1

1

0

1

1

1

0

WORKED EXAMPLE

Output F is 1 in row 2 (A = 0, B = 1) and row 3 (A = 1, B = 0). Row 2 gives Ā · B and row 3 gives A · B̄. So F = Ā·B + A·B̄, which is the XOR function (A ⊕ B).

Predicting outputs from a truth table

Study the table, find which gate rule it follows, and then predict the output for new inputs. For example, if a table gives output 1 for inputs (0,0) and (1,1) only, it is an XNOR gate, so inputs (1,1) will give 1 and inputs (0,1) will give 0.

Basic Boolean rules

Rule

Meaning

A · 0 = 0 and A · 1 = A

AND with 0 gives 0; AND with 1 keeps A

A + 0 = A and A + 1 = 1

OR with 0 keeps A; OR with 1 gives 1

A · A = A and A + A = A

Repeating a signal changes nothing

A · Ā = 0 and A + Ā = 1

A signal and its opposite

Modelling gates with local materials

Learners can model gates with a battery (cell), connecting wires, switches (or a metal paper clip and a board) and a small bulb. Two switches in series model AND and two switches in parallel model OR. Safety: use small cells only and never connect to mains electricity.

Logic gates in real life

✎ Practice: Logic gates

  1. Define a logic gate and a truth table.
  2. How many rows has the truth table of a gate with three inputs?
  3. State the output of (a) an AND gate with inputs 1 and 0, (b) a NOR gate with inputs 0 and 0, (c) an XOR gate with inputs 1 and 1.
  4. Write the Boolean expression for a NAND gate.
  5. Why are NAND and NOR called universal gates?
  6. A truth table has output 1 only when A = 1 and B = 0. Write its Boolean expression.
  7. Describe how you would model an OR gate with a cell, a bulb and two switches.

ANSWERS

  1. A logic gate is an electronic circuit that gives one binary output from one or more binary inputs. A truth table lists all input combinations and the output for each.
  2. 2³ = 8 rows.
  3. (a) 0; (b) 1; (c) 0.
  4. (A · B)′, which means NOT (A AND B).
  5. Any other gate can be built using only NAND gates, or only NOR gates.
  6. F = A · B̄.
  7. Connect the two switches in parallel, and connect them in a loop with the cell and the bulb. Closing either switch (or both) lights the bulb.

Key inquiry questions: What is the significance of logic gates in digital devices? How do logic gates form the building blocks of digital devices?

FOUNDATION

1.4 Logic Circuits

You should be able to: explain the relationship between logic gates and logic circuits; combine logic gates to form logic circuits; derive Boolean expressions from logic circuits; and acknowledge the application of logic circuits in daily-life situations.

From gates to circuits

A logic circuit is made by joining two or more logic gates so that the output of one gate becomes the input of another. Gates are the building blocks, and circuits are the structures built from them. Logic circuits are used in every digital device, from a calculator to a mobile phone.

Combining gates

Figure 1.8: A logic circuit for Q = (A AND B) OR C

Figure 1.8: A logic circuit for Q = (A AND B) OR C

To read a circuit, work from the inputs towards the output and write the expression at the output of every gate.

WORKED EXAMPLE

In Figure 1.8 the AND gate has inputs A and B, so its output is A · B. This output goes to the OR gate together with C. So the final output is Q = A · B + C.

Truth table of a circuit

For three inputs we need 2³ = 8 rows. Work out the output of each gate in turn.

A

B

C

A · B

Q = A · B + C

0

0

0

0

0

0

0

1

0

1

0

1

0

0

0

0

1

1

0

1

1

0

0

0

0

1

0

1

0

1

1

1

0

1

1

1

1

1

1

1

Drawing a circuit from a Boolean expression

  1. Find the operations in the expression and the order in which they are done (brackets first).
  2. Draw one gate for each operation.
  3. Connect the output of each inner gate to the input of the next gate.

For example, X = (A + B) · C̄ needs an OR gate for A + B, a NOT gate for C̄, and an AND gate that combines them.

Generating Boolean expressions from circuits and back

Applications of logic circuits

Figure 1.9: A burglar alarm circuit: Alarm = (Door OR Window) AND Armed

Figure 1.9: A burglar alarm circuit: Alarm = (Door OR Window) AND Armed

Application

Logic idea

Burglar alarm

The alarm sounds if the system is armed AND (the door OR a window is opened)

Simple switches

A two-way staircase switch uses XOR: the bulb changes state whenever either switch is moved

Street lights

A light sensor feeds a NOT gate: when there is no daylight (0), the light turns ON

Emergency response

A fire alarm sounds when the smoke sensor OR the heat sensor is on

Digital devices

Calculators and computers use circuits that add, compare and store binary numbers

Simulating circuits

A logic circuit can be tested before it is built: draw it in free circuit simulation software or an online simulator, set the inputs, and compare the output with the truth table. A physical model can be made with switches, a cell, wires and a bulb.

Community activity

Make a short video or poster for your community showing how logic circuits work in a burglar alarm and a street light, and explain why they make homes safer.

✎ Practice: Logic circuits

  1. Define a logic circuit.
  2. Write the Boolean expression for a circuit in which A and B go into an OR gate, and the output and C go into an AND gate.
  3. Complete a truth table for Q = A · B + C when A = 1, B = 0, C = 0.
  4. Draw (in words) a circuit for X = (A + B) · C̄.
  5. Describe a logic circuit for a classroom fire alarm that sounds if smoke or heat is detected.
  6. State two uses of logic circuits in daily life.

ANSWERS

  1. A logic circuit is a combination of logic gates in which the output of one gate is the input of another.
  2. Q = (A + B) · C.
  3. A · B = 0, so Q = 0 + 0 = 0.
  4. An OR gate with inputs A and B; a NOT gate with input C; an AND gate that takes the output of the OR gate and the output of the NOT gate. Its output is X.
  5. Join the smoke sensor and the heat sensor to the two inputs of an OR gate. The OR output switches on the alarm bell.
  6. Any two: burglar alarms; street lights; staircase switches; emergency fire alarms; calculators and computers.

Key inquiry questions: How are logic circuits used in digital devices? What are the real-life applications of logic circuits?

Computer Studies · Grade 11

Strand 2.0: Computer Networking

NETWORKING

2.1 Computer Network Standards and Protocols

You should be able to: identify the standards used in computer networking; describe the protocols in the Transmission Control Protocol/Internet Protocol (TCP/IP) model; explain encapsulation and decapsulation of data across different layers of the network; configure a computer network to establish communication; and appreciate the use of network standards and protocols in computer networking.

Standards and protocols

A computer network is a group of computers and devices joined together so that they can share data and resources such as files, printers and an internet connection.

Without standards and protocols, a phone made in one country could not open a website hosted in another. They make communication possible, reliable and secure.

Functions of protocols: addressing devices; breaking data into small parts and putting it back together; detecting and correcting errors; controlling the speed of sending (flow control); finding the best route; and protecting data.

Reference models

A network model divides communication into layers. Each layer does one job and serves the layer above it. This makes networks easier to design, test and repair.

The OSI model (Open Systems Interconnection) was developed by ISO. It has seven layers. A memory aid from the top: All People Seem To Need Data Processing.

Layer

Name

Main job

7

Application

Gives network services to the user's programs (web, email)

6

Presentation

Formats, compresses and encrypts data

5

Session

Opens, manages and closes a conversation between devices

4

Transport

Splits data into segments and delivers it reliably

3

Network

Adds IP addresses and chooses the route

2

Data link

Moves frames between devices on one network using MAC addresses

1

Physical

Sends the bits as electrical, light or radio signals

The TCP/IP model is the practical model used on the internet. It has four layers.

Figure 2.1: The four layers of the TCP/IP model with example protocols

Figure 2.1: The four layers of the TCP/IP model with example protocols

TCP/IP layer

Protocols and devices

Job

Application

HTTP, HTTPS, SMTP, FTP, DNS

Lets programs such as a browser or email app use the network

Transport

TCP, UDP

Breaks data into segments, controls delivery

Internet

IPv4, IPv6

Adds IP addresses and routes packets (done by routers)

Network access

Ethernet, Wi-Fi, MAC addresses

Sends frames over the cable or radio link

Comparing OSI and TCP/IP

Figure 2.2: How the seven OSI layers map onto the four TCP/IP layers

Figure 2.2: How the seven OSI layers map onto the four TCP/IP layers

Feature

OSI model

TCP/IP model

Number of layers

7

4

Developed by

ISO (a reference model)

US Department of Defense; used on the internet

Use

Mainly for teaching and troubleshooting

The model that real networks use

Similarities: both models use layers, both have application, transport and network functions, and both rely on standard protocols so that different devices can communicate.

Common protocols

Protocol

Full name

Purpose

HTTP / HTTPS

Hypertext Transfer Protocol (Secure)

Loading web pages; HTTPS encrypts the data

SMTP

Simple Mail Transfer Protocol

Sending email

FTP

File Transfer Protocol

Uploading and downloading files

DNS

Domain Name System

Changes a name such as www.cbcteacher.co.ke into an IP address

TCP

Transmission Control Protocol

Reliable delivery: checks that every segment arrives and in order

UDP

User Datagram Protocol

Fast delivery with no checking; used in video calls and games

IP

Internet Protocol

Addresses and routes packets (IPv4 or IPv6)

MAC

Media Access Control

Hardware address of the network card on the local network

IP addresses

Every device on a network needs an IP address. IPv4 addresses have 32 bits, written as four numbers (called octets) between 0 and 255, separated by dots, for example 192.168.1.10. Because there are not enough IPv4 addresses, IPv6 uses 128 bits written in hexadecimal.

Figure 2.3: Structure of an IPv4 address and subnet mask

Figure 2.3: Structure of an IPv4 address and subnet mask

Encapsulation and decapsulation

When you send a message, each layer adds its own header (extra control information) around the data. This is encapsulation. At the receiving computer the layers remove the headers in reverse order. This is decapsulation.

Figure 2.4: Encapsulation at the sender and decapsulation at the receiver

Figure 2.4: Encapsulation at the sender and decapsulation at the receiver

Layer

Unit of data

What is added

Application

Data

The message itself

Transport

Segment

TCP/UDP header with port numbers and sequence numbers

Internet

Packet

IP header with source and destination IP addresses

Network access

Frame

MAC addresses and an error-checking trailer, then sent as bits

Configuring a network

Learners can use real devices or a network simulator (such as Cisco Packet Tracer or other free simulators).

Task 1: Build one LAN. Connect three computers to a switch using straight-through cables. Give each computer an IP address on the same network:

Device

IP address

Subnet mask

Default gateway

Computer 1

192.168.1.10

255.255.255.0

192.168.1.1

Computer 2

192.168.1.11

255.255.255.0

192.168.1.1

Computer 3

192.168.1.12

255.255.255.0

192.168.1.1

Task 2: Connect two LANs with a router. Give the second LAN the network 192.168.2.0 and give each router interface the gateway address of its LAN (192.168.1.1 and 192.168.2.1).

Figure 2.5: Two local area networks connected by a router

Figure 2.5: Two local area networks connected by a router

Task 3: Test and troubleshoot. Use the ping command to test connectivity. A successful ping shows replies from the other computer.

TESTING CONNECTIVITY FROM COMPUTER 1

C:\> ping 192.168.2.10

Reply from 192.168.2.10: bytes=32 time=1ms TTL=127

Reply from 192.168.2.10: bytes=32 time=1ms TTL=127

If the ping fails ("Request timed out"), check in this order: (1) cables and lights, (2) IP address and subnet mask are on the same network, (3) the default gateway is correct, (4) the router interfaces are switched on, (5) firewalls are not blocking.

Task 4: Share resources. Share a folder or printer on one computer and open it from another. Always give access only to the people who need it, so that the network stays safe.

Community activity

Prepare a poster, short video or leaflet for community members explaining how to share a printer or files in a small network and why standards help devices to work together.

✎ Practice: Network standards and protocols

  1. Distinguish between a network standard and a network protocol.
  2. Name the four layers of the TCP/IP model.
  3. State the job of (a) DNS, (b) SMTP, (c) TCP.
  4. State two differences between the OSI and TCP/IP models.
  5. Explain the term encapsulation.
  6. Computer 1 has IP 192.168.1.10 and Computer 2 has IP 192.168.2.10 with mask 255.255.255.0. Can they communicate without a router? Explain.
  7. A ping to another computer in the same LAN fails. List three things you would check.

ANSWERS

  1. A standard is an agreed technical specification so that devices work together (e.g. Wi-Fi 802.11). A protocol is an agreed set of rules for sending and receiving data (e.g. HTTP).
  2. Application, Transport, Internet and Network access.
  3. (a) DNS changes a domain name into an IP address. (b) SMTP sends email. (c) TCP delivers data reliably and in order.
  4. OSI has 7 layers but TCP/IP has 4; OSI is a reference model used for teaching, while TCP/IP is the model used on the internet.
  5. Encapsulation is the process in which each layer adds its own header to the data as it moves down the layers before it is sent.
  6. No. They are on different networks (192.168.1.x and 192.168.2.x), so a router is needed to pass packets between them.
  7. Any three: network cable and lights; IP address and subnet mask; default gateway; whether the device is switched on; firewall settings.

Key inquiry questions: What is the significance of standards in computer networking? How do network protocols enable online activities?

NETWORKING

2.2 Network Security

You should be able to: describe security principles in computer networking; analyse security threats to a computer network; explore control measures used to counter security threats in computer networks; apply security control measures to secure a computer network; and acknowledge the importance of securing a computer network.

Why networks need security

Networks carry school records, marks, mobile money transactions, health records and private messages. Network security is the set of rules and tools used to protect a network and its data from misuse, damage and unauthorised access.

The CIA triad

The three basic principles of network security are known as the CIA triad.

Figure 2.6: The CIA triad: three principles of network security

Figure 2.6: The CIA triad: three principles of network security

Principle

Meaning

Example

Confidentiality

Only authorised people can read the data

Only the principal can open the exam database

Integrity

Data stays accurate and is not changed without permission

Nobody can secretly change a learner's marks

Availability

Authorised users can use the system when they need it

The school portal works during registration

Security threats

A threat is anything that can harm a network or its data.

Threat

Description

Malware

Harmful software: viruses spread by attaching to files, worms spread by themselves, trojans pretend to be useful programs, spyware secretly watches users, and ransomware locks files until money is paid

Phishing

A fake email, SMS or website that tricks people into giving passwords or bank details

Hacking

Unauthorised access to a computer or network

Denial of Service (DoS/DDoS)

Flooding a server with requests so that real users cannot reach it

Password attacks

Guessing or stealing passwords

Eavesdropping (sniffing)

Secretly capturing data as it travels through the network, for example on an open Wi-Fi

Social engineering

Tricking people into giving away secrets

Insider threats

A careless or dishonest user inside the organisation

Control measures

A control measure is a method used to prevent, detect or reduce the effect of a threat.

Figure 2.7: Matching common threats with control measures

Figure 2.7: Matching common threats with control measures

Control measure

How it protects the network

Firewall

Filters traffic between the internet and the network and blocks unwanted connections

Intrusion detection system (IDS)

Watches network traffic and raises an alarm when it sees suspicious activity

Encryption

Scrambles data so that only someone with the key can read it

Access control

Allows only authorised users, using usernames, strong passwords, biometrics (fingerprints) or two-step verification

Anti-malware and antivirus software

Finds and removes viruses, worms and other harmful programs

Software updates (patches)

Fix weaknesses that attackers could use

Backups

Keep copies of data so that it can be restored after an attack or failure

Audits and logs

Record who did what, so that unusual activity can be found

User training

Teaches users to avoid phishing and to use safe passwords

How a firewall works

Figure 2.8: A firewall placed between the internet and a school network

Figure 2.8: A firewall placed between the internet and a school network

A firewall checks every packet against a set of rules. Allowed traffic (such as web browsing) passes through. Blocked traffic (such as a connection from an unknown address) is dropped.

Encryption

Encryption changes readable data (plaintext) into unreadable data (ciphertext) using a key. Decryption changes it back.

Figure 2.9: Encryption and decryption using a key

Figure 2.9: Encryption and decryption using a key

WORKED EXAMPLE: CAESAR CIPHER

In a Caesar cipher each letter is shifted forward by a fixed number of places. With a shift (key) of 3: A → D, B → E, C → F and so on. The word KENYA becomes NHQBD (K → N, E → H, N → Q, Y → B, A → D). To decrypt, shift each letter back by 3.

Modern networks use much stronger encryption. For example HTTPS encrypts web traffic and WPA2/WPA3 encrypts Wi-Fi.

Securing a network and sharing resources safely

Learners can secure a simulated or school network by following these steps:

  1. Change the default administrator password to a strong one.
  2. Turn on the firewall and update the software.
  3. Create user accounts and give each user only the access they need.
  4. Install antivirus software and scan regularly.
  5. Encrypt the Wi-Fi (WPA2 or WPA3) and hide or protect the network key.
  6. Share folders with permission settings (read only or read and write) and keep backups.
  7. Check the logs regularly.

A STRONG PASSWORD

Use at least 12 characters, mixing capital letters, small letters, numbers and symbols. Do not use your name, birth date or "1234". Never share your password, and use a different password for each account.

Security versus accessibility

If a network is too strict, authorised people may be locked out and the work slows down. If it is too open, attackers can get in. Organisations must balance security and accessibility: give each user the access they need, protect sensitive data with extra controls, and review the rules regularly.

Community activity

Prepare a poster, short talk or video that sensitises community members about phishing and safe use of mobile money and public Wi-Fi.

✎ Practice: Network security

  1. Define network security.
  2. Name the three parts of the CIA triad and explain each in one sentence.
  3. Distinguish between a virus and a worm.
  4. What is phishing? State two ways of avoiding it.
  5. State the work of (a) a firewall, (b) encryption.
  6. Encrypt the word CAB using a Caesar cipher with a shift of 2.
  7. Explain why an organisation must balance network security and accessibility.

ANSWERS

  1. Network security is the set of rules and tools that protect a network and its data from misuse, damage and unauthorised access.
  2. Confidentiality: only authorised people can read the data. Integrity: data stays accurate and unchanged. Availability: authorised users can use the system when needed.
  3. A virus attaches itself to a file and spreads when the file is opened; a worm spreads on its own across the network without needing a host file.
  4. Phishing is a trick that uses fake messages or websites to steal personal information. Avoid it by not clicking unknown links and by checking the sender's address (also: never share passwords; use two-step verification).
  5. (a) A firewall filters traffic and blocks unauthorised connections. (b) Encryption scrambles data so that only authorised people with the key can read it.
  6. C → E, A → C, B → D, so CAB becomes ECD.
  7. Too much security can stop authorised users from doing their work; too little security lets attackers in. The two must be balanced so that data is safe and users can still reach it.

Key inquiry questions: What security practices are essential in network security? Why is it important for organisations to find a balance between network security and accessibility?

Computer Studies · Grade 11

Strand 3.0: Software Development

SOFTWARE

3.1 Object Oriented Programming (OOP) Concepts

You should be able to: explain principles of object oriented programming; describe a class and an object in object oriented programming; use Unified Modeling Language (UML) to represent a class; and acknowledge the importance of object oriented programming in software development.

What is object oriented programming?

A program is a set of instructions that tells a computer what to do. A programming paradigm is a style of writing programs. In procedural programming a program is a list of steps (functions) that work on data. In object oriented programming (OOP) a program is built from objects: self-contained units that keep their data and the actions that work on that data together, just like real things around us.

Figure 3.1: Procedural programming compared with object oriented programming

Figure 3.1: Procedural programming compared with object oriented programming

Feature

Procedural programming

Object oriented programming

Main unit

Functions (steps)

Objects (data and actions together)

Data

Often shared by all functions, so it is easy to change by mistake

Hidden inside objects and protected

Reuse of code

Copying and calling functions

Inheritance and classes can be reused

Best for

Small, simple programs

Large programs written by many people

Languages

C, Pascal, BASIC

Python, Java, C++, C#

Selecting an OOP language. Choose a language by looking at the type of program (mobile app, web, game), how easy it is to learn, the libraries and tools available, the support from the community, speed, and the computers it must run on. Python is a good first OOP language because its code is short and easy to read, and these notes use Python for examples. Java is widely used for Android apps and school projects, and C++ is used for games and system software.

Class and object

A class is a blueprint or template that describes what a group of similar things have and can do. An object is a particular instance of a class, a real thing made from the blueprint.

Class

Attributes

Methods

Example objects

Student

name, admissionNo, marks

enrol(), calculateGrade()

Wanjiku (Adm 101), Otieno (Adm 102)

Phone

brand, batteryLevel, number

call(), sendSms(), charge()

Tecno Spark, Samsung A15

Book

title, author, isbn

borrow(), return()

"Blossoms of the Savannah"

Matatu

plateNumber, seats, route

start(), pickPassenger()

KDD 123X

A class is a plan; the objects are the things built from it. One class can create many objects, and each object has its own values of the attributes.

Representing a class with UML

Unified Modeling Language (UML) is a standard way of drawing the design of a program. A class diagram is a rectangle divided into three compartments: the class name (top), the attributes (middle) and the methods (bottom). A symbol shows who can use each member: + means public (anyone), − means private (only the class itself) and # means protected (the class and its sub-classes).

Figure 3.2: A UML class diagram for Student and two objects made from it

Figure 3.2: A UML class diagram for Student and two objects made from it

An object is shown in a box with its name and class underlined as objectName : ClassName, followed by the values of its attributes.

Principles of OOP

OOP rests on four main principles.

Figure 3.3: The four principles of object oriented programming

Figure 3.3: The four principles of object oriented programming

Principle

Meaning

Real-life example

Abstraction

Show only the important features and hide the details

You press the send button on a phone without knowing how the network carries the message

Encapsulation

Bundle data and methods together and protect the data from direct, unsafe access

An ATM lets you withdraw money, but you cannot change the balance directly

Inheritance

A new class (child) takes the attributes and methods of an existing class (parent) and may add its own

Dog and Cat inherit from Animal

Polymorphism

The same method name behaves differently in different classes ("many forms")

speak() makes a dog bark and a cat meow

Importance of OOP in software development

Community activity

Prepare a poster or short video for your community explaining, with local examples such as a Matatu class and a Farmer class, how OOP helps programmers build useful software.

✎ Practice: OOP concepts

  1. Define object oriented programming.
  2. Distinguish between a class and an object.
  3. Distinguish between an attribute and a method. Give one example of each for a class called Book.
  4. Name the three compartments of a UML class diagram.
  5. State what the symbols +, − and # mean in a UML class diagram.
  6. Explain two of the four principles of OOP.
  7. State three advantages of OOP over procedural programming.

ANSWERS

  1. OOP is a style of programming in which a program is built from objects that contain both data and the methods that work on the data.
  2. A class is a blueprint that describes attributes and methods; an object is a particular instance of a class made from that blueprint.
  3. An attribute is data held by the class (e.g. title); a method is an action the class can do (e.g. borrow()).
  4. The class name, the attributes and the methods.
  5. + is public, − is private and # is protected.
  6. Any two: abstraction (show only essential features); encapsulation (data and methods bundled and data protected); inheritance (a child class takes features from a parent class); polymorphism (the same method name behaves differently).
  7. Any three: code reuse; easy maintenance; better security of data; teamwork; models real-life things; suitable for large programs.

Key inquiry questions: Why is OOP widely used in software development? How can real-life problems be represented using OOP principles?

SOFTWARE

3.2 Object Oriented Programming Implementation

You should be able to: describe the syntax of an object oriented programming language; write a program that implements a class and an object; write a program that implements class relationships; write a program that implements the principles of OOP; and appreciate the use of object oriented programming in problem solving.

All examples use Python. Type them in an editor such as IDLE, Thonny or VS Code, and run them. In Python, a block of code is shown by indentation (four spaces), and the first line of a block ends with a colon (:). The same ideas work in Java and C++, with different syntax.

Writing a class and creating objects

A class is written with the keyword class. The special method __init__() is the constructor: it runs automatically when an object is created and sets the starting values. self refers to the object itself.

A STUDENT CLASS

class Student:

school = "Mwangaza Senior School" # class (static) variable

def __init__(self, name, marks): # constructor

self.name = name # instance variable

self.marks = marks

def grade(self): # method

if self.marks >= 70:

return "A"

elif self.marks >= 50:

return "B"

return "C"

s1 = Student("Wanjiku", 78) # create an object

s2 = Student("Otieno", 55)

print(s1.name, s1.grade()) # Wanjiku A

print(s2.name, s2.grade()) # Otieno B

print(Student.school) # Mwangaza Senior School

Term

Meaning

Instance variable

Belongs to one object (e.g. name); every object has its own copy

Static (class) variable

Shared by all objects of the class (e.g. school)

Constructor

The method that creates and sets up a new object

Method

A function written inside a class

Visibility specifiers

Visibility decides which code may use a member of a class. Java and C++ use the words public, private and protected. In Python it is shown with underscores in the name.

Level

Meaning

In Python

Public

Any code may use it

name

Protected

Only the class and its sub-classes should use it

_name (single underscore)

Private

Only the class itself can use it

__name (double underscore)

Encapsulation in practice

By making data private and giving public methods to use it, a class controls how the data is changed.

PROTECTING AN ACCOUNT BALANCE

class Account:

def __init__(self, owner, balance=0):

self.owner = owner

self.__balance = balance # private

def deposit(self, amount):

if amount > 0:

self.__balance += amount

def withdraw(self, amount):

if 0 < amount <= self.__balance:

self.__balance -= amount

else:

print("Not enough money")

def get_balance(self):

return self.__balance

acc = Account("Achieng", 1000)

acc.deposit(500)

acc.withdraw(300)

print(acc.get_balance()) # 1200

acc.withdraw(5000) # Not enough money

Outside the class, the statement `acc.__balance = 0` cannot change the real balance, so the data is safe.

Inheritance and polymorphism

A child class is written with the parent class in brackets. The child can override (replace) a method of the parent so that the same name gives different results. This is polymorphism.

Figure 3.4: Dog and Cat inherit from Animal and override speak()

Figure 3.4: Dog and Cat inherit from Animal and override speak()

INHERITANCE AND METHOD OVERRIDING

class Animal:

def __init__(self, name):

self.name = name

def speak(self):

print(self.name, "makes a sound")

class Dog(Animal):

def speak(self):

print(self.name, "barks")

class Cat(Animal):

def speak(self):

print(self.name, "meows")

for a in [Dog("Rex"), Cat("Tom"), Animal("Pet")]:

a.speak()

# Rex barks

# Tom meows

# Pet makes a sound

Class relationships

Classes in a program are connected to each other. The three common relationships are:

Figure 3.5: Association, aggregation and composition

Figure 3.5: Association, aggregation and composition

Relationship

Meaning

Example

Association

One class uses or knows another; both exist independently

A Teacher teaches a Student

Aggregation

A "has-a" relationship where the parts can exist without the whole

A Library has Books; if the library closes, the books still exist

Composition

A strong "has-a" relationship where the parts cannot exist without the whole

A House has Rooms; if the house is destroyed, the rooms are gone

AGGREGATION: A LIBRARY HOLDS BOOK OBJECTS

class Book:

def __init__(self, title, author):

self.title = title

self.author = author

self.available = True

class Library:

def __init__(self):

self.books = [] # the library holds books

def add_book(self, book):

self.books.append(book)

def borrow(self, title):

for b in self.books:

if b.title == title and b.available:

b.available = False

return "Borrowed " + title

return "Not available"

lib = Library()

lib.add_book(Book("Blossoms of the Savannah", "Henry Ole Kulet"))

print(lib.borrow("Blossoms of the Savannah")) # Borrowed Blossoms of the Savannah

print(lib.borrow("Blossoms of the Savannah")) # Not available

COMPOSITION: A CAR CREATES ITS OWN ENGINE

class Engine:

def start(self):

print("Engine started")

class Car:

def __init__(self):

self.engine = Engine() # the Engine belongs to this Car

def drive(self):

self.engine.start()

print("Car is moving")

Car().drive()

# Engine started

# Car is moving

Solving real-life problems with OOP

Follow these steps to design a program:

  1. Understand the problem (for example, a school canteen wants to record sales).
  2. Identify the objects (nouns): Item, Sale, Customer.
  3. List attributes and methods (data and actions) for each class.
  4. Draw a UML class diagram showing the classes and their relationships.
  5. Write the code, class by class.
  6. Test and correct the program with sample data, and improve it.

Common errors

✎ Practice: OOP implementation

  1. What is the job of the constructor `__init__`?
  2. Explain the use of the keyword `self`.
  3. Write a Python class `Book` with attributes `title` and `pages`, and a method `info()` that prints both.
  4. Write the line that creates an object `b1` of class Book for a book "Atlas" with 120 pages.
  5. Explain how the variable `__balance` in the Account class is protected.
  6. In the Animal example, what will `Cat("Tom").speak()` print?
  7. Distinguish between aggregation and composition. Give one example of each.

ANSWERS

  1. The constructor runs automatically when an object is created and sets the starting values of its attributes.
  2. `self` refers to the current object, so that each object can use its own attributes and methods.
  3. Write `class Book:`, then inside it `def __init__(self, title, pages):` with the lines `self.title = title` and `self.pages = pages`, and then `def info(self):` with the line `print(self.title, self.pages)`.
  4. `b1 = Book("Atlas", 120)`
  5. It is private (double underscore), so code outside the class cannot change it directly; it can only be changed through the methods deposit() and withdraw(), which check the amount.
  6. It prints Tom meows.
  7. In aggregation the parts can exist without the whole (a Library and its Books). In composition the parts cannot exist without the whole (a House and its Rooms).

Key inquiry questions: How do the principles of object oriented programming facilitate solving real-life problems? What is the importance of classes and objects in OOP?

SOFTWARE

3.3 Relational Database Fundamentals

You should be able to: explain the types of database models used in computing; create a database for a real life task; represent a database structure in an entity relationship diagram; and acknowledge the importance of relational databases in computing.

Data, information and databases

Data is raw facts. Information is data that has been processed to give meaning. A database is an organised collection of related data that is stored electronically so that it can be searched, updated and shared easily. A Database Management System (DBMS) is the software used to create, manage and protect a database. Examples of DBMS software are MySQL, Microsoft Access, Microsoft SQL Server, Oracle and PostgreSQL.

Figure 3.6: Components of a database system

Figure 3.6: Components of a database system

Term

Meaning

Table (entity)

A grid that stores data about one type of thing, e.g. Student

Record (row)

All the data about one item, e.g. one learner

Field (column or attribute)

One piece of data about every item, e.g. name

Data dictionary

A list that describes every table and field: its name, data type and size

Metadata

"Data about data", such as the field type and length

Data types

The kind of data a field holds: text (VARCHAR), whole number (INT), decimal number, date, true/false (BOOLEAN)

Why not use paper or a single spreadsheet? A database reduces repeated data (redundancy), keeps data correct and consistent (integrity), allows many people to use it at once, protects data with passwords and permissions, and answers questions quickly.

Database models

A database model describes how data is organised and connected.

Figure 3.7: Four database models

Figure 3.7: Four database models

Model

How data is organised

Example use

Hierarchical

A tree: each child has one parent

A school folder structure; organisation charts

Network

A graph: each record can have many parents and children

Telecommunication and transport networks

Relational

Data stored in tables that are linked by common fields (keys)

School records, banking, shops. The most widely used model

Object-oriented

Data stored as objects with attributes and methods

Multimedia and engineering databases

Keys

A key is a field (or group of fields) used to identify records and link tables.

Key

Meaning

Example

Primary key

A field that identifies each record uniquely; it cannot repeat or be empty

admNo in Student

Foreign key

A field in one table that is the primary key of another table; it links the two tables

classId in Student (primary key in Class)

Composite key

A primary key made from two or more fields together

bookId + memberId in a Loan table

Secondary key

A field that is not unique but is used to search or sort records quickly

name or phone number

Figure 3.8: Primary and foreign keys linking two tables

Figure 3.8: Primary and foreign keys linking two tables

Entities, attributes and relationships

An entity is a person, place, thing or event about which data is stored (for example Learner, Teacher, Book). Its attributes are its properties (name, admission number). A relationship is the link between two entities. There are three kinds.

Figure 3.9: Types of relationships between entities

Figure 3.9: Types of relationships between entities

Relationship

Meaning

Example

One-to-one (1:1)

One record in A matches one record in B

One Learner has one School ID card

One-to-many (1:M)

One record in A matches many records in B

One Class has many Learners

Many-to-many (M:M)

Many records in A match many records in B

Many Learners study many Subjects

A many-to-many relationship is split into two one-to-many relationships by adding a linking (junction) table. For example the Marks table links Learner and Subject.

Entity relationship diagrams (ERD)

An entity relationship diagram is a drawing that shows the entities, their attributes and their relationships. Rectangles show entities, lines show relationships, and the symbols at the ends of the lines show one or many.

Figure 3.10: An entity relationship diagram for a school database

Figure 3.10: An entity relationship diagram for a school database

Creating a database for a real-life task

EXAMPLE: A SCHOOL LIBRARY

Step 1: Identify entities. Book, Member and Loan.

Step 2: List attributes. Book (bookId, title, author), Member (memberId, name, class), Loan (loanId, bookId, memberId, dateBorrowed).

Step 3: Choose primary keys. bookId, memberId and loanId.

Step 4: Link the tables with foreign keys. bookId and memberId in the Loan table.

Step 5: Draw the ERD. Member 1:M Loan and Book 1:M Loan (so Member and Book are many-to-many).

Step 6: Create the tables in a DBMS (Section 3.4), enter sample data, and test the queries.

bookId

title

author

B01

Blossoms of the Savannah

Henry Ole Kulet

B02

The River and the Source

Margaret Ogola

loanId

bookId

memberId

dateBorrowed

L1

B01

M10

2026-02-03

L2

B02

M12

2026-02-04

Importance of relational databases

Community activity

Create an operational database for a community group, such as a table-banking group or a school canteen, with at least two linked tables, and show members how to use it.

✎ Practice: Relational databases

  1. Define the terms database and DBMS. Give one example of a DBMS.
  2. Distinguish between a record and a field.
  3. State two advantages of a database over paper files.
  4. Name four database models and state one feature of the relational model.
  5. Explain the terms primary key and foreign key.
  6. What type of relationship exists between Class and Learner? Between Learner and Subject?
  7. A school wants to keep data about Teachers, Subjects and the Subjects each teacher teaches. Name the tables you would create and the keys.

ANSWERS

  1. A database is an organised collection of related data stored electronically. A DBMS is software for creating and managing a database, e.g. MySQL.
  2. A record is a row with all the data about one item; a field is a column holding one type of data about all items.
  3. Any two: less repeated data; better accuracy; data can be shared; better security; faster searching.
  4. Hierarchical, network, relational and object-oriented. In the relational model data is stored in tables linked by keys.
  5. A primary key is a field that uniquely identifies each record in a table. A foreign key is a field that is the primary key of another table and is used to link the two tables.
  6. Class to Learner is one-to-many. Learner to Subject is many-to-many.
  7. Teacher (teacherId as primary key), Subject (subjectId as primary key) and a linking table TeacherSubject (teacherId and subjectId, together a composite key, each a foreign key).

Key inquiry questions: Why are relational databases preferred for organisational data management? How are relational database applications applied in real-life situations?

SOFTWARE

3.4 Structured Query Language (SQL)

You should be able to: describe types of structured query language statements; perform structured query language operations in a database; and appreciate the use of structured query language in database management.

What is SQL?

Structured Query Language (SQL) is the standard language used to create, change and ask questions about data in a relational database. It is used by MySQL, Microsoft SQL Server, Oracle, Sybase and many other systems. SQL commands are not case-sensitive, but it is a good habit to write the SQL keywords in capital letters, and every statement normally ends with a semicolon (;).

Types of SQL statements

Figure 3.11: Types of SQL statements and their main commands

Figure 3.11: Types of SQL statements and their main commands

Type

Full name

Purpose

Commands

DDL

Data Definition Language

Creates and changes the structure of a database

CREATE, ALTER, DROP, RENAME

DML

Data Manipulation Language

Adds, changes and removes the data in tables

INSERT, UPDATE, DELETE

DQL

Data Query Language

Retrieves data

SELECT

The examples below use two tables: Class and Student.

classId

teacher

4A

Mrs Mwangi

4B

Mr Otieno

admNo

name

classId

marks

101

Wanjiku

4A

78

102

Otieno

4A

55

103

Achieng

4B

91

104

Kamau

4B

64

105

Halima

4A

70

DDL: defining the structure

CREATE TABLE

CREATE TABLE Class (

classId VARCHAR(2) PRIMARY KEY,

teacher VARCHAR(40)

);

CREATE TABLE Student (

admNo INT PRIMARY KEY,

name VARCHAR(50) NOT NULL,

classId VARCHAR(2),

marks INT,

FOREIGN KEY (classId) REFERENCES Class(classId)

);

The FOREIGN KEY line creates a one-to-many relationship: one class can have many learners. A one-to-one relationship is created by making the foreign key also UNIQUE. A many-to-many relationship is made with a junction table that holds two foreign keys.

ALTER, RENAME AND DROP

ALTER TABLE Student ADD phone VARCHAR(15); -- add a column

ALTER TABLE Student RENAME TO Learner; -- rename a table (MySQL)

DROP TABLE Learner; -- delete the table completely

Note: DROP removes the table and all its data, so use it with great care.

DML: working with the data

INSERT, UPDATE AND DELETE

INSERT INTO Class VALUES ('4A', 'Mrs Mwangi');

INSERT INTO Student (admNo, name, classId, marks)

VALUES (101, 'Wanjiku', '4A', 78);

UPDATE Student SET marks = 60 WHERE admNo = 102; -- change a value

DELETE FROM Student WHERE admNo = 104; -- remove a record

ALWAYS USE WHERE

`UPDATE` or `DELETE` without a WHERE clause changes or deletes every record in the table.

DQL: retrieving data with SELECT

BASIC QUERIES

SELECT * FROM Student; -- all columns, all rows

SELECT name, marks FROM Student; -- chosen columns

SELECT name, marks FROM Student WHERE marks >= 70;

SELECT name, marks FROM Student ORDER BY marks DESC;

SELECT name FROM Student WHERE name LIKE 'A%'; -- names starting with A

SELECT name FROM Student

WHERE classId = '4A' AND marks >= 60 ORDER BY name;

Query

Result

SELECT name, marks FROM Student WHERE marks >= 70;

Wanjiku 78, Achieng 91, Halima 70

SELECT name, marks FROM Student ORDER BY marks DESC;

Achieng 91, Wanjiku 78, Halima 70, Kamau 64, Otieno 55

SELECT name FROM Student WHERE name LIKE 'A%';

Achieng

Functions and grouping

AGGREGATE FUNCTIONS AND GROUP BY

SELECT COUNT(*) FROM Student; -- number of records

SELECT MAX(marks), MIN(marks), AVG(marks) FROM Student;

SELECT classId, COUNT(*), AVG(marks)

FROM Student

GROUP BY classId;

classId

COUNT(*)

AVG(marks)

4A

3

67.67

4B

2

77.5

Joining tables

A JOIN combines rows from two tables using the linked key.

INNER JOIN

SELECT Student.name, Class.teacher

FROM Student

INNER JOIN Class ON Student.classId = Class.classId;

The result lists each learner beside their class teacher, for example Wanjiku with Mrs Mwangi and Achieng with Mr Otieno.

Using SQL to manage community data

Learners can make an SQL database for a community group (for example a self-help group's members and contributions), use INSERT to enter data, UPDATE to correct it, and SELECT with GROUP BY to prepare reports such as total contributions per member.

✎ Practice: SQL

  1. State what SQL stands for and give two database systems that use it.
  2. Name the three types of SQL statements and one command of each.
  3. Write an SQL statement to create a table `Book` with columns `bookId` (primary key), `title` (up to 60 characters) and `pages` (whole number).
  4. Write a statement to add the book (1, 'Atlas', 120) to the Book table.
  5. Write a statement to change the pages of the book with bookId 1 to 150.
  6. Write a query to display the titles of all books with more than 100 pages, in alphabetical order.
  7. Explain why `DELETE FROM Book;` is dangerous.
  8. Using the Student table in these notes, state the output of `SELECT COUNT(*) FROM Student WHERE marks >= 70;`.

ANSWERS

  1. Structured Query Language; for example MySQL and Microsoft SQL Server (or Oracle).
  2. DDL (CREATE), DML (INSERT, UPDATE or DELETE) and DQL (SELECT).
  3. CREATE TABLE Book (bookId INT PRIMARY KEY, title VARCHAR(60), pages INT);
  4. INSERT INTO Book VALUES (1, 'Atlas', 120);
  5. UPDATE Book SET pages = 150 WHERE bookId = 1;
  6. SELECT title FROM Book WHERE pages > 100 ORDER BY title;
  7. Without a WHERE clause it deletes every record in the table.
  8. 3 (Wanjiku 78, Achieng 91 and Halima 70).

Key inquiry questions: How are SQL skills essential in database management? Why is SQL considered a powerful tool in data management?

SOFTWARE

3.5 Web Development Fundamentals

You should be able to: explain the terminologies used in web development; describe the structure of a web application in hypertext markup language; design a web application using appropriate tools; develop a dynamic web application to solve a real-life problem; and acknowledge the importance of web applications in society.

Web development terms

Term

Meaning

Web page

A single document on the web, written in HTML and viewed in a browser

Website

A collection of related web pages under one domain name, e.g. www.cbcteacher.co.ke

Web application

A program that runs in a browser and lets users do tasks, such as online registration or mobile banking

HTML

Hypertext Markup Language: the language that describes the structure and content of a web page

CSS

Cascading Style Sheets: describes the appearance (colours, fonts, layout)

Client-side scripting

Code that runs in the user's browser, e.g. JavaScript, for buttons and form checks

Server-side scripting

Code that runs on the web server, e.g. PHP (Hypertext Preprocessor), to process forms and use databases

Static web page

The content is fixed and is the same for everyone

Dynamic web page

The content is created by a program and may change for each user or time, e.g. a results portal

Client-server model

The client (browser) sends a request and the server sends back a response

The client-server model

Figure 3.12: How a browser and a web server communicate

Figure 3.12: How a browser and a web server communicate

  1. The user types a web address (URL) in the browser.
  2. DNS finds the server's IP address.
  3. The browser sends an HTTP request to the web server.
  4. The server finds the page, or runs a server-side script (such as PHP) that may ask the database for data.
  5. The server sends back an HTTP response containing HTML, CSS and JavaScript.
  6. The browser reads the HTML and shows the page.

Structure of an HTML document

HTML uses tags in angle brackets, usually in pairs: an opening tag and a closing tag (with a slash). An element is the opening tag, the content and the closing tag. A tag may have attributes that give extra information, written as name="value".

Figure 3.13: The structure of an HTML document

Figure 3.13: The structure of an HTML document

A SIMPLE WEB PAGE (INDEX.HTML)

<!DOCTYPE html>

<html>

<head>

<title>My School</title>

</head>

<body>

<h1>Welcome to Mwangaza Senior School</h1>

<p>We learn, we serve and we grow.</p>

<img src="logo.png" alt="School logo" width="120">

<a href="about.html">About us</a>

</body>

</html>

Element

Purpose

`<head>`

Holds information about the page, such as the `<title>` shown on the browser tab

`<body>`

Holds everything that is displayed on the page

`<h1>` to `<h6>`

Headings, from the biggest to the smallest

`<p>`

A paragraph

`<a href="...">`

A link to another page

`<img src="..." alt="...">`

An image; the alt text describes it

`<ul>`, `<ol>`, `<li>`

Bulleted list, numbered list and list item

`<table>`, `<tr>`, `<th>`, `<td>`

A table, a row, a heading cell and a data cell

`<form>`, `<input>`

A form and its input boxes

`<iframe>`

A frame that shows another page inside this page

Lists and tables in HTML

A LIST AND A TABLE

<ul>

<li>Computer Studies</li>

<li>Mathematics</li>

</ul>

<table border="1">

<tr><th>Name</th><th>Marks</th></tr>

<tr><td>Wanjiku</td><td>78</td></tr>

</table>

Styling with CSS

CSS can be added in three ways.

Method

Where the CSS is written

Use

Inline

In the `style` attribute of one tag

Changing one element only

Internal

Inside a `<style>` tag in the `<head>`

Styling one page

External

In a separate `.css` file linked with `<link>`

Styling a whole website (best)

INTERNAL CSS

<style>

body { background-color: #f4f8f5; font-family: "Times New Roman", serif; }

h1 { color: darkgreen; text-align: center; }

p { font-size: 18px; }

</style>

A CSS rule has a selector (what to style), then properties and values in curly brackets.

Designing a website

Before coding, plan the design with a wireframe (a simple sketch of the page layout), a site map (a diagram showing how the pages are linked) and a prototype (a model that can be clicked).

Figure 3.14: Wireframe and site map for a school website

Figure 3.14: Wireframe and site map for a school website

Design principles: keep the layout simple and consistent; use readable fonts and strong colour contrast; make the site work on phones (responsive design); give every image alt text; keep navigation clear.

Dynamic web applications

A dynamic web application uses an HTML form to collect data, a server-side script (such as PHP) to process it, and a database (such as MySQL) to store it.

Figure 3.15: Data flow in a dynamic web application

Figure 3.15: Data flow in a dynamic web application

THE HTML FORM (REGISTER.HTML)

<form action="save.php" method="post">

Name: <input type="text" name="name"><br>

Marks: <input type="number" name="marks"><br>

<input type="submit" value="Save">

</form>

THE PHP SCRIPT THAT SAVES THE DATA (SAVE.PHP)

<?php

$conn = new mysqli("localhost", "root", "", "school");

if ($conn->connect_error) { die("Connection failed"); }

$name = $_POST["name"];

$marks = (int) $_POST["marks"];

$stmt = $conn->prepare("INSERT INTO Student (name, marks) VALUES (?, ?)");

$stmt->bind_param("si", $name, $marks);

$stmt->execute();

echo "Record saved";

$conn->close();

?>

The script uses a prepared statement (the `?` marks) so that a user cannot damage the database by typing harmful SQL into the form. This protects against SQL injection.

Using a local server. Install a package such as XAMPP or WAMP, which gives you a web server (Apache), PHP and MySQL on your own computer. Put your files in the server's `htdocs` folder and open them at `http://localhost/` in a browser.

Maintaining web applications

Importance of web applications to society

Web applications let people pay bills, register for exams (KNEC), apply for services (eCitizen), shop, learn online and run a business from anywhere. They save time and cost and reach many people at once.

Community activity

Design and publish a simple local website or web application for a community need (for example a school notice board, a youth group register or a farmers' price list). Sensitise community members on how to use it safely.

✎ Practice: Web development

  1. Distinguish between a web page and a website.
  2. State the difference between a static and a dynamic web page.
  3. What is the job of (a) HTML, (b) CSS, (c) PHP?
  4. Explain the client-server model in three steps.
  5. Write the HTML to display the heading "My Class" and a paragraph "Form 4 learners".
  6. State three ways of adding CSS to a web page and which is best for a whole website.
  7. Explain the use of a prepared statement in a PHP script.
  8. State two ways of maintaining a web application.

ANSWERS

  1. A web page is a single document; a website is a collection of related pages under one domain name.
  2. A static page has fixed content that is the same for every user. A dynamic page has content generated by a program, which can change for different users or at different times.
  3. (a) HTML gives the structure and content. (b) CSS controls the appearance. (c) PHP is a server-side language that processes data and works with databases.
  4. The client (browser) sends a request; the server finds or builds the page; the server sends the response and the browser displays it.
  5. `<h1>My Class</h1>` and `<p>Form 4 learners</p>`
  6. Inline, internal and external. External CSS is best for a whole website.
  7. It sends the SQL and the data separately, which stops a user from injecting harmful SQL (SQL injection).
  8. Any two: back up regularly; update software; test and fix errors; secure the site; monitor activity.

Key inquiry questions: What design principles should be considered when creating a web application? How can a web application be used to solve real-life problems?

Quick Revision

Quick Revision Sheet

Strand 1.0: Foundation of Computer Studies

Topic

Key points to remember

Data units

1 byte = 8 bits; 1 KB = 1,024 bytes; each unit is 1,024 times the one before

Number systems

Decimal 10, binary 2, octal 8, hexadecimal 16 (A = 10 to F = 15)

Conversions

Decimal to other bases: divide repeatedly, read remainders upwards. To decimal: add the positional values. Binary to octal: groups of 3. Binary to hexadecimal: groups of 4

Coding schemes

ASCII 7 or 8 bits (A = 65); EBCDIC 8 bits; BCD 4 bits per decimal digit

Binary addition

0+0=0; 0+1=1; 1+1=10 (write 0, carry 1); 1+1+1=11

Signed numbers

Sign bit 0 = positive, 1 = negative. One's complement: flip bits. Two's complement: flip bits and add 1. 8-bit two's complement range −128 to +127

Logic gates

AND (both 1), OR (at least one 1), NOT (opposite), NAND, NOR, XOR (different), XNOR (same)

Logic circuits

Join gates; truth table has 2ⁿ rows; Boolean expression from the circuit or from the sum of products

Strand 2.0: Computer Networking

Topic

Key points to remember

Standards and protocols

Standard = agreed specification; protocol = rules for sending data

TCP/IP layers

Application, Transport, Internet, Network access

OSI layers

Application, Presentation, Session, Transport, Network, Data link, Physical

Encapsulation

Data, segment, packet, frame, bits; decapsulation is the reverse

IP addressing

IPv4 has 4 octets (0 to 255); subnet mask; default gateway; test with ping

CIA triad

Confidentiality, Integrity, Availability

Controls

Firewall, IDS, encryption, access control, antivirus, updates, backups, audits

Strand 3.0: Software Development

Topic

Key points to remember

OOP

Class = blueprint; object = instance; attributes = data; methods = actions

Four principles

Abstraction, encapsulation, inheritance, polymorphism

UML

Three compartments: name, attributes, methods; + public, − private, # protected

Relationships

Association (uses), aggregation (has-a, parts exist alone), composition (has-a, parts cannot exist alone)

Database keys

Primary (unique), foreign (links tables), composite (two or more fields), secondary (search)

Relationships (data)

One-to-one, one-to-many, many-to-many (needs a linking table)

SQL

DDL: CREATE, ALTER, DROP. DML: INSERT, UPDATE, DELETE. DQL: SELECT

Web

HTML = structure; CSS = appearance; PHP = server-side; client sends request, server sends response

© 2026 Tr Boen. For personal study and classroom use. Please do not redistribute this material.

Browse all Grade 11 notes →