0% found this document useful (0 votes)
731 views401 pages

Tie Computer Science Form Six

The document is a textbook titled 'Computer Science for Advanced Secondary Schools Student’s Book Form Six' published by the Tanzania Institute of Education in 2022. It covers various topics in computer science including data structures, algorithms, information systems, networking, and emerging technologies, structured into seven chapters with exercises and activities for students. The book is designed for form six students in Tanzania, aligning with the 2010 Computer Science Syllabus for Advanced Secondary Education.

Uploaded by

Joshua Bachuba
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
731 views401 pages

Tie Computer Science Form Six

The document is a textbook titled 'Computer Science for Advanced Secondary Schools Student’s Book Form Six' published by the Tanzania Institute of Education in 2022. It covers various topics in computer science including data structures, algorithms, information systems, networking, and emerging technologies, structured into seven chapters with exercises and activities for students. The book is designed for form six students in Tanzania, aligning with the 2010 Computer Science Syllabus for Advanced Secondary Education.

Uploaded by

Joshua Bachuba
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 401

Computer

Science
for
Advanced Secondary Schools
Student’s Book
Form Six

Tanzania Institute of Education

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 1 23/01/2023 11:26:40


© Tanzania Institute of Education, 2022
Computer Science

Published 2022

ISBN: 978-9987-09-590-2

Tanzania Institute of Education


P.O. Box 35094
Dar es Salaam, Tanzania

Mobile numbers: +255 735 041 170 /+255 735 041 168
E-mail: [email protected]
Website: www.tie.go.tz

All rights reserved. No part of this textbook may be reproduced, stored in any
retrieval system, or transmitted in any form or by any means, whether electronic,
mechanical, photocopying, recording, or otherwise, without prior written permission
of the Tanzania Institute of Education.

ii
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 2 23/01/2023 11:26:40


Table of Contents

Computer Science
Acronyms and Abbreviations............ v Chapter Three
Acknowledgements.......................... vii Data communication and
Preface..............................................viii networking...................................... 113
Concept of data communication...... 113
Chapter One Computer networks.......................... 127
Data structures and algorithms ....... 1 Client-server network architecture .. 141
Concept of data structure..................... 1 Transmission media......................... 168
Primitive data structure........................ 3 Chapter Summary ........................... 193
Non-primitive data structure................ 4 Revision exercise ............................ 198
Static data structure.............................. 6
Pointers.............................................. 11 Chapter Four
Dynamic data structure...................... 23 Visual programming...................... 200
Algorithms......................................... 34 Concept of visual programming....... 200
Recursive algorithms......................... 37 Visual Basic .NET and the .NET
Iterative algorithm.............................. 40 Framework....................................... 201
Searching algorithm .......................... 42 Components of the Visual Studio
2022 IDE.......................................... 209
Sorting algorithm............................... 45
Programming in Visual Basic .
Chapter summary .............................. 55
NET ................................................ 226
Revision exercise .............................. 56
Visual basic control structures......... 236
Visual Basic .NET procedures and
Chapter Two functions........................................... 248
Information systems......................... 59 Linking visual Basic .NET form
Overview of Information Systems..... 59 to data source................................... 252
Types of information systems............ 70 Chapter summary ............................ 263
Database systems............................... 74 Revision exercise ............................ 264
Types of database models.................. 77 Chapter Five
Relational database............................ 79
Entity-relationship model................... 90 Computer security and privacy...... 265
Normalisation..................................... 96 The concept of computer security ... 265
Database management..................... 103 Data protection................................. 268
General database administration...... 110 Attacks............................................. 275
Chapter summary ............................ 111 Authorization and access control
techniques........................................ 290
Revision exercise ............................ 111

iii
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 3 23/01/2023 11:26:40


Data loss prevention ........................ 310 Chapter Seven
Computer Science

Vulnerability analysis and penetration Emerging technologies


testing............................................... 313 and trends....................................... 347
Security in cloud computing and the
Concept of emerging technologies
Internet of things (IoT) .................... 320
and trends......................................... 347
Physical security.............................. 323
Industrial revolutions....................... 350
Software piracy and copyright......... 326
Ethical and legal issues.................... 330 Emerging technologies and their
applications...................................... 355
Chapter summary ............................ 332
Impact of emerging technologies..... 374
Revision exercise ............................ 333
Chapter summary ............................ 377
Chapter Six Revision exercise ............................ 378
Information technology career
and environment............................ 334
Glossary ......................................... 380
IT career opportunities..................... 334
IT and environment.......................... 341 Bibliography .................................. 384
Chapter summary ............................ 345 Index ............................................... 386
Revision exercise ............................ 346

iv
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 4 23/01/2023 11:26:40


Acronyms and Abbreviations

Computer Science
1NF First Normal Form
2NF Second Normal Form
3D Three (3) Dimension
3NF Third Normal Form
4D Four (4) Dimension
4IR Fourth Industrial Revolution
5D Five (5) Dimension
ACK Acknowledgment
ACL Access Control List
ADSL Asymmetrical Digital Subscriber Line
AI Artificial Intelligence
AR Augmented Reality
ASCII American Standard Code for Information Interchange
CAD Computer-Aided Design
CIDR Classless Inter-Domain Routing
CPS Cyber-Physical Systems
CRC Cyclic Redundancy check
DBMS Database Management System
DHCP Dynamic Host control protocol
DoS Denial of service
DSL Digital Subscriber Line
DSS Decision Support System
EIS Executive Information System
ERD Entity Relational Diagram
FDM Frequency Division Multiplexer
FTP File Transfer Protocol
IoT Internet of Things

v
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 5 23/01/2023 11:26:41


IS Information System
Computer Science

ISO International Standard for Organisation


LAN Local Area Network
MAC Media Access Control
MAN Metropolitan Area Network
MAU Media Access Unit, also Multistation Access Unit,
ML Machine Learning
NAT Network Address Translation
NIC Network interface card
OSI Open system interconnect
PAN Personal Area Network
PAT Port Address Translation
PC Personal computer
SDLC System Development Life Cycle
SMS Short Message Service
SQL Structured Query Language
SYN Synchronise
SYN-ACK Synchronise acknowledgment
TDM Time Division Multiplexer
TPS Transaction Processing System
UDP User datagram protocol
VPN Visual private network
VR Virtual Reality
WAN Wide Area Network
WLAN Wireless Area Network

vi
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 6 23/01/2023 11:26:41


Acknowledgements

Computer Science
The Tanzania Institute of Education (TIE) would like to acknowledge the contributions
of all organisations and individuals who participated in designing and developing
this textbook. In particular, TIE wishes to thank the University of Dar es Salaam
(UDSM), Mzumbe University (MU), The Open University of Tanzania (OUT),
Dar es Salaam Institute of Technology (DIT), The Mwalimu Nyerere Memorial
Academy (MNMA), the National Examinations Council of Tanzania (NECTA),
School Quality Assurance (SQA) Department, Teachers’ Colleges and Secondary
Schools. Besides, the following individuals are acknowledged:
Writers: Mr Chacha M. Nsaho (Mpwapwa Teachers’ College),
Dr Edephonce N. Nfuka (OUT), Dr-Eng. Morice D. Tegeje (MU),
Dr Fabian G. Mahundu (MNMA), Mr Justine J. Nnko (DIT),
Mr Leonard T. Mkama (Kilakala S.S), & Mr Robert Chassama
(Morogoro Teachers’ College).
Editors: Dr Jabhera Matogoro and Dr Ally S. Nyamawe, (UDOM),
Dr Theophil B. Assey, (IAA), Ms Zawadi L. Tito, (Iyunga Technical
Secondary School), Mr Mussa M. Gunda (Korogwe TC),
Dr Michael A. Mashauri (UDSM-Language) & Dr Rafiki Y. Sebonde
(UDOM-Language).
Designer: Ms Eva G. Kwai
Illustrators: Chacha M. Nsaho & Alama Art and Media Production Co. Ltd
Coordinator: Chacha M. Nsaho (Mpwapwa Teachers’ College)

TIE also appreciates secondary school teachers and students who participated in
the trial phase of the manuscript of this book. Likewise, TIE would like to thank
the Ministry of Education, Science and Technology for facilitating the writing and
printing of this textbook.

Dr Aneth A. Komba
Director General
Tanzania Institute of Education

vii
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 7 23/01/2023 11:26:41


Preface
Computer Science

This textbook, Computer Science for Advanced Secondary Schools Student’s Book
Form Six, is explicitly written for form six students in the United Republic of
Tanzania.
It is written following the 2010 Computer Science Syllabus for Advanced Secondary
Education, Form V-VI issued by the then Ministry of Education and Vocational
Training. The book consists of seven chapters: Data structure and algorithms,
Information systems, Data communications and networking, Visual programming,
Computer security and privacy, Information technology career and environments,
and Emerging technologies. In addition to textual descriptions, each chapter contains
illustrations, activities, and exercises. You are encouraged to do all activities and
exercises in this book and other assignments provided by your teacher. This will
enable you to develop the intended competencies.

Tanzania Institute of Education

viii
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 8 23/01/2023 11:26:41


Computer Science
Chapter
One Data structures and algorithms

Introduction
In form five, you learnt about problem-solving, the concepts of algorithms and
pseudocode, and programming. You demonstrated how to program in C++
language, which is essential in understanding data structures and algorithms.
Such data structures and algorithms are essential in developing efficient software
programs. In this topic, you will learn how data may be structured and instructions
sequenced in algorithms, programs and the relationship between appropriate data
and control structures. Studying data structures and algorithms helps to understand
the basic concepts involved in organising and storing data and the relationship
among the data sets. It helps to determine how information is stored, retrieved, and
modified in a computer’s memory. The competencies developed from data structures
and algorithms will help you to write efficient programs intended to retrieve and
store massive data of various types.

Concept of data structure The data structure organises data items


The data structure is a branch of based on the relationship between
Computer Science that deals with the the data elements in the computer
organisation, flow, and data storage program. For example, attributes such
which builds the logical relationships as the model, name, car number, engine
between data elements to maximise the capacity and number, transmission
efficiency of the computer programs or type, colour can identify a car. These
processes. A well-designed data structure structured variables depend on each
allows various critical operations to be other to identify the exact car. Similarly,
performed using as few resources, both the data structure is an organised set
execution time and memory space, as of interrelated variables that form a
possible. system’s elementary constituent.
The way of organising data affects the Generally, the data structure links the
performance of a program for different programmer’s viewpoint of data and
tasks. Computer programmers decide the implementation of these data in
which data structures to use based on the computers. It comprises the storage
nature of the data and the processes to be methods and one or more algorithms
performed. used to access or modify data.

1
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 1 23/01/2023 11:26:41


Importance of data structure Reusability: The programmer
requires many resources to develop
Computer Science

Nowadays, data structure is essential


in programming for producing efficient any software, making it an expensive
programs. The following are the enterprise. However, if the software
importance of data structure: designed is reusable and adaptable,
(a) It makes it easy for users to access it can be implemented in most future
and work with the data they need in applications. Thus, by implementing
the appropriate ways. quality data structures, it is possible to
(b) It frames information organisation develop reusable software which tends
so that machines and humans can to be cost-effective and time-saving.
better understand it. Robustness: Generally, all computer
(c) It offers the means to manage well programmers expect to produce
a considerable quantity of data. software that generates correct output
(d) It provides a diverse level of data for every possible input provided to it
organisation. and executes efficiently on all hardware
(e) It provides operations on a data platforms. This kind of robust software
group such as, adding an item and must manage both valid and invalid
looking for the highest precedence inputs.
item. Adaptability: Developing software
(f) It tells how data can be stored and projects such as web browsers,
accessed at its fundamental level. word processors, and search engines
(g) It enables fast searching and sorting involve bulky software systems that
of data. have worked or been accomplished
appropriately and efficiently for several
Goals of data structure
years. Additionally, software evolves
During the data structure implementation, due to continually changing market
its operations have two goals. These environments or emerging technologies.
goals are:
Correctness: For all inputs within
(a)  Factors to consider when selecting a
a program, the data structures are data structure
designed to operate correctly for It is essential to choose the appropriate
a specific problem intended to be data structure for each task. The factors
solved. to consider when selecting the proper
Efficiency: Data are processed
(b)  data structure include the following:
at the required speed without (a) Type of information to be stored
using much computer resources,
(b) The uses of data or information
and stored in a specific memory
location. (c) Ways or methods to organise the data
Features of data structures (d) 
The aspects of memory and
storage arrangement plan and their
Some of the essential features of data
management
structures are described as follows:

2
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 2 23/01/2023 11:26:41


(e) Storage devices for data after being the structure; homogeneous and non-
generated

Computer Science
homogeneous (heterogeneous) based on
the similarity of structures.
Classification of data structure In this book, as depicted in Figure 1.1, the
The data structure can broadly be data structure is broadly classified based
categorised into two distinct types: on the nature of the operation that can
A primitive data structure and a non- be conducted on the unit of respective
primitive data structure. In other books, data. The primitive data structure can
data structures have been classified store only values of the same data type,
based on various aspects, for instance,
while non-primitive data structures can
linear data structure and non-linear
store values with more than one data
data structure based on the arrangement
or organisation of the structure; static type. Figure 1.1 shows the classification
data structure and dynamic data of primitive and non-primitive data
structure based on the memory size of structures with examples.

Data Structure

Primitive Non-Primitive
Data Structure Data Structure

Linear Non Linear

Static Dynamic Tree Graph

Array Linked List Stack Queue

Figure 1. 1: Types of data structure

Primitive data structure


The primitive data structure is the fundamental category of data type. Its operations
and functionalities are only performed at the machine level because they consist of
numbers and characters built into a program. Any operation can be carried out in
these types of data items. They are also called pre-defined or built-in data structures.

3
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 3 23/01/2023 11:26:41


They are named in that way because the user can not change or make any alteration
as it is handled at the machine level. They are created without the support of other
Computer Science

structures as tools. They are directly used in the program for any specific task. The
user does not define them. Examples of primitive data structures are integers, floats,
doubles, characters, Boolean, pointers, and strings. Primitive data structure stores
only one type of data or may contain empty values. Figure 1.2. illustrates the sub-
category of primitive data structures.

Primitive Data

Character Boolean

Number

Integer Floating Point

byte short int long double float

Figure 1. 2: Classification of primitive data structure

Number: to 1.79769313486231E308 for positive


Integer: Represents numbers without values.
decimal points, for example, 5, 10, 200, Character: represents the variables that
1254. It has a 32 bits size. use symbols/ characters or letters, for
Float: Represent variables defined with example, r, R, h, A, y, X, “-”. It has a 16
fractional values. These variables have bits size.
decimal points, for example, 10.2, 22.7, Boolean: Represent logical values such
1076.3. It has a 32 bits size containing as; true or false, yes or no, 1 or 0. It has
up to 7 decimals. a 16 bits size.
Double: It is the same as the float
type but has a 64 bits size and
contains up to 15 decimals. For
Non-primitive data structure
example, -1.79769313486231E308 to The non-primitive data structure is a
-4.94065645841247E324 for negative user-defined data structure that can
values and 4.94065645841247E-324 hold several values in adjoining or

4
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 4 23/01/2023 11:26:41


random locations. They must contain memory space allocated to it. The size
some values, i.e. they cannot be empty. of the structure is fixed and permanent

Computer Science
It should have a specific function. at compile time. Accessing individual
The non-primitive data structure is data elements within a static structure
further classified into two categories, is speedy as their memory location is
namely; linear and non-linear data fixed. A static data structure stores a set
structures based on the arrangement and of amounts of data, usually user-defined.
organisation of data. An example of a static data structure is
an array.
Linear data structure
The linear data structure stores data in a
sequence, one after another and the data Dynamic data structure
is accessed from one place and continues In a dynamic data structure, the size
to others sequentially. The linear data of the structure is not fixed and can be
structure is the data structure in which its modified when operations are executed
elements are linked with the subsequent on it. Dynamic data structures aim to
one sequentially. A data structure is linear facilitate the change of data structures in
if its features are combined to form any the run time. Examples of dynamic data
specific order. There are two techniques structures are stacks, Linked lists, and
for representing linear structure queues.
within a memory. The first technique
is to represent the linear relationships
Non-linear data structure
among all the elements described using
linear memory location. These linear In a non-linear data structure the
structures are termed as arrays. The element may link to more than one
second technique represents the linear element, although their data items are
relationship among all the elements not sequential. This structure mainly
using pointers or links. This technique represents data with a hierarchical
of representing linear structures is relationship among various components.
termed linked lists. Furthermore, the An example of a non-linear data structure
linear data structure is classified into two is a tree.
types based on how data can be stored:
static and dynamic data structures. The Exercise 1.1
arrays, stack, linked list, and queue are
examples of linear data structures. Answer the following questions:
1. What is the data structure?
Static data structure 2. Explain the importance of data
The static data structure is a method of structure.
storing data where the amount of data 3. Explain any three features of data
stored and the memory used to hold structures.
it are fixed. In a static data structure, 4. Briefly describe the classification
the content of the data structure can of data structure.
be modified without changing the

5
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 5 23/01/2023 11:26:41


5. 
Kazolamimba Company wants Advantages of static data structures
to decide on a data structure to
Computer Science

The following are the advantages of


implement the program. Explain static data structure:
how you would help them to choose
the best data structure. Easier to comprehend: It is easier to
define and use a static data structure than
6. Describe the types of data structures.
a dynamic one.
7. 
With examples, describe primitive
Size: It has a fixed size.
data structures.
Faster: The memory for static data is
8. Give examples of non-primitive data
structures. assigned during the compilation time,
making the program execute more
quickly than when it has to stop and
Static data structure allocate the required memory each time.
An array index can randomly access any
Think about the following: element of an array.

Arrangements of crates of soda in the Disadvantages of static data structure


shops or depots; arrangements of soda Memory wastage: Declaring an array
in the crate, and the addition of some with a large size is a memory wastage.
bottles of soda than crates’ capacity of For example, if you declare an array of
the container. Also, think about other 10 and only a tiny portion less than the
items packed in cartons, dozen, and declared is used, the rest of the memory
trays. Can you add more items than its will be wasted. Therefore, it can waste a
capacity? lot of space if the estimation is too high.
Observe their arrangement and tell if Insufficient memory space: Declaring
you can add more items than the size of an array with a fixed size leads to a
their containers. Give reasons to support situation where the size of the array
your answer. is less than what you intended to use.
In other words, there is insufficient
Meaning of static data structure memory for the program to run with
all data required. In another situation,
The static data structure has a fixed size
requesting a consecutive large block
of the memory structure. The content
may not be granted, for example, int
of the data structure can be modified
y[6]; it has 6 elements, but the program
without changing the assigned memory
space. needs 10 memory.
Slow: Some algorithms are slower
when done statically than when done
Advantages and disadvantages of dynamically. How would you merge
static data structure
the two lists? The solution with static
Static data structure offers benefits and arrays is to define a more extensive array
limitations that a programmer should and copy the two arrays into a more
consider when deciding to use them. considerable array.

6
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 6 23/01/2023 11:26:41


Not ordinary: More suitable algorithms array is created. After that, elements are
can be implemented dynamically rather accessed using the fixed base location

Computer Science
than statically. of the array. Static arrays are the
Types of static data structure fundamental array type in most older
procedural languages, such as Fortran,
As seen earlier, the static data structure Basic, and C, and many newer object-
is a method of storing data where the oriented languages as well, such as Java.
amount of data stored and the memory
used to hold it are fixed. An example of The following are essential terms to
a static data structure is an array. understand the concept of an array:
(a) 
Element – refers to every item
Arrays stored in an array.
The term array is generally used in (b) Index − used to identify the location
computer programming to mean a of the element.
contiguous chunk of memory locations
where each memory location holds one Classification of arrays in algorithm
fixed-length data item. By this meaning, and data structure
an array is a physical data structure. Arrays must be classified before being
However, the array can also mean a used in a process. They are classified
logical data type composed of a typically into two dimensions as follows:
homogeneous collection of data items,
each identified by an index number. One-dimensional array: This
(a) 
array has one row of elements
An array is a list or table of data with and is stored in ascending storage
a variable name identifying such a list location in its table.
or table. Each item in the table is called
an element. An array can have many Multidimensional arrays: This
(b) 
dimensions. However, most arrays are kind of array includes as many
either one-dimensional, in which they indices as required because they
form a list or can be two-dimensional, are not bound to two indices or
visualised as a table. The array is a two dimensions. Examples of
container that can hold a fixed number multidimensional arrays are:
of items. These items should be of the (i) Two-dimensional (2-D) arrays
same data type. For example, integers or matrix arrays
only or float only or string only. Most of
the data structures make use of arrays to (ii) Three-dimensional (3-D)
implement their algorithms. arrays
In some programming languages, the One-dimensional array structure
size of an array must be established once One-dimensional arrays can be declared
and for all during the program designing in various ways in different languages.
time and cannot change during the For example, from the C++ array
execution. Such arrays are called static declaration, the structure of a one-
arrays. The chunk of memory that is dimensional array is as follows:
big enough and sufficient to hold all the
values in the array is allocated when the

7
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 7 23/01/2023 11:26:41


Array Elements
Computer Science

int array [8] = {32, 43, 12, 21, 56, 26, 89, 77 };

Type Size

As per the previous example, the following are important points to be considered:
(a) The index starts with 0.
(b) The array length is 10, which means it can store maximum 10 elements.
(c) Each element can be accessed via its index. For example, you can fetch an
element at index 6 as 36.
When you declare an array in a program, assign initial values to each of its elements
by enclosing the values in braces {}.
int Num[10] = {2, 9, 12, 78, 34, 23, 1, 29, 50, 13}, this declaration will create the
following array:
Num 2 9 12 78 34 23 1 29 50 13
Example 1: Add all elements of an array using C++ language.
#include <iostream>
using namespace std;
int schools [3] = {5, 9, 10};
int n, result=0;
int main ()
{
for ( n=0 ; n<3 ; n++ )
{
result += schools[n];
}
cout<< result;
return 0;
}

8
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 8 23/01/2023 11:26:41


The output for the program is 24 as shown in the snapshot in Figure 1.3.

Computer Science
Figure 1.3: Out of the program to add element of the array
Two-dimensional array (2-D array) Entering data in two-dimensional
Two-dimensional (2-D) arrays are arrays:
indexed by two subscripts, one for the A nested loop is used to enter data in 2-D
row and one for the column. The Syntax arrays. It depends upon the programmer
of the two-dimensional array is as which loop they want to use, which
follows: can be a While loop or a For loop. The
outer loop acts as the number of rows of
(Data type) (Name of Array)
a matrix and the inner loop acts as the
[Number of rows] [number of columns]; number of columns of a matrix.
For example: Example of a C++ program to enter and
display a two-dimensional array is as
int matrix [7] [7]; follows:
When you type this statement, the #include <iostream>
compiler will generate a 2-D array of a using namespace std;
matrix which consists of 7 rows and 7 int main () {
columns. int test [3][3];
// For taking integer
Accessing location of two-dimensional inputs in a matrix //
array elements for (int i=0 ; i<3 ; i++)
To store values in a C++ two-dimensional {
for (int j=0 ; j<3 ; j++)
array, the programmer has to specify the {
number of rows and columns of a matrix. cout<<”Enter Integer :”;
To access each matrix location to store cin>>test [i][j];
the values, the user must also provide }
}
the exact number of rows and columns. cout<<endl;
For example: // use of nested for
int matrix [3][3]; loop
// access rows of the
test[0][0] = 45 array
for (int i = 0; i < 3;
test[0][1] = 12 ++i) {
test[0][2] = 67 // access columns
of the array
test[1][0] = 78 for (int j = 0; j
test[1][1] = 34 < 3; ++j) {
cout << “test[“ << i <<
test[1][2] = 78 “][“ << j << “] = “ <<
test[2][0] = 89 test[i][j] << endl;
}
test[2][1] = 23 }
return 0;
test[2][2] = 67 }

9
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 9 23/01/2023 11:26:41


The output is shown in Figure 1.4 (c) Searching – An array element can
be searched. The process of seeking
Computer Science

specific elements in an array is


called searching.
(d) 
Merging – The elements of two
arrays are merged into a single one.
(e) Sorting – Arranging elements in a
particular order, either in ascending
or descending order.
Limitations of using arrays
Several limitations must be carefully
considered during the implementation
of arrays. These includes:
(a) Arrays are of fixed size
(b) 
Inserting and deleting elements
can be problematic because of the
shifting of elements from their
positions within a table row or
column
Figure 1.4: Output of the program to
enter and display 2D array elements (c) Data elements are stored in a
contiguous memory location that
Applications of arrays
may not always be available. To
Arrays are essential because they allow solve this implication of using
many values to be stored in a single arrays, you can use linked lists
data structure while quickly accessing arrays.
each value. This is possible as all values
in the array are of the same type and, Advantage of arrays
therefore, need the same amount of The array has the following advantages:
memory to store. Also, elements are kept
in contiguous memory locations. To find (a) The array is simple and easy to use.
where the element is kept, accessing an (b) 
It is also, faster to access the
element in an array “y[i]” needs to find elements.
where the element is kept.
Disadvantages of arrays
Array operations
The array contains the following
Operations with a one-dimensional array
disadvantages:
are as follows:
(a) Deletion – Involves deleting (a) The cluster size should be known
specified elements from an array before utilising it
(b) Insertion – Used to insert an (b) All the components in the cluster
element at a specified position in must be adorned and put away in
an array the memory

10
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 10 23/01/2023 11:26:41


(c) Embedding any element in the set Declaring pointer in C++
needs moving of every element of

Computer Science
The pointer can be declared as follows:
its originals
Datatype*variable_name;
(d) Expanding the size of the cluster is
a period taking cycle. It is not easy (a) The datatype is the base type of
to grow the size of the exhibit at the pointer, which has to be a valid
run time. C++ data type in the case of C++.
(b) The variable_name should be the
name of the pointer variable.
Pointers
(c) An asterisk (*) used above in the
Meaning of pointer pointer declaration is the same
A pointer is a variable whose value is the as the asterisk used to perform
address of another variable, that is, the multiplication operations. It marks
direct address of the memory location. the variable as a pointer.
It is a user-defined data type that creates The C++ uses the ‘&’ (reference)
variables for holding the memory operator to return a variable’s address.
address of other variables. It is denoted For example, if x is a variable, &x
by the “*” operator. It represents storage returns the address of the variable. The
space in memory (RAM) partitioned following example shows the application
into a small portion called cells which of a pointer in a C++ program.
are used to store values. Each cell has
a unique address and occupies one byte Example 1: How to apply pointer in C++
in memory, whose address is always
unassigned integers. If one variable #include<iostream>
using namespace std;
carries the address of another variable, int main ()
the first variable is said to be the pointer {
of another. Thus, a pointer is a variable int y = 12;
whose value is also an address where int *b; //
each variable has two attributes: address declaration of pointer
and value, as shown in Figure 1.5. variable
b = &y; // the
address of y variable is
address value assigned to a pointer b
pointer variable cout<<”Value at b =
“<<b<<endl; // display
Figure 1.5: The pointer and its variable address stored in pointer
b
cout<<”Value at variable
The syntax of a pointer is as follows: y = “<<y<<endl; //
display value stored in
type *ptr_name; variable y
Where type is any data cout<<”Value at *b =
type of the pointer, and; “<< *b;// display value
ptr_name is the pointer’s stored in address of
name. pointer b
}

11
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 11 23/01/2023 11:26:42


The output of the program is shown in Figure 1.6:
Computer Science

Figure 1.6: Output of a program to demonstrate application of pointers

Note: The data type of the pointer and variable should be the same.

Advantages of pointers
The following are the advantages of pointers:
(a) It can return multiple values from a function
(b) It reduces the code and improves performance
(c) It retrieves strings and trees
(d) Used with arrays, structures, and functions
(e) It allows you to access any memory location in the computer’s memory
(f) It can allocate and de-allocates memory dynamically
Disadvantages of pointers
The following are the disadvantages of pointers:
(a) If it is wrongly referenced, it will affect the entire program.
(b) It may lead to a memory leak if the dynamically allocated memory is not freed.
(c) An uninitialised pointer leads to a segmentation fault.
Application of pointers
A pointer is used in various ways as follows:
1. It is used to access array elements.
An array of components can be accessed using pointers, as shown in example 2.

Example 2: Accessing an array elements using C++ pointers


#include<iostream>
using namespace std;
int main(){
int a[]={6,10,23,30};
cout<<*(a +1);
return 0;
}

12
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 12 23/01/2023 11:26:42


The output for the program in example 2 is 10 is shown in Figure 1.7:

Computer Science
Figure 1.7: Output of a program to access array elements using pointers

2. It is used for dynamic memory allocation


Example 3: In C++, you can allocate dynamic memory as follows:
#include<iostream>
#include<stdlib.h>
using namespace std;
int main(){
int i,*ptr;
ptr =(int*) malloc(3*sizeof(int));
if(ptr == NULL){
cout<<”Error! memory not allocated.”;
exit(0);
}
*(ptr+0)=10;
*(ptr+1)=20;
*(ptr+2)=30;
cout<<”Elements are:”;
for(i =0; i <3; i++){
cout<<*(ptr + i);
}
free(ptr);
return 0;
}

The output for the program in example 3 is “Elements are:10 20 30” is shown in
Figure 1.8:

Figure 1.8: Output of a program for dynamic memory allocation using pointers

13
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 13 23/01/2023 11:26:42


3.The pointers are used to pass arguments by reference in functions to increase
efficiency.
Computer Science

Example 4, the program code in C++ to pass arguments by reference in functions as


follows:
#include<iostream>
using namespace std;
void swap(int* x,int* y){
int t=*x;
*x=*y;
*y = t;
}
int main(){
int r =3, s=9;
swap(&r,&s);
cout<< r<<s;
return 0;
}

The output is 93 as shown in Figure 1.9

Figure 1.9: Output of the program to pass arguments by reference

4.The pointer can be used to implement data structures like linked lists and trees as
described in the next sections.

Pointer operations
In C++, the pointer operators are of two kinds:
(a) Reference operator (&): The reference operator (&) returns the variable’s
address, and
(b) Deference operator (*): The dereference operator (*) helps us to get the value
that has been stored in a memory address.

14
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 14 23/01/2023 11:26:42


For example, if you have a variable given the name num1, stored in the address
0x236 and storing the value 27, then

Computer Science
(i) The reference operator (&) will return 0x236.
(ii) The dereference operator (*) will return 27.

Example 5: A C++ program to demonstrate pointer operators (reference and


dereference operators)
Try these code in C++ and display the output;
#include <iostream>
using namespace std;
int main () {
int x = 26;
int *ip;
ip = &x;
cout << “Value of x is : “;
cout << x << endl;
cout << “Value of ip is : “;
cout << ip<< endl;
cout << “Value of *ip is : “;
cout << *ip << endl;
return 0;
}

The output of the program shown in Figure 1.10:

Figure 1.10: Output of the program to demonstrate reference & dereference


operators OR pointer operations
Pointers in arrays
Arrays and pointers work based on a related idea. There are different things to
consider when working with arrays having pointers. The array name denotes the
base address of the array. This means that, when assigning an array’s address to a
pointer, do not use an ampersand (&).
For example:
p = arr; is correct since arr represents the arrays’ address but
p = &arr; is incorrect.
You can implicitly convert an array into a pointer. For example:

15
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 15 23/01/2023 11:26:42


int arr [20]; to these items using the same identifier,
enabling a structured approach to use
Computer Science

int * y;
This is a valid operation: related items. A record will contain a
fixed number of items. For example, a
y = arr;
record for a book may include the title,
After the declaration, y and arr will author, publisher, number of pages, and
be equivalent and share properties.
However, a different address can be whether it is literature or fiction.
assigned to y, but you cannot assign Records store a collection of related data
anything to arr. items, where all items have different
For example, you can traverse an array data types. For example, you might set
using pointers. Example of a C++ up a record called book, which stores
program to traverse the array given as the book’s title, author name, and ISBN.
arr[] = { 11, 45, 63, 26, 5, 24}. Title and author are text, whereas the
#include <iostream> PublicationDate is set as a Date data
using namespace std; type. You can write it as follows:
int main() {
int *y; Book = Record
int arr[] = { 11, 45, Title, Author As Text * 50
63, 26, 5, 24 };
y = arr; ISBN As Text * 13
for (int x = 0; x < 6; PublicationDate As Date.
x++) {
cout << *y << endl; When the program runs, every time data
y++; is entered for the book, the user will type
} in up to 50 characters of text for the title,
return 0; author, and up to 13 of text for ISBN. A
} variable may now be set up using this
record data type, containing all of this
The output of the program as shown in
data.
Figure 1.11
Generally, a record is a data structure that
consists of a fixed number of variables
called fields. Every field has an identifier
(field name) and a data type. Each field
in a record can have a different data type.
This is very common in Spreadsheets

and MS Access, and other databases.
Some languages provide a built-in
Figure 1.11: Output of a program to structure type that can be used to define
traverse array a record.
For example, assume that you want to
Records organise the individual student records
Records are composite data types formed such as registration number, name, sex,
by several related items of different data date of birth, average score, and grade
types. This enables a programmer to refer into a single data structure.

16
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 16 23/01/2023 11:26:42


Student’s_regNo: integer

Computer Science
Student’s_name: string
Student’s sex: string
Student’s_ average_score: real
Student’s_grade: char
Structure of records
Student’s records can be tabulated as shown in Table 1.1
Table 1.1: Student’s records
sn Student’s _regNo Student’s _name sex Average_score Grade Field
1. 7880 Maro Sambayeti M 67 C
2. 7565 Hadija Mkude F 78 B
Records
3. 8665 Makala Ikande M 87 A
4. 7881 Bupe Mwakibete F 91 A

Application of records
The following are the application of records:
(a) It is used to store data or information in a database such as Microsoft Access.
(b) It is used to group similar data.
Record operations
The record operations include creating, accessing, and updating the field in the
record.
Creating a student’s record
The keyword ‘record’ is used to create records specified with the record name and
fields. Its syntax is as follows:
record (recodname, {field1, field2, field3, field4 … … . fieldn})
The syntax to insert values into the record using C++ is as follows:
#recordname {fieldName1 = value1, fieldName2 = value2, fieldName3 = value3 .
. . . fieldNamex = valuex}

Example: A program to create a record using the C++ programming language.


#include <iostream>
#include <string>
using namespace std;
class student {

17
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 17 23/01/2023 11:26:42


public:
Computer Science

string student_name;
int student_id;
};
int main(){
student S;
S.student_name =”Maro Sambayeti”;
S.student_id =7880;
return 0;
}

Example: A program to access record values in the C++ programming language


#include<iostream>
#include<string>
using namespace std;
class student {
public:
string student_name;
int student_id;
};
int main(){
student S;
S.student_name=”Maro Sambayeti”;
S.student_id=7880;
cout<<S.student_id<<”\n”<<S.student_name;
return 0;
}

Output is shown in Figure 1.12

Figure 1.12: Output of a program to access record values.

Note: Starting the number with zero (0) will make it octal; therefore, the program
will display an error.

18
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 18 23/01/2023 11:26:42


Exercise 1.2 In computer science, the data types
defined by the user are called derived

Computer Science
Answer the following questions: datatypes or user-defined data types. In
1. Describe the static data structure. a programming language, user-defined
data types are defined by the users in the
2. Identify any four (4) advantages and program to suit their needs to store data
disadvantages of static data structure. either of the same or different types as per
3. With examples, describe the types their requirements.
of arrays. User defined data types are also known
4. Explain how to declare variables in as Composite data types. They are called
an array. Give two examples. composite because they are derived from
5.  What are the advantages and more than one built-in data type used
disadvantages of arrays? Describe to store complex data. These complex
any three for each. format data might contain tabular
data, graphical data, and databases.
6. Explain the applications of arrays. For this purpose, we use complex data
7. Describe the array operations. types called user-defined data types.
8. Give the meaning of the pointer. For every programming language,
9. Show how to declare a pointer in there are different types of user-defined
C++ data types. In C++, these user-defined
data types are class, Union, structure,
10. Point out the four advantages of a enumulation, and typedef.
pointer
(a) Class: This is a user-defined
11. Explain the application of pointers. data type that holds data members and
12. What is the meaning of records? functions whose access can be specified
13. Suppose Juma wants to write a as private, public, or protected. It uses
C++ program that uses 12 blocks the ‘class’ keyword for defining the data
of elements in memory, using the structure.
static data structure. He is then (b) Structure: A structured data type
expected to store the other six groups data items of different types into
more later. What would be the a single type. For example, a structure
consequences of the program? can be an address, which contains
information such as block number, plot
number, building name, street, city,
country and pin code. The keyword
User-defined data types “struct” is used to define this.
The user-defined data types allow a (c) Union: The Union is a type of data
programmer to develop his/her data structure where all the members of that
types and define what values program Union share the same memory location.
can take, for example, class, structure, If any changes are made in the Union,
union, and enumeration. These data they will also be visible to others. The
types hold more complexity than pre- ‘union’ keyword is used to define this
defined data types, but they can assist a user-defined data type.
programmer in reducing errors.

19
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 19 23/01/2023 11:26:42


(d) Enumeration: It helps to assign For example, you can create a structure
names to integer constants in the to store the student’s marks
Computer Science

program. The keyword ‘enum’ is used. struct student //


It is used to increase the readability of student as structure name
the code. {
(e) Typedef: This defines a new name //structure members
for an existing data type. It does not int stdid;
char stdname[40];
create a new data class. It makes code float marks, attendance;
readability easy and gives more clarity };
to the user.
Application of user-defined data
structure Example: The C++ program to
demonstrate structures in C++
(a) User-defined data types are the
building blocks for other data // C++ program to demonstrate
types that model the structure and // Structures in C++
behaviour of data. #include <iostream>
(b) They are used to implement using namespace std;
mathematical vectors and matrices. struct Point {
(c) They are used to model sets     int x, y;
or collections in computer };
programming. int main()
(d) It creates other data structures such {
as, lists, stacks and queues.     // Create an array of
structures
The structure     struct Point arr[20];
    // Access array members
A structure is a collection of multiple
    arr[0].x = 20;
variables of different data
    arr[0].y = 50;
types grouped under a single name for
convenient handling. The members of     cout << arr[0].x << “, “
<< arr[0].y;
structures can be ordinary variables,
    return 0;
pointers, arrays or even another structure.
}
Declaring structures
The structures are created by using the
struct keyword
The program’s output is 20, 50 as shown
in Figure 1.13.
struct
{
member a;
member b; Figure 1.13: The output of the program
....; to demonstrate structures in C++
member n;
};

20
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 20 23/01/2023 11:26:42


Union Enumeration

Computer Science
The Union is a user-defined data type In C++, an enumeration (or enum)
in which all members share the same is primarily used to give integral
memory place. For example, in the constant names, making the program
following C++ program, y and z share easier to comprehend and maintain.
the same location. If we change z, you In enumeration, if you do not provide
can see the changes reflected in y. the integral values explicitly to the
strings, then, in that case, the strings
#include <iostream> automatically start assigning the integral
using namespace std; values starting from value 0, the same as
// Declaration of union is the case of 0-based indexing.
the same as the structures
Points to remember for C++ Enum
union test {
    int y, z; (a) enum improves type safety
}; (b) enum can be easily used in switch
int main() (c) enum can be traversed
{
// A union variable t
enum
(d)  can have fields, constructors
union test t;
and methods
// t.z also gets value 4 enum
(e)  may implement many
t.z = 4; interfaces but cannot extend any
cout << “After making z = 4:” class because it internally extends
         << endl the Enum class
         << “y = “ << t.y
Example:
         << “, z = “ << t.z
         << endl; enum result {pass = 60, fail = 16};
// t.y is also updated to 20 Here, we have given the integer value 60
    t.z = 20; to be pass and 16 as fail; therefore, if we
cout << “After making Z = 20:” write,
         << endl enum result res;
         << “y = “ << t.y
         << “,Z = “ << t.z
res = pass;
         << endl; Then, the value of res would
    return 0; automatically be 60.
}
Typedef
The program’s output is as shown in The keyword typedef in C++ allows you
Figure 1.14: to define new data type names explicitly.
The use of typedef does not create a
new data class but establishes a name
for an existing type. This can improve
Figure 1.14: The output of a program a program’s portability (the ability of
to demonstrate union in C++ a program to be used across different

21
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 21 23/01/2023 11:26:42


types of machines, i.e., mini, mainframe (b) 
Reusability: Once defined, these
and micro without requiring significant data types can be reused within
Computer Science

changes to the code) because only the many definitions, saving coding
typedef statements would need to be time.
changed. By allowing descriptive names (c) 
Flexibility: They allow us to create a
for standard data types, typedef can also data structure per our requirements
help with self-documenting code. and needs.
(d) 
Encapsulation: In Java/Python, the
Syntax: variables and data values stored
in user-defined data types are
Typedef type name;
hidden from other classes as per
An example C++ program to demonstrate their accessibility declaration, i.e.
typedef user-defined datatype public, private, and protected. The
#include <iostream> data values remain hidden and safe.
using namespace std;
// After this line, BYTE
can be used   ctivity 1.1: Differentiating
A
// in place of unsigned char types of data structures
typedef unsigned char BYTE; 1. 
In pairs or groups of three,
int main() identify at least three uses for a 1
dimension array and three uses for
{
a 2-dimensional array.
   BYTE c1, c2;
   c1 = ″d″; 2. 
Compare array structures with
record structures, and decide if
   cout << ″ ″ << c1;
any of your uses would be better
   return 0; structured as records.
} 3. Show the stack, and the value of
the top pointer and base pointer
Output: when an item popped (taken out)
off the stack and 54 followed by 70
d
pushed onto the stack.
Benefits of user-defined data types
(a) 
User-defined data types store data
elements of either the same or
different types. This gives more
flexibility for the programmer to
store different data types in a single
variable as per their needs and
requirements.

22
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 22 23/01/2023 11:26:42


Exercise 1.3 (c) Easier to program as there is no

Computer Science
need to check data structure size.
1. What do you understand about the
user-defined types? Disadvantages of dynamic data structure
2. Describe the five types of (a) Because the memory allocation
user-defined data types. is dynamic, it is likely for the
3. Describe the structured type. structure to ‘overflow’ should it
exceed its allowed limit. It can
also ‘underflow’ should it become
Project: empty.
Develop a simple C++ program (b) It is complicated to program as the
that includes the struct, union, and
software needs to keep track of its
enum concepts. The program should
size and data item locations.
address any problem in your school or
community. (c) It can be very inefficient because
the memory for the data structure
is defined regardless of whether it
Dynamic data structure is needed or not when the program
Meaning of dynamic data structure is executing.
The dynamic data structure is the type Types of dynamic data structure
of data structure in which the size of Dynamic data structures are linked lists,
the structure is not fixed and can be arrays, and queues. Each of these types is
modified when the performance of discussed in the following subsections.
the operations is carried on them. The
dynamic data structures are designed to Linked lists
facilitate the change of data structures in
the run time. The size can be randomly The linked list is a dynamic data
updated during the run time, which structure, among others, that can grow
may be considered efficient concerning and shrink during the execution of a
the memory complexity of the code. program. The associated pointer would
Examples of dynamic data structures are give the memory location of the next
linked lists, stacks and queues. data item in the linked list.
Advantages of dynamic data structure Meaning of linked lists
The following are the advantages of A linked list is a sequence of data
dynamic data structure: structures connected via links. A linked
(a) It makes the most efficient use of list is a sequence of links that contain
memory since the data structure items. Each link has a connection to
only uses as much memory as it another link. The linked list is the
needs. second most-used data structure after
the array. The linked list can be defined
(b) The memory allocation is not fixed,
as a collection of objects called nodes
so there will be no problem adding
randomly stored in the memory. A node
and removing data items.

23
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 23 23/01/2023 11:26:42


contains two fields, the first, which data stored at that particular address and the
second is the pointer, which has the address of the next node in the memory. The last
Computer Science

node of the list contains a pointer to the null.


The following are essential terms to understand the concept of a linked list.
Link − Each link of a linked list can store data called an element.
Next − Each link of a linked list contains a link to the following link called Next.
Linked list − A linked list contains the connection link to the first link called First.
Head – Is the first node and tail is the last node.
Structure of linked lists
The structure of the linked list comprises two parts in each node. These parts are; the
one which represents data and that contain the address of the next node, as shown
in Figure 1.15.

Figure 1.15: Linked list

Advantages and disadvantages of linked list


Linked lists have both advantages and disadvantages over other data structures.
Advantages of linked lists
The advantages of linked lists include:
(a) Easy insertion and deletion of elements: Insertion and deletion are efficient and
take constant time as the links are manipulated hence, there is no need to give
the initial size of the list.
(b) No memory wastage: the size of the linked list increase and decreases during
runtime. This utilises the memory efficiently, hence, no wastage of memory.
(c) They can be expanded constantly: The linked list can grow and shrink depending
on the data to be inserted. With a linked list, you can start with space for just
one allocated element and then add on new elements easily without the need to
do any copying and reallocating
(d) Implementation: The implementation of stack and queue is very easy using a
linked list.
(e) Easy of moving pointer: In the linked list, it is very easy to insert and delete
a node. After insertion and deletion, there is no need to shift every element;
instead, it needs only to update the address in the next pointer.

24
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 24 23/01/2023 11:26:42


Disadvantages of linked lists (d) Implement stacks, queues, binary
trees and graphs of pre-defined size.

Computer Science
The following are the disadvantages of
a linked list: (e) The circular linked list is used in
(a) 
Memory usage: The node in a a slide show where a user wants
linked list occupies more memory to go back to the first slide after
than the array as each node occupies displaying the last one.
two types of variables, i.e., one is (f) 
A linked list is used for the
a simple variable, and another is polynomial implementation of
a pointer variable that occupies 4 mathematical operations.
bytes in the memory. (g) 
A doubly linked list is used to
(b) Traversal: In a linked list, traversal implement forward and backward
is not easy. If you want to access the buttons in a browser to move
element in a linked list, you cannot backwards and forward in the
access the element randomly, but opened pages of a website.
in the case of an array, you can (h) It is used when a user selects the
randomly access the element by desired application by pressing
index. For example, if you want the Alt+tab key combination
to access the 3rd node, you must to navigate through the opened
traverse all the nodes before it. application.
So, the time required to access a
particular node is extensive. Types of linked list
(c) 
Reverse traversing: Backtracking Linked lists can be divided into three types:
or reverse traversing is difficult in (a) A Singly-linked list is a linked list
a linked list. It is easier but requires traversed in one direction from
more memory to store the back head to tail.
pointer.
(b) The Doubly linked list is a type
Application of linked lists of linked list traversed in both
The following are some applications of directions, front and back.
linked lists: (c) A Circular linked list is a list in
(a) 
Implement dynamic memory which the last node points to the
management functions of the first node.
operating system. Linked lists operations
(b) 
A circular linked list is used to The primitive operations performed on
implement operating system or the linked list are as follows:
application functions requiring
(a) Creation
round-robin tasks execution.
(b) Insertion
(c) The linked list is used in a circular (c) Deletion
queue to maintain multiple players’
(d) Traversing
playing sequences in a game.
(e) Searching
(f) Concatenation

25
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 25 23/01/2023 11:26:42


Creation operation: This is used to create a linked list. Once a linked list is created
with one node, the insertion operation can add more elements to a node.
Computer Science

Insertion operation: Is used to insert a new node at any specified location in the
linked list. A new node may be inserted;
(a) At the beginning of the linked list
(b) At the end of the linked list
(c) At any specified position in between in a linked list. For example, Figure 1.16
shows the insertion operation of inserting a new node at the beginning of an
existing linked list where,
(i)  Show an existing linked list of the region in both Tanzania mainland and
Zanzibar island.
(ii) Shows the insertion of a new region called Tabora, and
(iii) 
Shows a resulting new liked list after insertion operation.
North
Dodoma Arusha
Pemba
(a)

North
Tabora Dodoma Arusha
Pemba
(b)
North
Tabora Dodoma Arusha
Pemba
(c)
Figure 1.16: Insertion operation
The deletion operation: This is used to delete an item (a node) from the linked list.
A node may be deleted from the;
(a) Beginning of a linked list
(b) End of a linked list and
(c) Specified location of the linked list. (See Figure 1.17).
North
Tabora Dodoma Arusha
Pemba
(a)

North
Tabora Dodoma Arusha
Pemba
(b)

North
Dodoma Arusha
Pemba
(c)
Figure 1. 17: Deletion operation

26
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 26 23/01/2023 11:26:42


Traversing: This is the process of going through all the nodes from one end to
another end of a linked list. You can visit from left to right in a singly linked list,

Computer Science
forward traversing, nodes only. In a doubly-linked list, forward and backward
traversing is also possible.
Concatenation: This is the process of appending the second list to the end of the
first list.
For example, consider a list A having x nodes and B with y nodes; then the operation
concatenation will place the 1st node of B in the (x+1)th node in A. After concatenation,
A will contain (x+y) nodes. (Figure 1.18)

Figure 1.18: Concatenation in a linked list

Stacks
Meaning of stacks
A stack is an Abstract Data Type (ADT) and is a linear data structure that can be
accessed only at one of its ends for storing and retrieving data. It is analogous to a
stack of trays in a cafeteria whereby, new trays are put on the top of the stack and
taken out the top. The last tray placed on the stack is the first tray removed from
the stack and based on this principle, a stack is called a Last-in-first-out (LIFO)
structure. Here, the element placed (inserted or added) last is accessed first. In stack
terminology, the insertion operation is called the PUSH operation and the removal
operation is called the POP operation.
A tray can only be taken if there is at least one tray on the stack, and a tray can
be added to the stack only if there is enough room when the stack is not too high.
Therefore, a stack contains operations that change its status and operations that
check this status. The operations are as follows;
clear()—Clear the stack.
IsEmpty()- determines whether the stack is empty. It returns 1 (true) if the stack is
empty otherwise, it returns 0 (false).
push()—Put the element on the top of the stack.

27
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 27 23/01/2023 11:26:42


pop()—Take the topmost element from an example because delimiter matching
the stack. is part of any compiler: No program is
Computer Science

topEl()—Return the topmost element in considered correct if the delimiters are


the stack without removing it. mismatched. In C++ programs, we have
the following delimiters: parentheses
Size(): Returns the number of elements “(” and “)”, square brackets “[” and “]”,
in the stack curly brackets “{” and “}”, and comment
A real-life example of a stack is a deck delimiters “/*” and “ */”. It is also used
of cards or a pile of plates. to undo, redo, and navigation bars.
Structure of stacks Stacks operations
The stack can be demonstrated as in PUSH operation
Figure 1.19.
The mechanism of PUSH operation in a
stack is conducted as follows:
Before embedding a component in a
stack, you check whether the stack is
complete.
If you attempt to embed the component
in a stack, and the stack is full, at that
point, the flood condition happens.
When you introduce a stack, set the
maximum estimation as - 1 to watch that
the stack is unfilled.
When the new component is pushed into
Figure 1. 19: T
 he stack structure and the stack, first, the size or number of the
its operation top gets increased, i.e., top=top+1, and
the component will be put at the new
Application of stacks position of the top.
Generally, the stack is beneficial when The components will be embedded
data are stored and retrieved in reverse until we arrive at the maximum size
order. One application of the stack is in of the stack (i.e. top = 3), as shown in
matching delimiters in a program. This is Figure 1.20.

Figure 1.20: Push operation

28
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 28 23/01/2023 11:26:42


POP operation (iii) Can you add a cap from the bottom
of the fixed rod? Give reasons.

Computer Science
The mechanism for POP operation in a
stack is conducted as follows: (iv) What types of data structure does
(a) Before erasing the component from the activity represent?
the stack, you check whether the Draw the diagram to demonstrate the
stack is vacant. activity of adding and removing the
(b) If you attempt to erase the bottle caps to and from the rods in the
component from the empty stack, abacus.
the sub-current condition happens. Can you give one example in your daily
(c) If the stack is not unfilled, you first life which exhibits the same principle in
access the component, which is this activity?
pointed at the top.
(d) Once the pop activity is played out,
the top is decremented by 1, i.e., Think about the following:
top=top-1.
The vehicles on weigh bridge or at
the narrow one-way bridge; then the
Activity 1.2: Demonstration phone calling and answering system.
of the stack
Afterwards, think about the basis on
Resources: which these incidents are being attended.
Is it on a last -in first-served or first-in-
Abacus, bottle caps, two pieces of spokes,
a piece of wood first-served basis? Lastly, think about
what will happen to other vehicles if one
Procedure: vehicle in the service fails.
Take an Abacus or make it using wood
and a piece of the spoke. Fix the pieces
of spokes into a piece of wood to create Queues
an Abacus Meaning of queue
Label the first rod “A” and the second The queue is an abstract data structure,
rod “B.” Take five bottle caps and put somewhat similar to stacks. Unlike
them into the first rod of an Abacus. stacks, a queue is open at both ends.
Take the other three bottle caps and the The queue follows the First-In-First-Out
first rod one after another. Take out three methodology, i.e., the data item stored
bottle caps from rod A to B in the abacus first will be accessed first.
Observe and write on the following: Queues are what you usually refer to as
(i)  Tell from which point the bottle lines. Its essential features are, that it is
caps were added. ordered and that access is restricted to its
(ii) Do you think you can remove the ends: things can enter a queue only at the
second cap from rod A without rear and leave the queue only at the front.
removing others on its top? Give The queue holds a sequence of elements
reasons. that allows insertions (enqueuer) only at

29
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 29 23/01/2023 11:26:42


one end, called the back or rear, and deletions (dequeuer) and access to elements at
the other end, called the front. In computing, queues are essential because resources
Computer Science

provide service on a first-come-first-served basis, such as jobs sent to a printer or


processes waiting for the CPU in an operating system.
A real-world example of a queue can be a one-way road or single-lane bridge, where
the vehicle first enters and exits. More real-world examples are queues at the ticket
windows and bus stops, banks, queuing for voting, taking food, and hospitals. Fig-
ure 1.21 shows the structure of the queues.

Structure of queues

Figure 1.21: Structure of the queue


Application of queues
The real-life queue is realised in what you all participate in from time to time. The
following are some of the applications that use queues:
(a) You wait in line at railway and bus stations for reservation counters and tickets.
(b) You wait in the dining halls and cafeteria line.
(c) You wait in a queue in the hospital when you want to present your illness case
to a doctor.
(d) You issue a print command from our office to a shared networked printer; the
print task is lined up in a printer queue. The print command issued first will be
printed before the subsequent commands in the line (in the queue).
(e) An operating system is also using different queues to control process scheduling.
Processes are added to the processing queue and used by an operating system
for various scheduling algorithms.
(f) The first-served scenario requires a queue to simulate real-world queues such
as lines at a bank counter or any other first-come.

Queues operations
The queues are a homogeneous collection of elements in which new elements are
added at one end, called the rear, and the existing elements are deleted from the other
end, called the front. The basic operations that can be performed on a queue are:
(a) Insert (or add) an element to the queue (enqueue)

30
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 30 23/01/2023 11:26:43


(b) Delete (or remove) an element from a queue (dequeue)

Computer Science
Enqueue operation will insert (or add) an element to the queue at the rear end by
incrementing the array index. The dequeue operation will delete (or remove) from
the front end by decrementing the array index and will allocate the deleted value to
a variable. When implemented using arrays, the total number of elements present in
the queue is front - rear+1. Figure 1.22 illustrates the basic operations of the queue.
Enqueue
(insertion)

Dequeue
(Deletion)
Front Rear

Figure 1.22: Queues operation

When deleting or removing an element orientation structure, the value of nodes,


from the queue, underflow occurs. It and the number of levels. Examples
is impossible to delete or remove any of tree data structures include binary,
element when no element exists in the B-tree, heap, and splay.
queue. Suppose the maximum size of
the queue when implemented using Binary tree
arrays is 20; if we try to enqueue, Meaning of binary tree
i.e., insert or add an element to the
A binary tree is a tree for which each
queue, overflow occurs. It is naturally
internal node is allowed to have at
impossible to insert more elements
most two child nodes. The children
when the queue is full.
of an internal node are called the left
Non-linear data structure child and the right child, depending on
the relationship with the parent. The
Tree
recursive definition of a binary tree is
A tree is a non-linear data structure that either a tree consisting of a single node
is an abstract and typically hierarchical or a tree whose root has an ordered pair
structure consisting of nodes with a of children, each of which is a binary
parent-child relationship. It is used tree. The applications of binary trees
in organisation charts, programming represent arithmetic expressions, create
environments, and file systems. There decision processes and search. Figure
are four basic things connected with 1.23 illustrates the structure of the
any tree: the distinction between nodes, binary tree.

31
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 31 23/01/2023 11:26:43


Structure of the binary tree
Computer Science

10

20 30

40 50 70
60

80 90
Figure 1.23: Binary tree

Binary tree operations


Inorder D, B, E, A, F, C, G
Preorder Traversal– A node is visited
before its descendants (in the example,
the Preorder traversal sequence is
10,20,40,80,90,50,30,60,70).
Inorder Traversal– A node is visited
between traversal of its descendants
in the example; the Inorder traversal
sequence is 80,40,90,20,50,10,60,30,70.
Postorder Traversal– A node is visited
after its descendants (in the example,
the Postorder traversal sequence is Preorder A, B, D, E, C, F, G
80,90,40,50,20,60,70,30,10).
Figure 1.24 shows the binary tree
traversing which will help you to
understand the binary tree traversal
quickly.

Postorder D, E, B, F, G, C, A

Figure 1.24: The binary tree traversing

32
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 32 23/01/2023 11:26:43


Note: If n is the number of nodes, x Pre-order operation in a binary tree
is the number of external nodes, i is

Computer Science
Algorithm for Preorder traversal:
the number of internal nodes, and h is
the height of the binary tree, then the (i) Visit the root.
following are the essential properties of (ii) Traverse the left subtree, i.e., call
binary trees: Preorder (left-subtree)
x=i+1 (iii) Traverse the right subtree, i.e., call
n = 2*x – 1 Preorder (right-subtree)
h>=log2x Uses of Preorder
h>=log2(n+1)-1 (i) Preorder traversal is used to create
a copy of the tree.
Inorder operation in a binary tree (ii) Preorder traversal is also used to get
prefix expressions on an expression
(i) Traverse the left subtree, i.e., call tree.
Inorder (left subtree)
Example: The Preorder traversal for the
(ii) Visit the root given Figure 1.26 is 11 23 41 15 13.
(iii) Traverse the right subtree, i.e., call
Inorder (right-subtree)
11
Uses of Inorder
For example, in binary search trees
23 13
(BST), Inorder traversal gives nodes in
non-decreasing order. To get nodes of
BST in non-increasing order, a variation
of Inorder traversal can be reversed. 41 15
For example, Inorder traversal for Figure
1.25 given tree is 14, 26, 58, 10,30. Figure 1.26: Preorder traversal
Example 1: Study the input in Figure 1.27.
10 Then, write its corresponding output by
using pre-order traversal.

30 21
26

23
14 58
62
41

Figure 1.25: The Inorder traversal


Figure 1.27: Pre-order traversal

33
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 33 23/01/2023 11:26:44


Output: 21 23 41 62 Output: 14, 35, 22, 43, 12
Computer Science

Post-order Application of binary tree


Algorithm for Postorder (binary tree) The following are the applications of
1. Traverse the left subtree, i.e., call binary tree:
Postorder (left-subtree) (a) The binary tree is used to implement
2. Traverse the right subtree, i.e., call indexing of the Segmented
Postorder (right-subtree) Database.
3. Visit the root. (b) It is used in implementing efficient
Uses of Postorder cache in hardware and software
systems.
(i) 
Postorder traversal is used to delete
the tree. (c) 
A binary Search Tree is used to
search elements efficiently and as
(ii) 
Postorder traversal is also helpful a collision handling technique in
for getting the postfix expression of hash map implementations.
an expression tree.
(d) The binary tree is the primary data
Example 2: Postorder traversal for the structure in Microsoft Excel and
given Figure 1.28. is 4 5 2 3 1. spreadsheets.
(e) A binary Heap (Binary Tree variant
1 of the heap) is used to implement a
Priority Queue efficiently, which is
3 used in Heap Sort Algorithm.
2
(f) 
A binary tree with nodes as
operations is used to compute
5 arithmetic expressions in some
4 compilers.
(g) A balanced Binary Search Tree is
Figure 1.28: The postorder traversal
used to represent memory to enable
Example 3: Consider input as given in fast memory allocation.
Figure 1.29 and its corresponding output
(h) 
A self-balancing Binary Search
using postorder traversal:
Tree is used in implementing games
to model a faulty search process
12 (i) Binary trees with 2 child is used
to represent routing data that
fluctuates efficient traversal.
22 43

Algorithms
14 35 Concept of algorithm
One of the significant steps to solving
Figure 1.29: Preorder traversal any problem is to analyse the problem.

34
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 34 23/01/2023 11:26:44


Analysing a problem involves implementing the given problem
understanding the problem and its requirement to solve a problem.

Computer Science
requirement. Problem requirements (b) The fastness or the slowness of the
include users, input data, output data designed system is measured.
and general system functionality. For
(c) We can solve the whole problem at
example, when one wants to develop
a time or divide it into manageable
a school management system, the
parts.
requirements might be the number
of students, teachers, and the school Characteristics of an algorithm
administrator who will be responsible The algorithm to solve the required
for updating data. After analysing a problem must be correctly and well-
problem, the next step is to design an defined. Thus must obey the following
algorithm. characteristics:
An algorithm involves step-by-step Finiteness: An algorithm should
(a) 
analysed procedures to solve a particular have a defined number of steps that
problem. It is a set of instructions must terminate at the end of the
written to accomplish the defined task. steps.
The algorithm is not a program, so
Definiteness: Every step in the
(b) 
you do not need to use a programming
algorithm should be defined in one
language to design it. It is just a way
meaning. The purpose of being
of solving a problem systematically,
conducted should be clear with no
which can be represented by either a
ambiguity.
flowchart or pseudocode. The algorithm
should define the beginning and end Effectiveness: Any operation
(c) 
of the problem with a specific number within the algorithm must be
of steps. The steps of the algorithm performed efficiently and follow
normally involve decisions, including the same principle required to
logic and comparison. All programs design the algorithm.
designed within the computer system Well-defined
(d)  inputs: The
are the implementation of the algorithm. quantities used as the input must be
Algorithms are used for calculation, data well-defined and specified.
processing and automatic reasoning. Well-defined output: An algorithm
(e) 
However, the concept of the algorithm must have well-defined results and
can be applied even in solving typical should match with the desired
daily life tasks, such as cooking food, output.
studying, teaching, and travelling.
Advantages of algorithms
Importance of algorithm (a) It is easy to understand because it
Through an algorithm; uses normal language in writings
(a) it is possible to know if there is a (b) It is the step-by-step representation
possibility of solving a particular of a solution to a given problem
problem or not. This includes

35
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 35 23/01/2023 11:26:44


(c) The problem is broken down into Step 1: Start
smaller steps for easier program
Computer Science

Step 2: Enter the first number


writing Step 3: Enter the second number
Disadvantages of Algorithms Step 4: Multiply two numbers and store
(a) Writing an algorithm needs time to the result
analyse the problem, which is time- Step 5: Display the result
consuming. Step 6: Stop
(b) It is difficult to write high-order
statements like branching and
Example 2: Algorithm to find the
looping in an algorithm.
largest number between two numbers
How to write an Algorithm Step 1: Start
As you have seen, an algorithm is a basic Step 2: Input two numbers, A and B
tool and very useful for understanding Step 3: Compare if A is greater than B; if
a problem through its step-by-step yes, go to step 4; otherwise, go to step 5
analysis. However, there are no well- Step 4: Print A is greater than B
defined standards for writing algorithms;
Step 5: Compare if B is greater than A; if
instead, it depends on the problem and
yes, go to step 6; otherwise, go to step 7
available resources. All programming
languages share basic code constructs Step 6: Print B is greater than A
like do, for, while, and if-else. With this, Step 7: Stop.
you note that an algorithm is not written
to support a particular programming Example 3: Write an algorithm to find
code, but these common constructs are the biggest of two numbers
used to write an algorithm clearly with
Step 1: Start
some steps as follows:
Step 2: Read two numbers, say A and B
(a) Determine the input and output of
the problem Step 3: If A > B, then BIG = A, otherwise
BIG = B
(b) Find the correct data structure to
Step 4: Write BIG
present the problem
Step 5: End
(c) 
Try to reduce the problem to a
variation of a well-known one
Example 4: Write an algorithm to find
(d) 
Decide whether you look for a
the Area of the Square.
recursive or imperative one or a
mixed algorithm Step 1: Start
(e) Write an algorithm Step 2: Input Side Length of Square says L
Step 3: Area = L x L
Examples of the algorithm: Step 4: Display AREA,
Example 1: Algorithm for multiplication Step 5: End
of two numbers

36
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 36 23/01/2023 11:26:44


Example 5: Write an algorithm to find inputs as a requirement of the second
Simple Interest. step. Suppose you want to arrange three

Computer Science
Step 1: Start books labelled A, B, C, the following
are the possible ways: ABC, ACB,
Step 2: Input value of Principle amount BAC, BCA, CAB and CBA. This means
(P), time in years (N), and % interest (R) there are six ways of arranging any three
Step 3: Calculate SI = (P x N x R)/100.0 objects. Mathematically, that scenario
Step 4: Display Simple Interest (SI) can be solved by using the concept of
factorial of n-object, for example, a 3!
Step 6: End
= 3*2*1 = 6 ways. This signifies that if
five students are sitting on the horizontal
Example 6: Write an algorithm to find bench, the ways of arranging them will
compound interest. be 5! = 5*4*3*2*1 = 120 ways.
Step 1: Start Generally, methods of organising any
Step 2: Input value of principle Amount given n-objects will be as;
(P), Time in Years (N), and % Annual n! = n x (n – 1) x (n – 2) x (n – 3) x (n –
Rate of Interest (R) 4) x.................x 2x 1.
Step 3: Calculate CI = P (1+R/100) N - P This system of breaking a problem into
Step4: Display Compound Interest (CI) more minor problems using the solution
applied to solve the main problem is
Step6: End called recursion.
Note: Two people can use different The algorithm that applies recursion to
algorithms in solving similar problems solve the problem is known as a recursive
as in the case of Example 2 and Example 3. algorithm. Recursive algorithms solve
a problem by breaking it into a simple
Types of algorithms problem using the same method by
repeatedly calling themselves.
In algorithms, you use to put similar
approaches in solving a problem in the
same group so that we can classify them Implementation of a recursive algorithm
one type of algorithm after another in
You can use a recursive function to
which a problem can be analysed briefly
implement recursive algorithms. The
and easily find a solution. There are
many algorithms, but this book deals recursive function contains a statement
with two fundamental types, recursive that causes the same function to execute
and iterative. again before completing the current call.
It is the function that calls itself until the
Recursive algorithms given condition is met. The result from
This is an algorithm that calls itself one execution in a recursive function is
repeatedly with a smaller value as inputs used as the input of the next recursive.
generated after solving the current The following example represents a
inputs until the problem is solved. This C++ program code to demonstrate the
means a process frequently uses the first recursive function:

37
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 37 23/01/2023 11:26:44


int factorial (int n) { The given solution explains that a
problem is split into more minor
Computer Science

if(n==0)
return 1; instances of the same problem.
else Note: The recursive function divides
return(n*factorial(n-1)); a problem into the base case and the
} recursive step. The base case is the most
From the given straightforward instance of the problem
demonstration code above; that stops the recursion function. It
factorial (3) = provides the result of the function when
3*factorial(2) the condition is met. Also, the recursive
factorial (2) = step is responsible for providing
2*factorila(1) solutions by making recursive calls and
factorial(1) = 1* factorial decreasing the size of inputs.
(0) Consider some of the positive integers:
factorial (0) =1,
Then, 1 + 2 + 3 + 4 + 5 + ................. n +1 =
factorial(3) = 3*2*1*1 n
∴ factorial(3) = 6.
∑ (r + 1)
r =0

Where:

Note: If there is no base case in the recursive function, the recursive function will
continue to repeat.
Recursive execution can be represented by using a data flow model. The box
represents procedure invocation through data flow into and out of the box shown in
Figure 1.30. Figure 1.31 represents the recursive data flow model and the use of the
data flow model to solve the recursive problem, respectively.

Figure 1.30: Data flow model for recursive execution

38
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 38 23/01/2023 11:26:44


Computer Science
Figure 1.31: Example of a recursive data flow model during execution

Examples of a recursive algorithm are Output 1


the sum of n-integers: The program asks the user to input any
Example 1: Write a recursive algorithm number to proceed, as shown in Figure
to find the sum of n-integers. 1.32, so enter any number and press
enter.
General algorithm for the recursive
algorithm will be given as:
Step 1: Start
Step 2: Assign sum = 0 and count = 0
Figure 1.32: Output 1
Step 3: Enter the range, n
Step 4: Compute count = count + Let us input 10 in a prompted message
n(count)
Step 5: Compute sum = sum + i as in Figure 1.33;
Step 6: Repeat step 5 and 4 until count Output 2
=n
Step 7: Print sum
Step 8: Stop
Example 2: Implement a recursive Figure 1.33: Output 2:
algorithm to find the sum of n-consecutive
integers in C++. Now press Enter and the final output
Syntax will be as in Figure 1.34.
#include<iostream> Output 3
using namespace std;
int sum(int n)
{
if (n!=0)
{ Figure 1.34: Output for a recursive
return n + sum(n-1);
} algorithm to find the sum of
return 0; n-consecutive integers in C++.
}
int main () Advantages of a recursive algorithm
{
int n; The following are the advantages of a
cout<<″Enter the recursive algorithm:
number:″;
cin>>n; (a) It reduces the number of lines of
cout<<″sum is:″ <<sum(n); code in a program.
return 0; (b) It is clear and straight for the
} programmer to understand.

39
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 39 23/01/2023 11:26:44


(c) Recursive algorithms simply solve Exercise: 1.4
complex problems.
Computer Science

1. Differentiate between algorithm


and program.
Disadvantages of a recursive algorithm
2. You want to do the homework, and
The following are the disadvantages of a you need a pen. Which algorithm
recursive algorithm: will you use to get a pen from a
(a) A recursive algorithm must include shopkeeper?
condition statements to terminate 3. (a) What is a recursive algorithm?
the recursion, otherwise, the
recursion will continue. (b)  Give two examples of a
recursive algorithm.
(b) 
Since the recursive algorithm
is repetitive, it requires enough 4. (a) How does the base case differ
processor time to complete the from the recursive step?
task. (b) 
Which effect will be arisen
(c) It simplifies a solution to the when the base case is not
problem when using a recursive defined in a recursive
algorithm. function?

 ctivity 1.3: Demonstration


A Iterative algorithm
of the Fibonacci number When a recursive algorithm produces
using C++ many repetitions, it is the best time to
use an iterative algorithm. An iterative
(i) Write the first ten Fibonacci algorithm involves the repetition of
numbers. some steps during problem-solving. The
iterative algorithm breaks a problem
(ii) How are numbers related in a into multiple iterative by adding some
Fibonacci series? features to get the correct solution. It
consists of iterative control structures
(iii) How does the Fibonacci number such as For loop, While loop, and Do....
define a recursive algorithm? while loop. Any iterative event should
have a condition to accomplish. For
(iv) Write a recursive algorithm to example, if you want to score a goal, you
generate the Fibonacci series. will kick the ball to the goalkeeper and
repeat it more than once until you score
(v) From your algorithm, state the the goal. So, achieving the plan will be
base case and recursive step. your condition to stop kicking the ball.
(vi) Develop a C++ program to display There are two types of iterations: definite
Fibonacci numbers. A program iteration, which provides a restricted
will prompt a user to enter the number of times when instruction should
range of the Fibonacci series and be repeated, and indefinite iteration,
where instruction is repeated within the
then display the output.
loop until another event stops.

40
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 40 23/01/2023 11:26:44


An example of the iterative algorithm Note:

Computer Science
is the conversion of binary to decimal (i) The iterative algorithm is more
numbers as follows: efficient than the recursive
algorithm in terms of speed of
Step 1: Start the program execution and memory usage.
Step 2: Read the binary value, n
(ii) 
The iterative algorithm can also
Step 3: Initialise dec=0, i=0 write any program that can be
Step 4: Check whether (n>0) written using a recursive algorithm
Step 5: Calculate r = n%10, dec += r *
pow(2, i); n=n/10, ++i
Step 6: Print the value of the dec . Exercise: 1.5
Step 7: Stop 1. (a) Identify the real-life example
where iteration is applied.
An example of a C++ program to (b) Write an iterative algorithm to
represent the implementation of an express the example.
iterative algorithm activity is as follows:
2. What are the advantages of using
#include <iostream> iterative over recursive algorithms?
#include <cmath>
using namespace std; 3. (a) Design an algorithm to find
int main() the sum of the digits made
{ from a positive number.
int n, dec=0, i=0, r; (b) Create the C++ program to
cout << ″Enter any binary implement the algorithm.
number: ″;
cin >> n; 4. (a) Change the following
while (n> 0) recursive algorithm to find
{ the reverse of the number in
r = n% 10; iterative form
n /= 10; Step 1: Start
dec += r * pow(2, i); Step 2: Enter the value of n
++i; Step 3: Assign r = 0, sum = 0
}
cout << ″Equivalent Decimal Step 4: If n>0
number: ″ << dec << endl; r = n mod 10
return 0; sum = sum *10 + r
} n = n div 10
Step 5: Repeat step 4 until the
The output of the program is as in condition fail
Figure 1.35.
Step 6: Print Sum
Step 7: Stop
(b) 
Develop a program of the
Figure 1.35: Output of the program given algorithm to display the
output.

41
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 41 23/01/2023 11:26:44


Searching algorithm the number equals the target. A system
of finding data among several elements
Computer Science

Meaning of search algorithms


within the list by comparing each value
You have studied how data is organised with the targeted value is known as
in different data structures such as an a linear search. Sometimes the linear
array, pointer, stack, and linked list. The search is known as a sequential search.
most important operation conducted in A linear search can be performed either
a linked list is a search algorithm. The within a sorted or unsorted list.
searching for the item within the list, The linear search algorithm derived
involves the following: from the given scenario is:
(a) Determine if the data is within the Step 1: start
list or not.
Step 2: Compare each number with the
(b) Check if the data are arranged for targeted number
quickly finding the location of data. Step 3: If the present number matches the
(c) Determine where the deleted data target, declare victory and stop
or item can be found. Step 4: If the present number is not
(d) To simplify searching for data or equal to the target, move to the
items within the list, each data set next number and repeat step 2.
should have a unique identified key. Step 5: stop
For example, if you want to search Example of a C++ program to implement
for details of a particular student the linear search algorithm activity
from a school database, student ID derived from the given cenario
as a uniquely identified key should
be used to search student details. #include<iostream>
using namespace std;
You will compare that key with int a[50], item, n, i;
the targetted records to find the void linearSearch()
required data. {
Generally, the search algorithm is for (i=0; i<n; i++)
designed to find or retrieve an item from if (item == a[i])
cout<<”the item is found
the list of data. There are two basic types
at location “<<++i;
of search algorithms, which are: return ;
(a) Linear search }
int main()
(b) Binary search {
Linear search cout<<”Enter number of
cars within the list: “;
Suppose you want to find a particular cin>>n;
car number from a list of car numbers. cout<<”Enter all numbers
The easiest way is to compare your within the list:”<<endl;
car number (target) with all numbers for (i=0; i<n; i++)
within the list by starting from the first {
cin>>a[i];
number to the last number. Searching
}
is over when you reach the point where

42
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 42 23/01/2023 11:26:44


cout<<”Enter number to

Computer Science
search: “;  ctivity 1.4: Searching a
A
cin>>item; word in a paragraph
linearSearch();
return 0; Write five sentences to explain
} about central processing unit (CPU).
The output of the program will be in Your explanation should include the
Figure 1.36: components and functions of each
element. Then, write a linear search
algorithm to find the word ALU.

Exercise: 1.6
Figure 1.36: Output of the program 1. What is a linear search algorithm?
2. What are the significances of using
Advantages of the linear search linear search in real life?
algorithm
(a) A linear search is performed very 3. Consider a list of the number with
fast if a list contains few elements. their position as represented in
Table 1.2
(b) Linear search does not need to
be sorted; anyhow data arranged, Table 1. 2: List of number and
searching is possible. their respective position
(c) Any operation within a list, Positions in a list Value
including insertion and deletion of
0 3
the items, will not affect the linear
search. 1 5

Disadvantages of the linear search 2 2


algorithm 3 9
(a) For the long list, linear search is
4 6
very slow
(b) Since linear search compares 5 1
all data within the list, it needs 6 8
more space and time to complete
searching. 7 7
Generally, the linear search seems to be (i) Write an algorithm to search
quietly inefficient. Suppose you have number ‘2’ from the list of the
1000 items, and the searched item is at data value.
the last position. Then, you will pass
through 999 items without getting the (ii) 
Develop a C++ program
value. However, the linear search can for the algorithm you have
work on any sorted or unsorted data set. designed in part (i).

43
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 43 23/01/2023 11:26:44


Binary search Step 7: stop
Computer Science

You have realised that sequential or linear Example of a C++ program to show
search is inefficient for an extensive list. the implementation of a binary search
Therefore, if you want to search data algorithm
from the list that contains many data,
use binary search. The binary search #include<iostream>
uses the divide and conquers approach to using namespace std;
search data within the list. Binary search int a[50], item, n, loc,
beg, mid, end, i;
divides the list into two portions when void binarySearch()
the list is sorted from the smallest value {
to the biggest value. After dividing the beg = 0;
list into two halves, compare the target end = n - 1;
with the middle item, then decide which mid = (beg+end)/2;
half to take up or down the middle while((beg<=end)&&(a[mid]
value. For example, suppose you want !=item))
to search for a number from the phone {
book, where names are arranged in if (item<a[mid])
end = mid - 1;
ascending order. Instead of looking for a
else
number from the first to the last, you can beg = mid + 1;
start from the middle and see whether to mid = (beg + end)/2;
go up or down depending on the position }
of a targetted name. The following is the if (item == a[mid])
algorithm and C++ program to explain cout<<″the item is found
the Binary search. at location ″<<mid +
1<<endl;
Algorithm else
Step 1: Start cout<<″Item does not
Step 2: S
 ort the list from small to the exist″<<endl;
}
large value int main()
Step 3: Find the middle value of the list {
Step 4: If the middle value of the list cout<<″Enter number of
items in the list: ″;
and the targeted value are equal, cin>>n;
declare the victory and stop cout<<″Enter all numbers
Step 5: If the middle item is less than within the list″<<endl;
the target, then remain with only for (i=0; i<n; i++)
upper items of the middle value, {
and from the list and repeat step cin>>a[i];
}
2 using the new list.
cout<<″Enter number to
Step 6: If the middle item is greater than search: ″;
the target, then continue with the cin>>item;
lower items list of the middle binarySearch();
value, repeat step 2 using the return 0;
new list. }

44
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 44 23/01/2023 11:26:44


The output of the C++ program (see (iv) Write a binary search algorithm to
Figure 1.37).

Computer Science
find the number of students who
failed the exam
(v) Use C++ programming language to
develop a linear and binary search
program
(vi) Compile and run the program
Figure 1.37: Output of the program (vii) 
Use the program to search the
number of students who have
Advantages of binary search average pass marks and above in a
class
(a) Binary search narrowed the long-
distance searching by dividing the (viii) T
 ake the snapshot of the output
list into two halves. and save it in a word processor file
(b) When the list of data is extensive,
binary search works more Exercise: 1.7
efficiently than linear search.
Answer the following questions
Disadvantages of binary search
1. Why do we need a search algorithm?
(a) Program a binary search algorithm
is complicated compared to a linear 2. What are the advantages of using
search binary search over sequential
(b) 
It is time-consuming to solve, search algorithms in solving a
especially if the binary search has problem?
many items. 3. 
Assume that you are required to
develop a program using the search
Activity 1.5: Developing algorithm, binary or linear. Which
a linear and binary search search is best for you? Give reasons
program to support your answer.
Resources:
Student score sheet, computer with C++ Sorting algorithm
compiler
Data should be arranged in ascending
Procedure: or descending order due to different
(i) Record current marks for computer reasons. You can organise data for
science subject from all students easy searching, reading, retrieving,
(ii) Set 50% to be a pass mark or otherwise. For example, a class
(iii) Write a linear search algorithm to teacher finds each student’s position
find the number of students who in a class after placing the students’
passed the exam marks in ascending order. The algorithm
responsible for putting data within a

45
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 45 23/01/2023 11:26:44


list in a required order is known as the (d) Heapsort
Computer Science

sorting algorithm. The sorting algorithm (e) Quick-sort


uses a comparison operator or divides (f) Merge sort
and conquer technique to decide the
new order of elements within the data
Selection-sort
structure.
Selection-sort involves sorting by
Types of sorting algorithms selecting elements in the list and shifting
There are various types of sorting them to their required position. The
algorithms, including: algorithm locates the smallest element
(a) Selection-sort at the top of the unsorted portion of the
list. The selection sort is most applied in
(b) Insertion-sort
an array. Figure 1.38 shows a selection-
(c) Bubble-sort
sort algorithm.

Unsorted list

6 6 2 2
10 10 10 4
Swap
4 4 Swap 4 10
7 7 7 7 Swap
5 5 5 5
2 2 6 6

Sorted list
2 2 2
4 4 4
5 5 5
7 6 6
10 Swap 10 7
Swap
6 7 10

Figure 1.38: Selection sort

Consider the following example for implementing the selection sort algorithm in
C++.

46
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 46 23/01/2023 11:26:44


#include <iostream> int findSmallest(int

Computer Science
using namespace std; school[],int i)
int findSmallest (int[],int); {
int main () int ele_small,position,j;
{
ele_small = school[i];
int school[6] =
{20,8,16,4,1,10};
position = i;
int pos,temp,pass=0; for(j=i+1;j<6;j++)
cout<<”\n Input list of {
elements to be Sorted\n”; if(school[j]<ele_small)
for(int i=0;i<6;i++)
{
{
ele_small = school[j];
cout<<school[i]<<”\t”;
position=j;
}
for(int i=0;i<6;i++)
}
{ }
pos = findSmallest (school,i); return position;
temp = school[i]; }
school[i]=school[pos];
school[pos] = temp;
pass++; Insertion-sort
} Insertion-sort puts an element in its
cout<<”\n Sorted list of proper place by comparing the value
elements is\n”; of data and considering the position of
for(int i=0;i<6;i++) a particular data. Insertion-sort divides
{ a list into sorted and unsorted sublists.
cout<<school[i]<<”\t”; Then, elements from the unsorted
sublist are placed in the correct position
}
in the sorted sublist. Insertion sort can
cout<<”\nNumber of passes be applied to sort data in linked data, as
required to sort the seen in Figure 1.39.
array: “<<pass;
return 0;
}

47
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 47 23/01/2023 11:26:44


Computer Science

6 6 4 4 4 2
10 10 6 6 5 4
4 4 10 7 6 5
7 7 7 10 7 6
5 5 5 5 10 7
2 2 2 2 2 10

KEY: Sorted list Unsorted list

Figure 1.39: Insertion sort

The general algorithm for writing #include<iostream>


insertion sort will be: using namespace std;
int main ()
Step 1: Start {
int studentMarks[12] = { 20,
Step 2: set temp = y [z] 45, 28, 24, 91, 55, 73, 80,
58, 99, 49, 45};
Step 3: set i = z – 1 cout<<”\nInput list is \n”;
Step 4: Repeat while temp <= y [i] for(int i=0;i<12;i++)
set y [i + 1] = y[i] {
set i = i – 1 cout<<studentMarks[i]<<”\t”;
}
[end of inner loop]
for(int k=1; k<12; k++)
Step 5: Set y [i + 1] = temp {
[end of loop] int temp = studentMarks[k];
int j= k-1;
Step 6: Exit while(j>=0 && temp <=
studentMarks[j])
{
Insertion sort implementation using studentMarks[j+1] =
studentMarks[j];
C++ language j = j-1;
Example of a program using C++ }
language which to sort the marks of 12 studentMarks[j+1] = temp;
}
students is as follows.
cout<<”\nSorted list is \n”;
for(int i=0;i<12;i++)
{
cout<<studentMarks[i]<<”\t”;
}
}

48
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 48 23/01/2023 11:26:44


The output of the program is shown in Figure 1.40.

Computer Science
Figure 1.40: Output for insertion sort implementation using C++

Bubble sort
Bubble sort is the comparison-based type of sorting algorithm. The bubble sort
algorithm sorts data by comparing and swapping elements if they are not in the
required order. It continues with the swapping of data until all data is sorted. For
the data which is arranged horizontally, such data in an array, bubble sort starts by
comparing the first two elements and then swapping them if they are not arranged
correctly, then arranging the second and third elements. Bubble sort is a stable sorting
algorithm but inefficient for large data volumes. Figure 1.41 shows an example of
the bubble sort algorithm.

Figure 1.41: Bubble sort algorithm

49
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 49 23/01/2023 11:26:44


Implementation of bubble sort:
Computer Science

The following is algorithms and C++ program to implement the bubble sort algorithm
Algorithm
Step 1: Start
Step 2: Compare the first and second element
Step 3: If the first element is greater than the second element of an array, swap them
Step 4: If the first element is less than the second element of an array, move to the
next elements
Step 5: Repeat step 1 until all data is sorted within the list
Example of a C++ program for bubble sort algorithm implementation:
#include<iostream>
using namespace std;
int main()
{
int n, i, arr[50], j, temp;
cout<<”Enter the size of array: “;
cin>>n;
cout<<”Enter “<<n<<” Numbers”<<endl;
for(i=0; i<n; i++)
cin>>arr[i];
for(i=0; i<(n-1); i++)
{
for(j=0; j<(n-i-1); j++)
{
if(arr[j]>arr[j+1])
{
temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
}
cout<<”\nThe sorted array is: \n”;
for(i=0; i<n; i++)
cout<<arr[i]<<” “;
cout<<endl;
return 0;
}

50
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 50 23/01/2023 11:26:44


The output of the C++ program to implement bubble sort is as shown Figure 1.42.

Computer Science
Figure 1.42: Output of the program

Example 1: Sort (5, 1, 12, 6, 23) using the bubble sort algorithm
Solution:
Step 1: (5, 1, 12, 6, 23) à (1, 5, 12, 6,23)
Step 2: (1, 5, 12, 6, 23) à (1, 5, 12, 6,23)
Step 3: (1, 5, 12, 6, 23) à (1, 5, 6, 12,23)
Hence, all elements are sorted.

Heapsort
Heapsort is a sorting method based on comparing elements. It is like a selection sort
where you first find the smallest element in the list and position it at the beginning
of the list. This process should be repeated to all elements within the list. Unlike
selection sort, heapsort does not use much time with a horizontal arrangement of
the unsorted element; instead, it has a way of quickly sorting the largest elements.
Figure 1.43 shows an example of the quicksort algorithm.

A 5 4 8 2 9 6

B 5 C 9

4 8 5 7

6 2 4 6
2 9
Maximum heap
Initial list

Figure 1.43: Heapsort

51
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 51 23/01/2023 11:26:45


Using the diagrams in Figure 1.43, you if (l < n &&arr[l] >arr[largest])
can now generalise writing an algorithm
Computer Science

largest = l;
for the heap-sort technique as follows:
if (r < n &&arr[r] >arr[largest])
Step 1: Start largest = r;
Step 2: 
From the given data, build a if (largest != root)
max heap from the given data {
such that the root is the highest swap(arr[root], arr[largest]);
element of the heap. Load(arr, n, largest);
Step 3: Remove the root, i.e. the highest }
element from the heap, and }
swap it with the last element of void loadSort(int arr[ ], int n)
the heap.
{
Step 4: Then, adjust the max heap not to for (int i = n / 2 - 1; i >= 0; i--)
violate the max heap properties Load (arr, n, i);
(heapify).
for (int i=n-1; i>=0; i--)
Step 5: The above step reduces the heap {
size by 1.
swap(arr[0], arr[i]);
Step 6: 
Repeat the above three steps Load(arr, i, 0);
until the heap size is reduced to 1.
}
Step 7: Stop. }
Remember, to sort the given dataset void displayArray(int arr[ ], int n)
in increasing order, you first construct {
a maximum heap for the given data for (int i=0; i<n; ++i)
as shown in the previous heap-sort cout<<arr[i] << “ “;
algorithm. cout<< “\n”;
Example: The following code }
demonstrates the implementation of int main ( )
heap-sort using C++. {
int heap_arr[ ] = {11,9,6,13,2,8};
#include <iostream>
int n = sizeof (heap_arr)/sizeof (heap_
using namespace std; arr[0]);
void Load(int arr[ ], int cout<<”Inputed array”<<endl;
n, int root) displayArray (heap_arr,n);
{ loadSort (heap_arr, n);
int largest = root; cout<< “Sorted array”<<endl;
int l = 2*root + 1; displayArray(heap_arr, n);
int r = 2*root + 2; }

52
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 52 23/01/2023 11:26:45


The output of the heap-sort program is as shown in Figure 1.44:

Computer Science
Figure 1.44: The output of the heap-sort program

Quicksort
Quicksort uses the divide and conquer sorting technique. The list is portioned into
two sublists, and each will be sorted and joined to form one list again. It uses the
recursion method to implement sorting. Quicksort divides a list into lower and upper
sublists separated by a pivot. A pivot is a selected element from the list that is more
significant than all elements in a lower sublist and less significant in an upper sublist.
Quicksort can be applied to sort data within an array. Figure 1.45 shows an example
of the quicksort algorithm.

10 6 4 7 13 12

Pivot = 10

6 4 7 10 13 12

Pivot = 6 Pivot = 12

4 6 7 10 12 13

Figure 1.45: Quick sort


MergesSort
Merge sort is also a divide and conquer sorting algorithm. It divides the list into
two halves and then merges the two sorted lists. Merge sort starts by dividing
the list into sublists and continues dividing sublists into two more halves while
swapping the elements, then combining swapped elements to form a completely
sorted list. Figure 1.46 shows an example of the quicksort algorithm.

53
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 53 23/01/2023 11:26:45


Computer Science

Figure 1.46: Merge sort

The following are things to consider to it is possible to make unstable sorts like
choosing the sorting algorithms for the heap and quick sort stable.
application:
Execution time
Stability of the sorting algorithms This explains a running time algorithm
The stability of a sorting algorithm is that can be set for data processing. It
considered by how it treats identical explains the average performance of the
elements. Stable sorting algorithms algorithm on every set of data. Usually,
maintain the order of equal or repeated execution time depends on recursive
elements, which is impossible for calls, memory usage, and comparisons.
unstable sorting. This is to say, stable Quicksort and merge sort are examples
sorting preserves the order of two of fast sorting algorithms.
similar elements within the list. Suppose
you want to sort the students according Memory usage
to their grades after already sorted Memory usage depends on the size of
based on their names; you must use the input data to be sorted. An example
a stable sort algorithm such as merge of a sorting algorithm that does not need
and insertion sort to sort similar grades extra memory is the insertion and bubble
without affecting their names. However, sort. Otherwise, merge sort and quick

54
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 54 23/01/2023 11:26:45


sort requires more memory to complete data structures are String, Boolean,
sorting. character and interger. A user-derived

Computer Science
Note: Depending on some factors, data structure that can store different
every sorting algorithm can be the best data types is the non-primitive data
or worst. These factors are based on the structure. Examples of non-primitive
problem to be solved and the data to be data structures include arrays, linked
manipulated. lists and stacks.
3. The data structure in which the
number of elements is fixed is the
Exercise: 1.8 static data structure. An example of
Answer the following questions: a static data structure is an array. The
data structure in which the number
1. Use the bubble sort algorithm to of elements is not fixed is known
arrange the following numbers in as a dynamic data structure. An
ascending order: 9, 3, 10, 2, 8, 5, 1. example of a dynamic data structure
2. Write a C++ program to display the is a linked list.
sorted list in question (1). 4. An array is a static data structure. It
3. Given the list of the elements: 6, 10, contains identical types of data. The
25, 8, 45, 15, whereby the first three elements in the array are stored in
elements are in order, how many consecutive memory locations. An
key comparisons are executed to example of an array is a[3] = {7,9, 11}.
move 8 to its proper position using 5. Stack is a non-primitive linear data
bubble sort? structure in which data insertion and
4. 
Given the list of elements to be deletion occur from only one end,
sorted: 25, 15, 22, 11, 24, 32, 13, known as the top.
70, 33, 55, 14, use bubble sort to 6. Pointers are usually auxiliary
determine the resulting list after six variables that indirectly allow users
steps. to access other variables’ values.
For example, int x, *p;. “x” is the
Chapter summary numerical variable in the declaration
while “p” is the pointer to the number.
1. The data structure is the standard
way of storing and organising data in 7. Records are the type of data structure
a computer for quick and efficient comprising a series of related data.
searching, sorting, and accessing Unlike an array data structure which
data. includes data of the same type, a
record contains data for different
2. The data structure available in the
kinds.
computer and generally defined
within a compiler is known as a 8. The queue is a non-primitive linear
primitive data structure. The primitive data structure in which data insertion
data structure stores only one type and deletion occur from two opposite
of data. Examples of primitive ends, rear and front.

55
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 55 23/01/2023 11:26:45


9.  A linked list is a dynamic data algorithms are classified into a
structure where nodes are linear and binary search
Computer Science

connected using a pointer. Each 18. 


Linear search is the algorithm
node in a linked list contains data that traverses the list entirely and
and addresses related to the next matches each list’s value with the
node in a list. targeted value.
10. User-defined data structures are
19. 
The binary search uses the divide
data structures implemented
and conquers technique to find
independently within a computer
elements after sorting the list.
program. These data structures
are built by combining primary 20. 
The sorting algorithm is
and built-in data types and then an algorithm that puts elements of
associating operations. Examples a list into ascending or descending
of such data structures are Class, order.
Structure, Union, Enumeration, and 21. 
Types of sorting algorithms include
Typedef defined Datatype selection sort, merge sort, heap
11. A binary tree is a non-linear dynamic sort, insertion sort, bubble sort and
data structure in which two or more quick-sort
children make each node. Binary 22. 
Bubble sort is the sorting algorithm
trees are used to implement binary that works by repeatedly swapping
search trees and binary heaps for the adjacent elements if they are in
efficient searching and sorting. the wrong order.
12. The algorithm is the correct
sequence of steps of instructions Revision Exercise
required to solve a problem.
1. (a) What is meant by the term
13. The algorithm should be precise, data structure?
finite, definite, effective, etc.
(b) Give out the characteristics of
14. The approach to designing an static data structure.
algorithm can either be recursive or
iterative. 2. (a) What is an array?
15. The recursive algorithm explains (b) 
Differentiate the array from
the algorithm approach where the linked list.
the solution to the main problem (c) 
Explain the advantages and
depends on solutions of more minor disadvantages of an array over
instances of the same problem. the linked list.
16. An iterative algorithm involves (d)  Describe a programming
the repetition of some steps during situation that will lead a
problem-solving programmer to choose an
17. Searching algorithms are designed array or a linked list.
to find or retrieve an element stored 3. (a) 
What is the difference
in a data structure. Based on the between array and pointer
type of search operation, these data structure?

56
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 56 23/01/2023 11:26:45


(b) With examples, briefly 12. (a) Write an algorithm to find the
describe the following as

Computer Science
length of a password.
used in the data structure:
(b)  
Write a C++ program to
(i) Stack implement the algorithm
(ii) Queue made in part (a).
4. Describe the stack implementation 13. (a) What is linear search?
in the C++ program in an array.
(b) 
Explain steps to implement
5.  By using illustrations, describe
linear search.
operations done in the stack data
structure. 14. (a) What is the binary search?
6. Describe four operations that the (b) The following form an array:
queue can perform. 10, 31, 0, 9, 38, 20, 13, 24, 7
7. Sort the numbers: 55, 44, 83, 26, and 200. Why is it impossible
47, 66, 92 and 72 in a binary tree to locate key “0” using binary
structure and arrange them in Pre- search?
Order, In-order, and Postorder.
15. (a) 
By showing steps clearly,
8. State three (3) features of a suitable show how binary search is
algorithm.
implemented to find an element
9. Design an algorithm for a program in the following Array, and let
that inputs the radius of a circle the searched key be 56.
from a user. The user will be
asked by the program to calculate Elements Index
diameter, circumference, or area. 10 0
The result will be calculated and
then displayed. 12 1
10. Write an algorithm to find squares 24 2
of the number. 29 3
11. Write a C++ program for the 37 4
following algorithm
40 5
Step 1: Start 51 6
Step 2: Enter two numbers A and B
56 7
Step 3: Check if A is greater than B, if
yes go to step 4 else go to step 5 68 8
Step 4: Print A is greater than B
Step 5: Check if B is greater than A, if (b) Use a C++ program to
yes go to step 6 else go to step 7 implement the given algorithm.
Step 6: Print B is greater than A 16. (a) What is bubble sort?
Step 7: Print A is equal to B (b) Explain the implementation of
Step 8: Stop bubble sort.

57
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 57 23/01/2023 11:26:45


17. Read the following C++ code and Project to develop a simple
answer the questions that follows: program using C++
Computer Science

int a[5] = {2, 5, 4, 1, 3}, Ketox is a service rendering application


i, k; system. The application aims to create
int x; a bridge between service providers
for(i = 0; i<4; i++) and clients to ease the accessibility
of business-related services. The
{ application has two sides, one for the
for(k = 1+i; k<5; k++) service provider and another for the
{ clients. Each side defines business
privileges to the particular side.
if(a[i]<a[k])
The client-side has the following
{
privileges:
x=a[i];
(i) Search for a service provider and
a[i] = a[k]; order the service.
a[k] = temp; (ii) Get all the necessary information
} about any service provider.
} (iii) 
Pay for any ordered service
} through any mobile money service
application.
(iv) 
Rate and comment upon the
(i) How many elements are services provider.
included in an array?
The service provider has the following
(ii) What type of sorting algorithm privileges:
is implemented on the given (i) Receive requests from clients.
code? (ii) Get a short portfolio of all clients
(iii) In which order the array “a” who need service.
will be sorted? (iii) 
Approve payment soon after
receiving the message of the money
(iv) Which variable will be used sent by the customer from mobile
temporarily in the given code? money application services.
Justify your answer.
(iv) Rate and comment upon the clients.
(v) Write a complete C++ program Design the system’s algorithm, then use
to display the sorted array “a.” it to implement the system using a C++
programming language.

58
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 58 23/01/2023 11:26:45


Chapter

Computer Science
Two Information systems

Introduction
Nowadays, people and organisations use various information systems to handle
their daily activities in healthcare, education and training, financial transactions,
administration, agriculture, tourism and other sectors. For example, the Tanzania
Institute of Education (TIE) online library gives students and teachers textbooks and
video conferencing facilities to facilitate business meetings, and instant messages. In
this chapter, you will learn about these information systems and how to manage and
apply them in real life. Important issues related to information systems in general,
like database systems, relational databases, and database management, will be
covered. The competency achieved will enable you to design, develop, manage, and
use various information systems.

Overview of Information Data and information


Systems Data is a collection of unprocessed
Information systems facilitate corporate raw facts, which have no meaningful
and individual operations, interaction, context, whereas Information is
and decision-making. An information processed data organised and presented
system is usually a computer-based in a meaningful context. Examples of
system designed to support operations, data are numbers, symbols, characters,
management, and decision-making. texts, and multimedia forms, e.g., 125A.
Also, Information Systems are Four data types representing these facts
combinations of hardware, software, are shown in Table 2.1.
and telecommunications networks that Examples of information are such as
people build and use to collect, create, reports, transactions, and processed
and distribute valuable data, typically in data. The primary function of the
organisational settings. An information Information System is to receive the raw
system is made of different components data (not processed) and then process
that work together to provide value to it to produce the information with
an organisation; it includes hardware, meaningful contexts, such as reports and
software, data, people, and procedure. other information formats.

59
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 59 23/01/2023 11:26:45


Table 2. 1: Forms of data representation
Computer Science

Data Represented by
Alphanumeric data Numbers, letters, and symbols characters
Image data Graphic images and pictures
Audio data Sound, noise, or tones
Video data Moving images or pictures

Characteristics of information stakeholders. On the other hand, other


Information is a collection of data parts of this system are restricted to
organised and processed to have NECTA staff for administration matters;
additional value beyond the value of so, those who are authorised can access
individual facts. An examination officer, that part. Also, a telephone directory or a
for example, through an information phone book on your phone or computer
system, may want individual should be easy to obtain or access. It is
examination results summarised to see most often the first place when you look
the average, maximum and minimum for a phone number. However, because
grades achieved. Information originating no one stores the entire country’s phone
from information systems can help books, you can call a mobile phone
people in their organisations to perform customer care for numbers beyond
tasks more efficiently and help decision- what you have or utilise the internet to
makers achieve their organisation’s find out, information about a hotel in a
goals. Many businesses and other parties different country, say the Democratic
assume that reports are based on correct Republic of Congo (DRC).
and quality information. However,
this is not always true. Therefore, it is Accuracy
necessary to ensure that an Information The information generated by the
System’s characteristics regarding information systems must be accurate
the information to be produced are enough to be used as intended.
followed. Furthermore, there are several Obtaining 100 percent precise
characteristics of valuable information to information is frequently unattainable
consider when handling the Information because it is likely to be too costly to
Systems as follows: supply on time. The level of precision
varies depending on the situation. For
Accessibility example, information may need to be
Information should be easily accessible precise at the operational levels on a
by authorised users to obtain it in the supermarket checkout receipt. Accuracy
proper format and at the right time to meet is an essential feature of information
their needs. For example, the NECTA systems and the data they create. For
Examination system from which form example, suppose the government
IV and VI results are easily accessible to information based on the most recent
all students, parents, schools, and other census incorrectly reflects a rise or fall

60
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 60 23/01/2023 11:26:45


in births within a region. In that case, Appropriateness and relevance
the government’s plans and budgets in

Computer Science
The information supplied by information
that region will not reflect the reality. systems should be relevant or
This inappropriate reflection may lead appropriate for the task at hand. What is
to unrealistic planning such as allocated important to one person or organisation
budget for school and hospitals. might not be necessary to another. The
Completeness user will get annoyed if the material
An information system’s output should contains unnecessary data for the task.
include all of the user’s details. Otherwise, For example, detailed technical data on
it could not be a reasonable basis for equipment and production specifications
deciding. For example, suppose an can be relevant to the line supervisor but
organisation is given information on the may be irrelevant to upper management.
cost of selling laptops to a school, but not Objectivity or dependability
on the cost of service and maintenance.
In that case, the total cost of ownership Objectivity deals with the truth of the
based on the information provided will information that an information system
be significantly underestimated. presents and relies on. Only if you are
confident of the information’s reliability
Economical or cost-effective or objectivity can you use it confidently.
Information should be accessible at For example, you may go straight to the
a predetermined price, which may library to choose an appropriate book
change based on the situation. If for an essay on any subject if you have
obtaining information is expensive, an reasonable confidence in the accuracy
organisation may opt for less expensive and objectivity of information obtained
information elsewhere. For example, from a book or a library. This might be
suppose an organisation wishes to do a due to the reason that books in the library
market research study on a new product, are authored and edited by specialists
the survey could cost more than the in the topic, and the authors’ names are
product’s expected initial profit. The usually prominently displayed.
organisation would most likely choose
a less expensive information source in Secure
that circumstance. Unauthorized users should not be
Flexibility allowed to access information. For
example, in a college information
Information systems should be flexible
system, examinations and staff salary
to be used for a variety of reasons. A
information are sensitive; hence, they
procurement officer in a school, for
have to be secured against students and
example, might utilise information
other unauthorised persons.
on how much inventory is on hand
for a specific part to close a deal. The Simple
headmaster can use the same information
Information should be straightforward
to approve a new inventory, and a school
and in a format that permits it to be
accountant may use the same to secure
examined and used without the addition
the required amount of money.

61
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 61 23/01/2023 11:26:45


of excessive data. It is normal, for For example, the students’ results
example, to summarise financial data information in a school or university
Computer Science

or examination results and present information system has verifiable


them in figures, charts, or graphs. original transcripts in physical or online
Having too much information can lead systems that capture and store them.
to information overload, in which a
decision-maker or a consumer is unable Concept of information systems
to decide what is important.
An information system (IS) is a set of
Timely interrelated components that collect,
For a reason, it is necessary for the process, store, distribute data and
information to be delivered on time. information, and provide a feedback
Information from an information system mechanism to meet an objective.
that is obtained too late is useless. For Therefore, it involves a cycle that
example, if you get a brochure from a contains (input), manipulates (process),
theatre and see that your favourite band distributes information (output), and
had a show yesterday, the information is offers a corrective reaction (feedback)
too late to be helpful. to fulfil a system goal, as indicated in
Verifiable Figure 2.1. The feedback mechanism is a
critical aspect of a system’s performance
Information should be able to be verified.
This means that you may double-check since it aids organisations in achieving
it for accuracy, perhaps by examining their objectives. For example, increasing
many sources for the same information. efficiency and enhancing customer
service.
Feedback

Input Processing Output

Figure 2.1: An information system (input, output, processing, feedback)

Input
Input is the action of acquiring and capturing raw data in information systems.
For example, when creating payroll checks, each employee’s number of hours
worked must be gathered before the payroll check can be generated and printed.
Supervisors must submit their employees worked hours in a payroll system as
indicated in Figure 2.2 to generate payroll checks for the given employees.
In the payroll system demonstrated in Figure 2.2, the input goes through a
transformation process to produce output with the possibility of improving the input
and process through feedback.

62
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 62 23/01/2023 11:26:45


Feedback
Hours

Computer Science
Worked

Payroll Payroll
Transaction checks
Processing

Pay rate

Figure 2.2: An example of a payroll system

Processing information, including output, available


The term “processing” in the context for future use.
of information systems refers to the Output
transformation of data into meaningful Producing an output in an information
outputs. Calculations, data comparisons, system entails creating valuable
alternative actions, and data storage for information, which is typically in the
future use is all part of the process. In form of documents and reports. In Figure
a computer system, converting data 2.2 of a payroll system, an output could
into valuable information is crucial. be the payroll checks for employees, a
Processing can be done manually or with report on payment for the management,
the help of a computer. For example, in the involved bank, and the employees’
a payroll system indicated in Figure 2.2, social security fund organisation. In
the number of hours each person worked some circumstances, one system’s
must be converted to pay per day, week, output can be used as input for other
or month, based on the agreed-upon systems. For instance, the output can be
payment arrangement. Other inputs, used as input for the said/involved social
in this case, can be an employee ID security fund organisations.
number and department. To calculate
gross compensation, start by multiplying Feedback
the number of hours worked by the Feedback is information from a system
employee’s hourly pay rate. Overtime used to modify input or processing in
pay may be included if weekly hours the information systems. Errors may
worked exceed 40. Then, to get net trigger the correction of input data or
pay, deductions such as government the modification of a process. Consider
taxes, insurance contributions, and loan the case of the payroll system indicated
payments are removed from gross pay. in Figure 2.2. Perhaps an employee’s
These calculations and comparisons are number of hours worked was 300 rather
usually saved in storage devices when than 30. Fortunately, most information
they are completed. The term “storage” systems validate data, ensuring that data
refers to the process of keeping data and fall within predefined limits. Because

63
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 63 23/01/2023 11:26:45


an employee will rarely work more than Output: Reports, rentals
(iii) 
100 hours in a week, the range for the agreement
Computer Science

number of hours worked may be 0 to 100. (iv) Feedback: Error reports


The information system would identify
that 300 hours are outside the acceptable 4. In the Car Plant
range and notify the user. The feedback Inputs: Raw materials
(i) 
is used to double-check and correct the components
input of 30 hours worked. This mistake (ii) Processes: Assembly line
would result in unnecessarily high net
(iii) Output: Mini-vans
pay if it went undiscovered.
Feedback: Customer surveys,
(iv) 
Figure 2.3 illustrates the components
quality reports
of the information systems in the
way a computer receives data (input), Characteristics of information system
manipulates it (process), and provides
the results (output). Some output may The following are characteristics of the
be different than you imagined when information system:
you look at the results offering you (a) Organises data into information
some ideas for how to make it better (b) 
Analyses information to give
(feedback). knowledge during data processing
Examples of Information Systems: from input to output.
1. Food Information System (c) 
Processes data and transform
(i) Inputs: Consumer orders them into valuable information for
decision-making.
(ii) Processes: Processing software
(d) Promotes evidence-based decision-
Output: Receipts, cook’s
(iii) 
making like, producing reports.
order list
(e) Automation of workflows through
(iv) F
 eedback: Invalid entry
computerised processes involving
message
users in each work field.
University /College information
2. 
(f) Enhances usability by providing an
system
accessible user interface that makes
Inputs: Students, faculty,
(i)  it easy to use.
textbooks
(ii) Processes: Education/Courses
Components of information system
(iii) Output: Graduates
The computer based information system
(iv) Feedback: Surveys, grades components comprise of hardware,
software, telecommunications
Video Library Information
3.  (communication channels including
System computer networks and the Internet),
(i) Inputs: Rentals, returns people, and procedures. Information
(ii) Processes: Processing software system components are put in place by
an organisation to help with its processes

64
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 64 23/01/2023 11:26:45


or human activities. People or machines can communicate and work together to
achieve a goal in this digital age. This set forms the components of an information

Computer Science
system, as indicated in Figure 2.3.

Figure 2.3: Components of an information system

These components are interconnected and magnetic ink-reading equipment


and work together to provide a solution are examples of input devices. Smaller,
to problems faced by society, allowing faster, and more transportable input
them to achieve their objectives. The devices that automate this process are
following is a list of each component’s becoming popular in the computer
description: industry. Computer chips with a central
Hardware processing unit and primary memory are
examples of processing devices.
Hardware is any physical/tangible part
of the computer. It is utilised to conduct Many automated operations that we
computer input, processing, storing, and undertake today in our offices, banks,
output operations. Input devices capture colleges, schools, organisations, and
instructional data or instructions that as individuals are done swiftly and
can be transformed into alphanumeric, efficiently with handheld, lower, and
picture, sound, or video data. Keyboards, medium-range computer equipment.
mouse, fingerprint and other pointing Furthermore, because of powerful
devices, automatic scanning devices, supercomputers, complex tasks such as

65
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 65 23/01/2023 11:26:45


the design of new autos that used to take of the computer. There are two types
two to three years are now doable in a of software; systems software and
Computer Science

relatively shorter period. Output devices application software, both of which


handle the result of the computer’s interact in use, including hardware,
processed input. They include printers as illustrated in Figure 2.4. System
and computer screens. For example, software coordinates hardware and
computers with sensitive touch-screens software processes. They include
that may execute certain task or run Operating Systems like Microsoft
applications, including opening the Windows and Android, utility programs
Internet or launching a new computer like Norton antivirus software, and
game or word processor. development programs like C++.
There have also been numerous special- Applications software includes general
purpose hardware devices built, such as application software like Microsoft
Event Data Recorders (EDRs). These Office that allows users to perform
devices are currently being installed in cross-cutting tasks such as editing text
many places such as, vehicles where documents, analysing data, and creating
they serve as the blackboxes to capture graphs. Specific application software
information on driver performance, solves particular problems such as
potential engine faults, and road speed human resource systems and student
of the vehicle. Many individuals prefer systems. All forms of computers, from
the mobility, functionality, and cost of small handheld computers to massive
tablets and smartphones, which give
supercomputers, require both systems
computing power, access to applications,
and application software. For instance,
and communications services whenever
Google’s Android operating system and
and wherever the user wants them.
associated apps like Google Maps are
Software designed specifically for touch-screen
The software consists of the computer mobile devices such as smartphones and
programs that govern the operation tablets.

Figure 2.4: Use of application software and systems software and how they relate

Database as an application software


A database is an organised collection of facts and information, usually two or more
related data files. Clients, employees, students, inventory, sales, online purchases, and
much more can all be found in an organisation’s database. For example, the Online

66
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 66 23/01/2023 11:26:46


Loan Application and Management Mobile devices such as cell phones
System (OLAMS) by Tanzania Higher and tablets can connect via wireless

Computer Science
Education Students’ Loans Board transmission. People can work from
(HESLB) handles over 100,000 home or on the road because of telecoms.
applicants for loans for higher education. Telecommunications also allow virtual
Data are collected from all interested teams of people working on a project
beneficiaries, mostly from higher to meet and interact without physical
learning institutions and intermediate meetings. For example, during the
college graduates. Data is collected from COVID-19 pandemic, when the social
people seeking for loans as well as those distance was required, many people
who have already graduated are now were able to work and learn from their
required to repay. Thousands of them homes.
and a Higher Education Students Loans
Networks, on the other hand, enable
Board (HESLB) staff utilise the system
electronic communication by
every year. This includes registration,
connecting computers and equipment
application, follow-ups, and issuing
within a building (Local Area Network-
and refunding the loan by beneficiaries
LAN) such as an administration
and employees, resulting in an increase
block in a school; across the buildings
in digital data and significant database
(Metropolitan Area Network-MAN)
and device storage requirements. The
such as various colleges’ buildings in
OLAMS systems database makes it
simple and convenient to obtain the a University; and across the country
data, for use in operations and decision- or countries (Wide Area Network-
making. For example, HESLB staff can WAN) such as in the Southern African
obtain a detailed report of beneficiaries Development Community (SADC)-
who received loans to study at a specific wide based company.
university. Furthermore, the Internet is a vast
network that connects computers
Telecommunication, Network, and worldwide. In today’s technological era,
the Internet most organisations do their operations
Telecommunication is the transmission over the Internet. Organisations and
of information by various technologies individuals make their daily tasks more
over the wire, radio, optical, or other productive and comfortable through
electromagnetic systems. Categorically, various Internet use. Major uses of the
telecommunications can take place Internet that play a vital role in daily
through wired, wireless, and satellite life include online bookings and orders,
transmissions. People may now see cashless transactions, education, online
the news live as it happens, including banking, and trading. Others include
breaking news events, due to satellite research, electronic mail, job search,
communication networks that have social networking, collaboration,
eliminated delays in news transmission. entertainment, e-commerce, file transfer,
People and organisations of all sizes are navigation, advertising, and real-time
using telecommunications worldwide. updates, as indicated in Figure 2.5.

67
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 67 23/01/2023 11:26:46


Computer Science

Figure 2.5: The uses of the Internet that play a vital role in daily life

The technology used to create the Internet assistance from other organisations.
is also being applied within organisations Dalsey Hillblom Lynn (DHL) is a large
to develop intranets, which allow company that empowers customers to
people in an organisation to exchange serve themselves at their convenience
information and work on projects. through a corporate extranet. Through
Through the internet, employees can its customers’ information system,
quickly access the internet; employees customers can access the DHL extranet
can promptly access work resources, to obtain a full range of shipping, billing,
collaboration, and fun. An extranet is and tracking services.
a network based on web technologies
that allow selected outsiders, such People
as business partners and customers, People are the most vital component of
to access authorised resources of an computer-based information systems.
organisation’s intranet. Many people They make it possible for the computer
use extranets daily without realising it system to work effectively, improve and
to track shipped goods, order products solve society’s challenges and problems.
from their suppliers, or access customer All persons who utilise, manage, run,

68
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 68 23/01/2023 11:26:46


develop, program, and maintain information systems; including IT professionals
who handle technical aspects and end-users who work directly with information

Computer Science
systems to get outcomes, are considered information systems personnel, as shown
in Figure 2.6. End-users include finance executives, marketing representatives,
sales persons and manufacturing operators, while IT professionals includes systems
analysts, persons, network engineers, and systems administrators.

Figure 2.6: P
 eople - End-users & IT professionals that use, manage, develop and
maintain the system

Procedures
Procedures are strategies, policies, and guidelines for using a computer-based
information system (CBIS) more effectively to meet the organization’s objectives.
They define the processes to achieve a given result, such as submitting a customer
order, paying a supplier invoice, or getting a current business-oriented report at
the entry-level. From the end users’ and IT professionals’ perspectives, reasonable
procedures outline how to reach the desired result, who does what and when, and
what to do if something goes wrong. People who are adequately taught and follow
effective procedures available in various ways can complete tasks faster, save money,
better use human resources, and help people adapt to change. Procedures clearly
documented, such as in user manuals, systems manuals, and Frequently Asked
Questions (FAQs), can drastically minimise training costs and time to mastery. This
also applies to the availability of high-level policies and strategies that are aligned
with the objectives of these information systems in the organisation.

69
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 69 23/01/2023 11:26:46


4. 
What is a computer-based
Computer Science

Activity 2.1 information system? How does it


differ from a traditional file-based
An information system consists of system?
input, processing/procedure, output,
and feedback. Identify an information 5. 
Two of the system components
system in your school or community of a computer-based information
as a whole and describe how it works system are hardware and software.
based on these elements, and its impact Describe the importance of each
on society. Also, identify the input, and, with an example, explain how
processing, and output of the specified
they depend on each other.
information system.
6. 
Suppose you had to explain the
concept of an information system
to a family member. How will it be
Activity 2.2
defined? In one paragraph, write a
Use an internet search engine or any description that best describes an
other means to find an information information system to your family
system example in real life, and describe using your own words.
how its components interlink and work
together to achieve a specified goal
successfully. Types of information systems
Today’s information systems come in
Exercise 2.1 various shapes, sizes, and functions
and cover a variety of scopes. While
1. Using any two examples, describe some information systems are unique
the importance of information and others vary somewhat from one
systems in today’s digital society. organisation to another, they can usually
be grouped by their basic functions
2. Briefly describe two of the valuable
into four main types of information
characteristics of information
systems. These types are Transaction
that modern information system
Processing Systems (TPS), Management
require. What is the difference
Information Systems (MIS), Decision
between them and their impact
Support Systems (DSS), and Executive
when developing, implementing,
Support Systems (ESS) or Executive
and using an information system?
Information Systems (EIS). They are
3. Describe five characteristics of an also summarised in Figure 2.7 and
information system. discussed next, including who uses
each system, the output, and trust for
each type. Their true potential is to help

70
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 70 23/01/2023 11:26:46


employees and managers to provide all necessary information in the organisation’s

Computer Science
operations, control and assessment, and decision-making. These systems can cut
costs, uncover new opportunities, increase profits, or improve effectiveness.

Executives Executives
Information
Systems
Senior Managers
Decision Support
Systems
Middle Managers Management Information
Systems

Workers
Transaction Processing Systems

Figure 2.7: F
 our main types of information systems

Transaction processing systems


An information system that captures and processes data from day-to-day business
activities is known as a Transaction Processing System (TPS). It ensures that a
business transaction is completed successfully and keeps track of transactions using
a database. Effective TPS can speed up business activities, increase reliability, and
reduce clerical costs. For example, buyers who buy a book from a store may pay
with a credit card. A transaction processing system takes a customer’s credit card
number, connects with their bank, and authorises or refuses the purchase based on
their account balance.
Batch and real-time transaction processing systems are the two types of transaction
processing systems. Batch processing is a way of handling huge amounts of data
in which a group of comparable transactions is grouped for a defined amount of
time. It is commonly employed in manufacturing industries where large-scale
manufacturing activities are carried out. A simple example of batch processing is
when you do your own laundry. You will probably wait till you have a good amount
to throw in the washer all at once
Another example is when a consumer pays for a subscription service at the end of
the month. Because the transactions happen at the same time, the TPS processes

71
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 71 23/01/2023 11:26:46


them as a batch. It’s fine if transactions take longer to process than they should as
Computer Science

long as the system only reads batches once a month.


Real-time processing refers to data streams collected and processed without delay
in real-time. Computer control is an example of this, in which a computer reacts
instantly to events such as flight control, ATMs, and traffic control systems. Because
data is processed as soon as it arrives, a continual flow of input data is required to
offer a rapid output. Table 2.2 compares the batch and real-time processing.
Table 2.2: Batch vs Real-Time Processing
Batch processing Real-Time processing
The collection and storage of data, for The immediate processing of data after
processing at a scheduled time when the transaction occurs, with the database
a sufficient amount of data has been being updated at the time of the event.
accumulated.

Example: Examples:
(a) Cheque clearing, (a) Reservation systems
(b) G
 eneration of bills, credit card (b) Point of sales terminals
transactions
Advantage Advantage
Many transactions are completed at once a Data is processed immediately
time in a single process
Disadvantage
Disadvantage
The act of processing data is repetitive.
Data takes time to be processed

Management Information Systems


A Management Information System (MIS) is used to coordinate, control, analyse, and
visualise information in an organisation. An example is a transportation coordinator
using MIS reports to find the least and most expensive means that have been in use
for the past year to ship products to market. MIS supports the management level of
the organisation whereby managers can access various reports such as, performance
reports, online. MIS usually depends on TPS for their data.
Decision support systems
A decision support system (DSS) is an information system that aids in the decision-
making process in an organisation. It assists people in making decisions regarding

72
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 72 23/01/2023 11:26:46


problems that are fast-changing and Executive support systems

Computer Science
not clearly stated in advance, such Executive Support Systems (ESS) or
as unstructured and semi-structured Executive Information Systems (EIS)
decision problems, at the management, are computer-based information systems
operations, and planning levels of that enable top managers or senior
an organisation, often mid-to-upper executives to quickly access internal
management. and external data, critical to strategic
DSS focuses on combining model or decision-making, and other executive
analytic techniques with traditional duties. It has drill-down features for easy
data access and retrieval functions and information navigation, status access,
emphasises flexibility and adaptability to trend analysis, exception reporting, and
accommodate environmental changes. It customised analysis, all of which are
created with management’s essential
also focuses on features that make them
success elements in mind.
easy to use by non-computer-proficient
people in an interactive mode. Some The four significant types of information
examples are a sales manager projecting systems are related to one another, as
revenue figures based on product sales shown in Figure 2.8.
assumptions.

Executive
Support
Systems
(ESS)

Management Decision
Information Support
System Systems
(MIS) (DSS)

Transaction
Processing
Systems(TPS)

Figure 2.8: Major types of information systems and their interrelationships

73
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 73 23/01/2023 11:26:46


TPS is typically a significant data source (a) 
Provide an example of what can
for other plans, whereas ESS is primarily be done and identify the types of
Computer Science

a recipient of data from lower-level information system being used by


systems. Other types may exchange necta for examination results.
data with each other. Data may also (b) What features do you think NECTA
be exchanged among systems serving examination system possesses to
different functional areas. For example, enable managerial and decision
an order captured by a sales system making?
may be transmitted to a manufacturing
system as a transaction to produce or
deliver the product specified in the order
Database systems
or to MIS for financial reporting. In today’s world, database systems
play a critical role in various aspects
of our daily life, e.g., business and
Activity 2.3: Analysing the education. Every day, most of us and
types of information system the organisations around us engage
in various activities, including some
Eescribe TPS, DSS, ESS, and MIS and form of database interaction. Such
their interrelationship using an example activities are depositing or withdrawing
of an information system from any money from banks or mobile money
organisation in your community or via a agents, hotel reservations, buses, airline
search engine. ticketing, and a digital library to access
a bibliographic item or buy something
online. Even buying groceries, today’s
Exercise 2.2
supermarkets located across the country
1. What is the importance of frequently update the database that
information systems in schools and stores the inventory of grocery goods.
for entrepreneurs today? As a result, databases are practically
vital in every field where computers are
2. What is the difference between utilised, including business, government
batch and real-time processing in services, commerce, social media,
information systems? Provide an engineering, healthcare, genetics, law,
example for each. education, and library science.
3. What roles do people play in A database is a collection of connected
information systems? How is it data that is organised and kept so that
complemented by the procedures information may be retrieved as needed.
component of the information It is a collection of related data having
system? an underlying meaning that represents
4. Consider the NECTA examination the reflection of the real world. We
use the term “data” to refer to known
system accessible at www.necta.
facts that can be recorded and have
go.tz, which you have probably
implicit meaning. Consider the names,
used to access your form IV results. phone numbers, and addresses of the
Provide an example of what can be people you know. These days, most
done and a report obtained by each of this information is saved on mobile
type of information system covered. phones, which come with their database

74
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 74 23/01/2023 11:26:46


software. This information can also be application manuals; so, programs are
entered into an indexed address book or written to perform particular functions/

Computer Science
saved to a hard drive using a computer applications. The database approach
and software like Microsoft Access or collects pragmatically related data,
MySQL. some of which can be published for
A database is also a logically coherent an application. The main differences
collection of data with some inherent among them are as follows, and are
meaning that has been created, built, also, illustrated in Figure 2.9:
and populated with data for a particular (a) A file-based system is a method
purpose. It has a target audience and of arranging /organising files on a
some predetermined applications that medium such as hard disks and flash
these users are interested in. In other disks. A Database system also known
words, a database has a data source, as Database Management System
some level of interaction with real-world (DBMS) is a software application
events, and an audience that is actively used to access, create, and maintain
engaged in its contents. A database’s databases.
end users can conduct transactions or an (b) There is no disaster recovery
event can be triggered by an employee. mechanism in the file-based system;
All of this must be reflected in the DBMS provides you with a disaster
appropriate databases. recovery mechanism.
A database must be a true reflection of (c) The file-based system does not
the real world; it depicts to be accurate provide transfer of transactions;
and dependable at all times. As a result, it is complex, while in the DBMS
even in databases with increased size system, it is easy to implement the
and complexity, such as the government transfer operations using Structured
electronic Payment Gateway (GePG), Query Language.
Facebook, and WhatsApp, which have (d) The file-based system does not offer
millions to billions of users and are concurrency, but DBMS does offer
constantly changing, changes must concurrency.
be reflected in the database as soon as (e) Data redundancy and inconsistency
they occur. A database can range in size are at the top of the system file. As
from an individual’s address book to shown in the first part of Figure
a company-wide database containing 2.9(a), the same data, A, is stored
customer data used by employees to a in different application programs,
product database used in conjunction thus causing redundancy which
with an e-commerce site to allow online leads to data inconsistency as data
shoppers to place real-time orders. get updated. The inconsistency in
Database can also be used in a search database management systems is
engine database. For example, Google eliminated or reduced when using
contains data about billions of web different applications to access
pages accessed by people worldwide. the same database, as shown in
Figure 2.9(b). This is because all
Database system and file-based system data are stored in one place (DB),
The file-based system is the software independent of the applications
that allows users to access and organise involved and accessible by any
a small group of data. It is defined in the of them. Also, any update made

75
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 75 23/01/2023 11:26:46


through any application is stored centrally, and therefore, available for access
by any application involved.
Computer Science

(a): The traditional file approach

(b): The database approach

Figure 2.9: (a) Traditional file system


(b) The database approach

76
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 76 23/01/2023 11:26:46


Types of database models structure with a single root to which all
other data is related. The information

Computer Science
A database model is a form of the
is kept in the form of records that are
data model that defines a database’s
linked together. This model begins with
logical structure. The model determines
the root data and grows in a tree-like
relationships and how data can be stored,
fashion, adding child nodes to parent
organised, altered, and accessed. You nodes, with each child node having
can handle your business data using one only one parent node. This model may
of four database models: hierarchical, effectively express various real-world
network, object-oriented, or relational relationships, such as a book’s index
database models. and recipes. This model also has a one-
to-many link between two categories
Hierarchical database model
of data. For example, one department
A hierarchical database model is a data can have many courses, teachers, and
model that organises data into a tree-like students, as shown in Figure 2.10.

College

Department Infrastructure

Course Teachers Students

Theory Practical

Figure 2.10: A
 n example of a structure illustrating the use of the hierarchical
database model

Network database model


The network database model is designed to flexibly represent objects and their
relationships. Data is organised more like a network in this model, and many parent
nodes are allowed as shown in Figure 2.11. Network model extends the hierarchical
structure since it provides many-to-many relationships to be managed in a tree-
like structure with multiple parents. Because more associations are developed in
this database model as the data become increasingly connected, accessing the data
becomes quicker and faster, and redundancy is managed more efficiently than in the
hierarchical approach. Because of this, the network database model was the most
extensively used database model before the introduction of the relational model.

77
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 77 23/01/2023 11:26:46


Relational database model
Computer Science

A relational database model represents


data in which all items are organised
into two-dimensional tables known
as relations. It is currently the most
extensively used model. In this
paradigm, all data are kept in rows and
columns in a table. Thus, compared to
network and hierarchical models, the
basic structure of a relational database
model is simple, and it is readily scaled
up because we may add as many rows
and columns as needed. For example,
Figure 2.11: A
 n example of a network in the student table, shown in Table
database model 2.3 you can see columns (attributes or
fields) and rows (tuples or records).
Table 2. 3: The attributes and tuples of a student table

Object-Oriented database model


In contrast to relational databases, which are table-oriented, an object-oriented
database architecture represents both the data and the relationship in a single
structure called an object. The object-oriented data model,better represents real-
world problems. It allows us to store music, video, photographs, and other data
types in databases, which was not possible or efficient in the relational paradigm.
Furthermore, in this object-oriented database architecture, two or more objects with
various properties and methods are linked together, as in today’s object-oriented
databases and programming languages. These links are used to connect one thing
to another. Figure 2.12 shows an example in which each object has its properties
and methods. For example, consider the employee object, “Salary” is one of the
employee object properties, while “Get hired” is one of the methods.

78
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 78 23/01/2023 11:26:46


Employee Department

Computer Science
Attributes Attributes
Name Dept_id Name
Job_Tittle Dept_name
Phone_no Methods
Salary
Dept_id
Change Department
Methods
Get_Hired
Change Number

Figure 2.13: An example of object-oriented database model implementation

Relational database
Meaning of relational database
 ctivity 2.3: Database
A
systems A relational database is a collection of
data elements linked together by pre-
Access a file and a database system defined connections. These objects
in your school and then describe the are organised as a collection of tables
disadvantages observed in the former containing columns and rows, as
vs. advantages observed in the latter. mentioned in the preceding section. The
relational database divides data into
tables that can be connected or related
Exercise 2.3
based on shared data. You may create
1. What is the database system? How a whole new table from data in one or
does it differ from the file system? more existing tables with a single query.
Provide an example for each. It also provides a better understanding of
the relationships between all accessible
2. Define the database model and data and the acquisition of fresh
describe its importance in the use insights for better decision-making or
of information systems today. identifying new opportunities. Consider
3. Differentiate hierarchy and network the following scenario whereby your
models and then, provide real-life school keeps a record of the pupils and
examples for each of them. their related information, e.g., family
4. 
Contrast relational and object- members, results, subjects, and teachers,
oriented models, and then give as shown in Figure 2.13. Pupi_ID,
examples of their uses in real life Pupil Name, Family_ID, and so on are
for each of them. examples of columns (or fields) in a
pupil table; Assessment_Date, Pupil_ID,
Grade, Class ID, and so on are examples
of columns (or fields) in a grade table.

79
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 79 23/01/2023 11:26:46


The tables (student and grade) can be linked together using the Pupil_ID column.
The linking between tables using common fields can also be applied to other tables
Computer Science

in this small database. As a result, you can query the data to generate useful reports,
such as consolidated pupil results. These queries are fed into report generators,
which run them on-demand to create reports. Many organisations use databases to
keep track of inventories, sales, financing, fees, treatments, and pharmaceuticals
issued and develop financial and other business/organisational projections. This
section will cover various aspects of relational databases, mainly entity-relationship
models, functional dependency, and normalisation.

Figure 2.13: Simple relational database example – Pupil Database


Relational database model generate a visual representation of data.
A relational database model is a It also responds to the data pieces’ about
collection of data items with pre- who, what, where, and why questions.
defined relationships between them, The data model in a retail transaction, for
made possible by data models. Data example, includes information on who
models, which range from conceptual made the purchase, what was purchased,
to logical, then to physical, serve as a and when. Additional information on the
powerful template and reference for customer, product, store, salesperson,
your database. A data model is a set of manufacturer, supply chain, and other
specified data structures and business factors could be included in the model.
rules. It determines what data is required It is advisable to start with, high-level
and how it should be organised, allowing user needs (conceptual data model) and
for creating a database to be used to work your way through the middle level
develop an application. They also use (logical data model) down to a granular
naming conventions and default values database or file structure (physical data
to assure data quality. It shows how model). Three primary types of data
different data pieces are connected to models can be used to construct an

80
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 80 23/01/2023 11:26:46


active database for various purposes. and foreign keys. The goal of a logical
These models are conceptual, logical, data model is to define the data rather

Computer Science
and physical data models. than to implement it. It is not reliant on
any particular database or file structure.
Conceptual data model It can be used in various databases,
The concepts, rules, and processes including relational and NoSQL
required to support the business are systems, and an XML file.
described using a conceptual data Characteristics of a logical data model
model. It determines and defines what (a) They are designed and developed
data is needed for business operations, independently from the DBMS.
analytics, reporting applications, and (b) It describes data needs for a single
the business rules and concepts that go project but can integrate with other
with it. The conceptual model identifies logical data models based on the
the data required and tracks business project’s scope.
events and their outcomes. On the other (c) Data attributes/elements will have
hand, a conceptual model concentrates data types with exact precisions
on the necessary data pieces for business and lengths. This characteristic
processes but ignores process flow or may also be used in physical data
data type categorization. model.
Characteristics of a conceptual data model (d)  Normalization processes to the
(a) 
The conceptual model is model are applied up to the Third
independent of hardware Normal Form (3NF).
specifications like data storage Physical Model
capacity, and location, or software A physical data model is more
specifications like DBMS vendor concerned with data design and
and technology. The attention is to database implementation. It specifies
represent data in a way a user will how data is organised in a system’s
see it in the “physical world.” specific database or file structure. It is
(b) Gives organisation-wide coverage the physical representation of process
of the business concepts. data pieces collected by the entity for
(c) This type of data model is designed storage in a database management
and developed for a business system (DBMS). The model considers
audience. the technical as well as the performance
criteria. The physical (model) comprises
Logical data model all relationships and entities, data types,
A logical data model defines the mapping keys, foreign keys, constraints, indexes,
of data rules and structures. It goes into triggers, tables, spaces, partitions, and
a greater depth about a process and how other DBMS features in the database
it ties to other business processes inside utilised to construct an application. This
the company. It detects and defines model, developed from the conceptual
data structures such as entities, tables, and logical models, contains entities and
attributes, columns, and structure-to- relationships that help with enterprise
structure relationships such as primary data storage and retrieval.

81
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 81 23/01/2023 11:26:46


Characteristics of a physical data model
Computer Science

(a) The physical data model describes data needed for a single project or application
though it may be integrated with other physical data models based on project
scope.
(b) It was developed for a specific version of a DBMS, location, data storage, or
technology in the project.
(c) The physical data model contains relationships between tables that address
cardinality and the relationships’ nullability.
(d) Columns should have exact data types, lengths assigned, and default values.
(e) Primary and foreign keys, views, indexes, access profiles, authorizations, are
defined.

The three data models, also shown in Figure 2.14, can be produced using Entity-
Relationship (ER) modelling, a best practice for building a well-designed relational
database structure through the three processes.

Figure 2.14: Conceptual, logical, and physical data models

Entities are objects that represent things in the real world and have a common set of
attributes, (which are characteristics of properties of the entities), and relationships,
(which describe how entities are related to one another, and share information in the
database) are used to accomplish this database.

82
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 82 23/01/2023 11:26:46


Example on how to create the three (iii) Foreign keys
data models from a real-life scenario

Computer Science
According to the relationships
Scenario: A route taken by a particular established in step 1, route number from
bus company, whose buses travel the entity Route will become a foreign
according to a given schedule. key in the remaining entities, which
are Bus Company and Schedule. This
Step 1: Creating a conceptual data model
implies that there shall be an addition of
In this step, you have to identify entities one attribute (route number) in the Bus
and their relationships. There are Company and Schedule entities.
three entities, which are: Route, Bus
Company, and Schedule. With regard Step 3: Creating a physical data model
to relationships, one route can have The creation of the physical data
one or many bus companies offering model requires defining the names of
transportation services to passengers. the tables, names of the columns, and
Also, a route can have one or multiple column data types in addition to the
transportation schedules. characteristics, primary key, and foreign
keys described in the logical data model
Step 2: Creating a logical data model in step 2. Since physical data model is
Identification of characteristics, primary also an implementation of the database,
keys, and foreign keys are necessary for its specification may be dependent on a
the establishment of a logical data model particular database management system
in addition to the names of entities and such as MS Access, MySQL, and
relationships that were formed between PostgreSQL.
entities in step 1. i) Names of tables
(i) Identification of attributes The names of tables are route, bus_
• 
The entity Route may have company, and schedule
the following attributes: route ii) Names of columns
number, route name, origin, • The table route has the following
destination columns, route_number, route_
• The entity Bus Company may name, origin, destination
have the following attributes: • The table bus_company has the
company id, route number, following columns, company_
owner name, post code id, route_number, owner_name,
• The entity Schedule may post_code
have the following attributes: • The table schedule has the
schedule number, route number, following columns, schedule_
departure time, arrival time number, route_number,
(ii) Primary keys departure_time, arrival_time
Under current scenario, the primary (iii) Data types
keys are route number, company id, and • Data type for route_number,
schedule number for entities Route, Bus company_id, schedule_number,
Company, and Schedule, respectively. and post_code will be integer

83
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 83 23/01/2023 11:26:46


•  Data type for route_name, relation, domain, primary key, candidate
key, alternate key, foreign key, selection,
Computer Science

origin, destination, and


owner_name will be character and projection.
of varying length (preferably 50 Attribute or field
characters) Attributes or fields describe
• Data type for departure_time, characteristics or properties that define
and arrival_time will be date all items about a particular category.
time or time (depending on your An attribute is also a named column in
preference) a database. e.g., first name, postal code,
and date of birth in the employees’
Note: The physical data model and database.
relationships between entities will be
Tuple or record
covered in more detail in this chapter’s
subsequent sections. A tuple or record is a data set representing
a single item. It is a collection of related
data fields or attributes. It is also known
 ctivity 2.5: Creating a data
A as a row in a database. An example of a
model record is, for instance, when you have
an employee’s database with attributes
Based on the example on how to create first_name, post_code, and date_of_
data models from real life, create a data birth whose values may be Juma, 11101
model for a shop interms of conceptial, Kivukon, and 2/3/1980, respectively
logical, and physical data models. Limit Relation
yourself in three important emptities.
It is a set of tuples or records with the
same attributes; a set of columns and
Relational database terminologies rows as in Figure 2.15. Also, we refer to
and their application it as an entity that is a generalised class
As mentioned earlier, the relational of people, places, concepts, or things
database is a type of database that for which data is collected, stored, and
focuses on the relationship between maintained. The entity is also named
stored data elements. The fundamental Table in a database. For example, a
terminologies applied to relational school database may include Students,
databases include attribute, tuple, Classes, and Courses.

Figure 2.15: Illustration of some relational database basic terminologies

84
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 84 23/01/2023 11:26:47


Domain

Computer Science
The domain is a set of allowable values for an attribute. It refers to a group of values
we can assign to an attribute and can be considered as a constraint on the attribute’s
value. Each attribute has a domain. For example, for an attribute “Grade” in a student
database, its domain can be a positive number between 0 and 100. Another example
could be an attribute “Regions” in the Tanzania census database in which by March
2022, there were 31 regions (26 from Tanzania mainland and 5 from Zanzibar);
thus, the domain alphabetically is “Arusha, Dar es Salaam, Dodoma …, Kaskazini
Pemba, Kusini Unguja …, Tabora, Tanga”.
Primary key
The primary key is a tuple, field, or set of tuples or fields that uniquely identify a
record or tuple in relation to a table. A table can have only one primary key, often
denoted as PK. The primary key cannot be null due to the dependency of other
fields in relation to a table. A good example is a National Identification Number in
National Identification Authority (NIDA) database or a student registration number
in a student database, as indicated in Figure 2.16 as “StudID.”

Figure 2.16: Example of the primary, candidate and alternate keys using a student
table
Candidate key
A candidate key, denoted as K, is a minimal set of attributes that can uniquely identify
a tuple, or field row. Any set of attributes or columns has a unique combination
of values in each row. The additional constraint is that removing any attribute or
column can produce duplicate rows. The difference between the candidate key and
the primary key is that, while the primary key uniquely identifies a record or row
in the table and follows one key per table approach, the candidate key does the
same. Still, it can have one or many keys per table. Sometimes, there are a group of
columns in a table with unique values. All such columns have a candidate key, and
thus the primary key is a subset of the candidate key. For example, in Figure 2.17,
the StudID, Roll_Number, and email columns can be the candidate keys, meaning
records of these columns do not have any duplicate value, and they can be used to
identify data in the table. And any one of these three can be taken as the primary key.

85
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 85 23/01/2023 11:26:47


Alternate key
Computer Science

The candidate keys that are not selected as the primary key are called alternate keys.
In this kind of key, columns have a candidate key except for the primary key, which
has an alternate key. For example, in Figure 2.17, the columns - Roll_No and Email
are alternate keys, considering that Student ID is the primary key.
Foreign Key
The foreign key is an attribute, or set of attributes, within one relation or table that
matches the primary key of another relation or table. It creates a relationship between
the two tables. It effectively uses the values of attributes in the referenced relation
to restrict the domain of one or more attributes in the referencing relation. The
purpose is to maintain data integrity and allow navigation between two different
instances of an entity. A good example is a foreign key in an Employee database
where every employee works in a specific department in an organisation, and the
employee and department are two different entities or tables. Therefore, we cannot
store the department’s information on the employee table. That is why we link
these two tables through the primary key of one table. We add the primary key of
the DEPARTMENT table, Department_ID, as a new attribute in the EMPLOYEE
table; thus, becoming a foreign key there; then both tables are related, as depicted
in Figure 2.17.
EMPLOYEE DEPARTMENT
Employee_ID Department_ID
Employee_Name Department_Name
Passport_Number
License_Number
SSN
Department_ID

Figure 2.17: Example of the foreign key using an employee database

Activity 2.6. Identify keys in the tables

Consider the related tables of student registration and results in your school. Identify
the Primary, Foreign, Candidate, and Alternate keys and illustrate them with a
diagram.

86
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 86 23/01/2023 11:26:47


Composite Key

Computer Science
In the context of relational databases, a composite key is a combination of two or
more columns in a table that can be used to identify each row in the table uniquely.
Uniqueness is only guaranteed when the columns are combined; the columns do not
guarantee uniqueness when taken individually.
The column(s) that agrees with uniqueness is called a candidate key. A composite
key is a distinct type of candidate key formed by two or more columns. Sometimes
the candidate key is just a single column, and sometimes it is created by linking
multiple columns.
Note:
(a) The combination can also make a composite key of more than one candidate key.
(b) A composite key cannot be empty/null.
Selection and projection
Selection and projection operations are basic and most used operations specific
to relational databases. The selection is defined as taking the horizontal subset of
rows of a single table that satisfies a particular condition. It retrieves tuples from a
relation, limiting the results to only those that meet a specific criterion. Selection,
covered in detail in the next section, returns some or all rows and all the columns
in a table. Selection answers the question: which rows shall the query return (where
condition)? For example, `Select * From emp Where deptno = 10` as shown in
Table 2.4.
Table 2.4: Selection operation in a relational database

The projection is defined as the set obtained when the components of the tuples are
restricted to the set – it discards (or excludes) the other attributes. It extracts only
the specified relation attributes from a tuple or set of tuples. It is a vertical subset of
table columns, and it may include one column, two columns or all table columns.

87
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 87 23/01/2023 11:26:47


Projection answers the question: which columns shall the query return? E.g. `Select
empno, fname, job From emp`; returns columns as depicted in Table 2.5.
Computer Science

Table 2.5: Projection operation in the relational database

Projection differs from selection as SELECT is used to select all rows of a specific
relation that meet a particular condition, whereas project is used to select particular
columns. However, one query may contain both: selection and projection: For
example, `select empno, fname, job From emp Where deptno=10`; returns
enclosed columns and rows as in Table 2.6.
Table 2.6: Selection and Projection operations in a relational database

Activity 2.7: Selection and projection


Using selection and projection based on Table 2.6, work out the results of “Select
Fname, job, hiredate, sal From emp Where deptno=30”. Illustrate the results in the
same format as in the referred figure.

88
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 88 23/01/2023 11:26:47


Advantages of relational database the records from being imperfect,
model isolated or unrelated; thus, aiding the

Computer Science
A relational database system has relational database’s characteristics like
multiple advantages, as described in the ease of use, precision, and data stability.
next paragraphs. Flexibility
Simple model A relational database system possesses
A relational database system is the qualities for levelling up and expanding
simplest model, as it does not require to bigger lengths. It is endowed with
any complex structuring or querying a bendable structure to accommodate
processes. It does not involve tedious the constantly shifting requirements,
architectural processes and SQL queries as there is supposedly no boundary on
like hierarchical and network database the number of rows, columns or tables
models. a relational database can hold. This
facilitates the increasing incoming
Data accuracy amount of data and the update and
In the relational database system, deletes wherever required. For example,
multiple tables can be related to one a database administrator can insert,
another using a primary key and foreign update, or delete tables, columns, or
key concepts. This makes the data non- individual data in the given database
repetitive hence, no data duplication, system promptly and efficiently to meet
and more data accuracy is experienced. business needs.

Easy access to data Normalization


There is no pattern or pathway for The methodical style is maintained to
accessing the data in the relational make sure that a relational database
database system as it is in the network structure is liberated of any variances that
or hierarchical models. Anyone who can make a difference in the integrity and
accesses the data can query any table or accuracy of the tables in the database.
a combination of them in the relational A normalization process provides a
database, allowing the user to get and set of regulations, characteristics, and
display the relevant data effortlessly. purposes for the database structure
and evaluation of a relational database
Data integrity model. It aims at illustrating multiple
Data integrity is a crucial characteristic levels of breaking down the data. Any
of the relational database system. level of normalization is expected to be
Robust data entries and legitimacy accomplished on the same level, that is,
validations ensure that all the data in before moving ahead to the next levels.
the database is confined within suitable A relational database model is usually
arrangements and the necessity for confirmed to be normalised only when
creating the relationships are present. it satisfies the third normalisation form’s
This relational reliability amongst the necessary conditions; thus, reassuring
tables in the database helps to prevent the extra strong and reliable database.

89
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 89 23/01/2023 11:26:47


High security database in this category is MySQL and
PostgreSQL.
Computer Science

As the data is divided amongst the


tables of the relational database system, Popular proprietary DBMSs for
it is possible to make a few tables to be organizations
tagged as confidential and others not.
The popular and most used relational
Unlike other databases, this segregation
databases in this category are Microsoft
is easily implemented with a relational
SQL Server, Oracle, IBM-DB2 and
database management system. For
recently AWS - Amazon Relational
example, when a data analyst tries to
Database Service (Amazon RDS), that
log in with a username and password,
makes it easy to set up, operate, and
the database can set boundaries for their
scale a relational database in the cloud.
level of access by providing admission
only to the tables that they are allowed Exercise 2.5
to work on.
Feasible for future modifications 1. What is a relational database model?
As the relational database system holds 2. 
Differentiate between logical and
records in separate tables based on their physical data models.
categories, it is straightforward to insert, 3. Identify two related entities in your
delete or update records subject to the school students’ organisation and
latest requirements. This feature of the determine three possible attributes
relational database model tolerates the for each. Create both tables with
newest requirements presented by the three tuples for each and show how
business and can be inserted or modified they relate.
depending on the conditions. 4. 
In the tables you have created in
question (3), identify the primary
Examples of relational database key, candidate key, alternate key
systems and foreign key. Also, determine the
Relational database systems are used domain for each attribute that was
in many organisations today. There are identified.
several common and popular relational 5. Differentiate between selection and
database systems based on: end-users, projection in an RDBMS while
open source, and proprietary, as follows: giving examples.
Popular DBMSs for end-users
The popular and most used relational Entity-relationship model
database in this end user’s utilisation
Entity-Relationship (ER) modelling
category is Microsoft Access and File
is a best practice for producing well-
MakerPro.
designed databases. It depicts the
Popular open-source DBMSs for structure of a relational database
organizations allowing you to understand the data and
The popular and most used relational how it shares information.

90
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 90 23/01/2023 11:26:47


Elements of the entity-relationship model

Computer Science
An ER data model’s main elements involve entities, attributes, and relationships, as
depicted in Figure 2.18,
with the example from a student database involving how each element is
diagrammatically represented.

Student_ID Course_ID

Student Takes Course

Age Credits

Attribute Relationship Entity


Figure 2.18: A
 sample of entities, attributes, and relationships from a student
database in the ER data model

Entity cardinality which defines how the


An entity is an object representing things entities’ data or records are related. The
from the real world. An entity contains a common cardinalities include one-to-
set of attributes, each with values. one, one-to-many, many-to-many, and
many-to-one relationships. Details for
Attribute each relationship are outlined as follows:
The attribute is the characteristics or One-to-one relationship is when one
properties of an entity based on the entity from entity set A can be associated
data type. Each column represents an with at most one entity of entity set B
attribute that stores the value of an entity and vice versa. For example, a school
characteristic. might decide to assign one class teacher
to precisely one class; thus, one teacher
Relationships manages only one class.
Relationships define how entities are One-to-many relationship is when one
related to each other; and how they share entity from entity set A can be associated
information in the database. This is done with multiple entities of entity set B.
through Entity-Relationship Diagrams Still, an entity from entity set B can
(ERD). ERD uses basic graphical be associated with at least one entity
symbols to show the organisation of in set A. For example, the relationship
entities and their relationships. An between a teacher and the subjects they
important aspect of relationships is teach, where one teacher can teach

91
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 91 23/01/2023 11:26:47


multiple subjects, but only one teacher summarised as follows:
teaches a given subject.
Computer Science

Many-to-one relationship is when more


than one entity from entity set A can be
associated with at most one entity of
entity set B. However, an entity from
entity set B may or may not be associated
with more than one entity from entity set
A. For example, many students belong
to the same class.
Many-to-many relationship is when one
entity from set A can be associated with
more than one entity from set B and vice
versa. For example, students are related Generally, these cardinalities might
to multiple teachers, and teachers can be apply in an ERD at the entity level. An
associated with multiple students. example is the customer order database
in Figure 2.19, in which a salesperson
Cardinality notation symbols serves many customers that each can
In cardinality notation symbols, the lines also place multiple orders. Each order
connecting entities appear with extra can have only one invoice, but each of
marks at the end. These marks define these orders may also include many line
the cardinality degree. The notations are items, and each specifies products that it
contains.

Figure 2.19: An example of Entity-Relationship Diagram (ERD) - customer order


database

92
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 92 23/01/2023 11:26:47


Computer Science
Activity 2.8: Construction of an E-R diagram to represent a real-life
database
In a University, a student enrols in courses. A student must be assigned to at least one
or more courses. To maintain instruction quality, a Professor can deliver only one
course. Create an Entity Relationship Diagram (ERD) following the steps indicated
in the diagram below and the steps that follow:

Step 1) Entity identification


We have three entities: Student, Course and Professor.

Step 2) Relationship identification


We have two relationships: The student is assigned a course, and the
professor delivers a course.

Step 3) Cardinality identification


From the problem statement, we know that, a student can be assigned multiple courses,
and at a time Professor can deliver only one course.

Step 4) Identify attributes

93
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 93 23/01/2023 11:26:47


To identify attributes, you need to study the files, forms, reports, and data currently
maintained by the organization. You can also conduct interviews with various
Computer Science

stakeholders to identify entities. Initially, identify the attributes without mapping


them to a particular entity. Once you have a list of attributes; you need to map them
to the identified entities. Ensure an attribute is to be paired with exactly one entity. If
you think an attribute should belong to more than one entity, use a modifier to make
it unique. Once the mapping is done, identify the primary keys. If a unique key is
not readily available, create one.
Entity Primary Key Attribute
Student Student_ID StudentName
Professor Employee_ID ProfessorName
Course Course_ID CourseName
For the Course entity, more attributes could for example, be Duration, Credits,
Assignments, etc. For ease, we have considered just one attribute for each entity.
Step 5) Create the ERD Diagram
A more modern representation of ERD example

Functional dependency thus, the employee name and salary are


functionally dependent on the employee
Meaning of functional dependency
number. Table 2.7 shows an example of
Functional dependency is a constraint functional dependent.
that determines the relation of one
Table 2.7: Functional dependent
attribute to another in a relational
database management system. It is a Employee Employee Salary
relationship between attributes in which number Name
we can obtain the value of another EMP01 Diana 900,000
attribute from a given attribute. For
example, if we know the value of a EMP02 Juma 950,000
student’s roll number, we can obtain
EMP03 Andrew 850,000
the student’s address and marks. It is
said that student address and marks are
functionally dependent on student roll Importance of functional dependencies
number. Similarly, if we know the value (a) Functional dependency helps to
of the employee number, we can also maintain the quality of data in the
obtain the employee name and salary; database.

94
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 94 23/01/2023 11:26:47


(b) It helps to define databases’ Here columns manuf_year and colour are
constraints, ensure data integrity, independent of each other and dependent

Computer Science
and avoid data anomalies. on motorbike_model. In this case, the
(c) It plays a vital role in finding the two columns are said to be multivalued
difference between good and bad dependent on motorbike_model. These
database design, thus promoting dependencies are represented like this:
robust and impactful databases. motorbike_model ->> manuf_year; and
motorbike_model ->> colour
Types of functional dependencies
Trivial dependency
There are four main types of functional
This type of functional dependency
dependency which are:
occurs when a set of attributes called a
(a) Multivalued dependency trivial is included in that attribute. So, X
(b) Trivial functional dependency -> Y is a trivial functional dependency if
(c) Non-trivial functional dependency Y is a subset of X. For example, consider
(d) Transitive functional dependency this Employee table with two columns,
Emp_id and Emp_name.
Multivalued dependency
Emp_id Emp_name
This type of functional dependency
occurs when there are multiple AS555 Harry
independent multivalued attributes in a AS811 Mwajuma
single table. It consists of at least two
AS999 Kevin
dependent attributes on its attributes;
thus, it always requires at least three In this case, {Emp_id, Emp_name}
attributes. For example, consider a -> Emp_id is a trivial functional
motorbike manufacturing company that dependency as Emp_id is a subset of
produces two colours (black and red) in {Emp_id, Emp_name}.
each model every year. Table 2.8 shows
multivalued dependency. Non-trivial dependency
Table 2.8: Multivalued dependency This functional dependency occurs when
A->B holds true where B is not a subset
Motorbike_ Manuf_year Colour of A. In other words, if a functional
model dependency X->Y holds true, then Y is
M1001 2017 Black not a subset of X; thus, this dependency
is called a non-trivial functional
M1001 2017 Red dependency. For example, an employee
M2012 2018 Black table with three attributes: emp_id,
emp_name and emp_address. From
M2012 2018 Red this example, the following functional
M2222 2019 Black dependencies are non-trivial: emp_id ->
emp_name (This means that if we know
M2222 2019 Red emp_id, we know emp_name. but emp_
name is not a subset of emp_id) emp_id

95
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 95 23/01/2023 11:26:47


-> emp_address (This imply that, if we Normalisation
know emp_id, we know emp_address
Computer Science

Meaning of normalisation
which is not a subset of emp_id). Normalisation was developed to break
A transitive dependency data into related groups and define
It is a type of functional dependency that the relationships between them. It is a
happens when it is indirectly formed by specific relational database analysis and
two functional dependencies, and can design technique used to model groups
only occur in relation to three or more of related data within an organisation.
attributes. Consider the following table Normalisation organises data in a
containing the details of the company’s database to avoid redundancy, insertion
Chief Executive Officers (CEOs). anomaly, update anomaly, and deletion
anomaly. These concepts will be
Table 2.9: Company chief executive
discussed in detail later in this section. It
officers details
analyses the relation schemas based on
Company CEO BirthDate their different functional dependencies
Microsoft Satya Nadella 1.2.1967 and primary key. The purpose is to ensure
that data stored within the database
Google Sundar Pichai 12. 6.1972 adhere to best practices by following a
Facebook Mark Zuckerberg 7.9.1984 set of rules to eliminate redundancies
and optimise the process of information
It follows that {Company} -> {CEO} retrieval. Normalisation leaves us with
(if we know the company, we know its a structure that groups alike data into
CEO’s name). {CEO} -> {Birthdate}; relational models. It is accomplished
if we know the CEO, we know the by applying some formal rules either
Birthdate. Therefore, if the rule of by synthesis (creating a new database
transitive dependency: {Company} -> design) or decomposition (improving an
{Birthdate} should hold, it will make existing database design).
sense because if we know the company’s Importance of normalisation
name, we can know the CEO birthdate. Database normalisation is structuring
a database, usually a relational database,
to reduce data redundancy, anomalies,
Activity 2.9: Functional and inconsistency; and minimising
dependencies in databases redesign when extending the database
The multivalued dependency is the type structure. It also entails organising
of functional dependency that occurs a database’s columns (attributes)
when multiple independent multivalued and tables (relations) to ensure that
attributes are in a single table. Study database integrity constraints properly
your surroundings and generate a single enforce their dependencies. An example
table that produces a single table that is indicating one of the reasons for
a multivalued dependency. normalization, the data anomalies, is
shown in Table 2.10, where Employee
426 is shown as having different
addresses on different records.

96
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 96 23/01/2023 11:26:47


Table 2. 10: Data update anomaly – employee 426 shows different addresses on its records

Computer Science
Employees’ Skills
Employee ID Employee Address Skill
426 Box 137 MWANZA Public speaking
426 Box 132 MWANZA Typing
645 Box 8991 Dar es salaam Carpentry
645 Box 8991 Dar es salaam Public speaking

In this example, the same information relations are considered free of insertion,
can be expressed on multiple rows; updating, and deletion anomalies.
therefore, updates to the relationship In addition, we have something called
may result in logical inconsistencies. For Un-Normalised Form (UNF); though
example, each record in an “Employees’ not generally considered as part of the
Skills” relation might contain an normalisation rules, it represents the
Employee ID, Employee Address, and very first stages of the normalisation
Skill; thus, a change of address for a process. The objective of the Un-
particular employee may need to be Normalised Form (UNF) and each of the
applied to multiple records (one for three normal forms (1NF; 2NF; 3NF)
each skill). If the update is only partially are shown in Figure 2.20, followed by
successful, (the employee’s address is details for each one.
updated on some records but not others),
then the relation is left in an inconsistent Un-Normalised Form (UNF)
state. Specifically, the relation provides
conflicting answers to this particular Create model Data
employee’s address, affecting the
database’s use and effectiveness.
First Normalised Form (1NF)
Database normalisation forms
Normalisation is represented by a logical Remove Repeating Attributes
set of steps that follow simple rules
applied to each stage of the modelling
process. The stages are separated into Second Normalised Form (2NF)
normal forms at the highest level,
identified by a particular named process. Remove Partial Dependencies
There are three common normal forms
that, when applied, a relation is often
described as “normalised”. These forms Third Normalised Form (3NF)
are First Normal Form (1NF), Second
Normal Form, (2NF) and Third Normal Remove Transitive Dependencies
Form (3NF). Generally, normal forms Figure 2.20: Objective of Un-Normalised
are six, but the rest three are considered Form (UNF) and the three normal forms
complex data structures. Once the first (1NF; 2NF; 3NF)
three common normal forms are applied,

97
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 97 23/01/2023 11:26:47


Un-Normalised Form (UNF)
Computer Science

Un-Normalised Form (UNF) intends to achieve a database data model (organisation


of data in a database) which does not meet any of the conditions of database
normalisation defined by the relational model. In the relational model, unnormalised
relations can be considered the starting point for normalisation. This un-normalised
form is a preparatory stage of the normalisation process, allowing us to create a
structured frame representative of organisational data such as a form or document
(e.g., invoice, report and purchase order).
Based on the form or document you are working from, draw up a table structure
(unnormalised), creating a column heading for each data item.
An example of the unnormalised form: is when a manufacturing company stores the
employee details in a table named employee with four attributes, as shown in Table 2.11.
Table 2.11: An example of an unnormalised form table
emp_id emp_name emp_address emp_dept
101 Samson Madirisha DSM D001
101 Samson Madirisha DSM D002
123 Madina Wavu Kagera D890
166 Hashim Milango Mbeya D900
166 Hashim Milango Mbeya D004

In this un-normalised table (see Table 2.11), there is an update anomaly. In the table,
we have two rows for employee Samson, who belongs to two different departments
of the company. If we want to update the address of Samson, then we have to update
the same in two rows; otherwise, the data will become inconsistent. If, somehow,
the correct address were updated in one department but not in the other, then as per
the database, Samson would have two different addresses, which is incorrect and
would lead to inconsistent data. Besides, the table in this form may lead to an insert
anomaly. Suppose a new employee joins the company who is under training and
currently not assigned to any department, then we would not be able to insert the data
into the table if the emp_dept field does not allow nulls. Finally, in this normalized
table, there is a delete anomaly: suppose, at a point in time, the company closes the
department D890, and then deleting the rows that have emp_dept as D890 would
also, delete the information of employee Madina since she is assigned only to this
department. Therefore, we need to normalize the data in the three normal forms as
introduced earlier to overcome these anomalies.
Another example of an Unnormarised Table is shown in table 2.12.

98
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 98 23/01/2023 11:26:47


Table 2.12: Non-normalized table.

Computer Science
Full name Address Movie_industry Sports
Ismail Makame Kijichi Hollywood and Football and
Bollywood Basketball
Rehema Kiongwe Mnazi Moja Swahiliwood and Netball
Nollywood
Muki Mohamed Mbagala Nollywood and Cricket
Riverwood

Advantages of normalization
(a) Normalization helps to reduce data redundancy
(b) More incredible overall database organization
(c) Data consistency within the database
(d) Much more flexible database design
(e) Enforces the concept of relational integrity

Disadvantages of normalization
(a) You cannot start building the database before knowing what the user needs.
(b) The performance degrades when normalizing the relations to higher normal
forms, i.e., 4NF, and 5NF.
(c) It is very time-consuming and challenging to normalize relations of a higher
degree.
(d) Careless decomposition may lead to a bad database design and severe problems.
First Normal Form (1NF)
As indicated in Figure 2.20, the objective of this 1NF is to remove repeating
attributes. This is done because the relation is in 1NF if it contains an atomic value,
and an attribute of a table cannot hold multiple values. Instead must have only
single-valued attributes. Also, 1NF disallows the multi-valued attribute, composite
attribute, and their combinations.
For a table to be in the First Normal Form, it should follow the following four rules:
1. It should only have single (atomic) valued attributes/columns.
2. Values stored in a column should be of the same domain.
3. All the columns in a table should have unique names.
4. The order in which data are stored does not matter.
For example: Suppose an agriculture-based company wants to store its employees’
names and contact details. It creates a table as presented in Table 2.13.

99
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 99 23/01/2023 11:26:47


Table 2.13: An example of a table not conforming to 1NF
Computer Science

emp_id emp_name emp_address emp_mobile


101 Hamis Waya Iringa 0658000770
0713876776
102 Erick Misitu Mbeya
0767000771
103 Mwantumu Chake Coastal 0688000775
028675432
104 Namdori Mchicha Arusha
0736000671

As you can see from Table 2.13, employees (Erick and Namdori) have two mobile
numbers, so the company stored them in the same field as you can see in emp-
mobile. Therefore, this table is not in 1NF as a rule says, “each attribute of a table
must have atomic (single) values”; the emp_mobile values for employees Erick and
Namdori violate this rule.
To make the table comply with 1NF, we should have those anomalies fixed in the
data, as indicated in Table 2.14.
Table 2.14: An example of a table conforming to the First Norm Form (1NF).
emp_id emp_name emp_address emp_mobile
101 Hamis Waya Iringa 0658000770
102 Erick Misitu Mbeya 0713876776
102 Erick Misitu Mbeya 0767000771
103 Mwantumu Chake Coastal 0688000775
104 Namdori Mchicha Arusha 028675432
104 Namdori Mchicha Arusha 0736000671

For example, if we want to put Table 2.15 in the 1N, it will look as in Table 2.15.
Table 2.15: The first normalized form
Full name Address Movie_industry Sports
Ismail Makame Kijichi Hollywood Football
Ismail Makame Kijichi Bollywood Basketball
Ismail Makame Kijichi Hollywood Basketball
Ismail Makame Kijichi Bollywood Football
Rehema Kiongwe Mnazi Moja Swahiliwood Netball
Rehema Kiongwe Mnazi Moja Nollywood Netball
Muki Mohamed Mbagala Riverwood Cricket
Muki Mohamed Mbagala Nollywood Cricket

100
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 100 23/01/2023 11:26:47


Second Normal Form (2NF) Table 2.17: (b) Teacher_subject table

Computer Science
A table is in 2NF, if the relation or table Teacher_id Subject
is in 1NF (First Normal Form) and all 25 Computer
non-key attributes are fully functional
dependent on the primary key (non- 25 Biology
prime attribute). For example, suppose a 47 English
school wants to store the data of teachers 83 Math
and the subjects they teach and, in a 83 Chemistry
school, a teacher can teach more than
one subject. Since a teacher can teach The characteristics of 2NF
more than one subject, the table can
(a) In the 2NF, relational must be in 1NF.
have multiple rows for the same teacher,
as indicated in Table 2.16. (b) In the second normal form, all non-
key attributes are fully functional
Table 2.16: An example of a table not
dependent on the primary key.
conforming to 2NF
(c) 
A single column Primary Key
Teacher_id Subject Teacher_age
that is not functionally dependant
25 Computer 40
on any subset of candidate key
25 Biology 40 relation.
47 English 35
83 Math 36 Third Normal Form (3NF)
83 Chemistry 36 A table design is said to be in 3NF if
it is in 2NF and transitive functional
Based on Table 2.16, we have; candidate
keys which are {Teacher_id, Subject} dependency of the non-prime attribute
and the Non-prime attribute is: teacher_ (an attribute that is not part of
age. Therefore, the non-prime attribute any candidate key) on any super key
Teacher_age is dependent on Teacher_id, (single key or a group of multiple keys
which is a proper subset of a candidate that can uniquely identify tuples in a
key; thus, violating the rule for 2NF. To table) should be removed.
convert the given table into 2NF, we In other words, a table can be explained
decompose it into two tables: Teacher as in 3NF if it is in 2NF, and for each
details in Table 2.17(a) and Teacher-
functional dependency X-> Y, at least X
subject in Table 2.17(b), which the now
is a super key of the table or Y is a prime
comply with Second Normal Form
(2NF). Resulting tables conforming to attribute of the table. For example,
Second Norm Form (2NF). suppose a company wants to store the
complete address of each employee;
Table 2.17 (a): Teacher details they create a table named employee_
Teacher_id Teacher_age details, as indicated in Table 2.18.
25 40
47 35
83 36

101
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 101 23/01/2023 11:26:48


Table 2.18: An example of a table not conforming to 3NF.
Computer Science

emp_id emp_name emp_pc emp_reg emp_city emp_district


1001 John Miti 282005 AR Arusha Arumeru
1002 Muhidini Kata 222008 DS DSM Kinondoni
1006 Lora Misitu 282007 DS DSM Temeke
1101 Lilly Nyavu 292008 TG Tanga Muheza
1201 Steve Milango 222999 MZ Mwanza Ilemela

In Table 2.18 you can see that Super keys Table 2.19: Employees’ details
are: {emp_id}, {emp_id, emp_name}, emp_id emp_name emp_pc
{emp_id, emp_name, emp_pc}… and
so on; Candidate Keys: {emp_id}, Non- 1001 John Miti 282005
prime attributes: all attributes except 1002 Muhidini Kata 222008
emp_id are non-prime as they are not 1006 Lora Misitu 282007
part of any candidate keys. 1101 Lilly Nyavu 292008
Here, emp_reg, emp_city and emp_ 1201 Steve Milango 222999
district depend on emp_pc. and, emp_pc
is dependent on emp_id that makes non- Table 2.20: Employee address
prime attributes (emp_reg, emp_city &
emp_pc emp_reg emp_city emp_district
emp_district) transitively dependent on
super key (emp_id). This violates the 282005 AR Arusha Arumeru
rule of 3NF. To make this table comply 222008 DS DSM Kinondoni
with 3NF, we have to break the table 282007 DS DSM Temeke
into two tables to remove the transitive 292008 TG Tanga Muheza
dependency, as shown in Table 2.19 and
222999 MZ Mwanza Ilemela
Table 2.20, which conform to 3NF.

Activity 2.9: Normalising databases up to the 3rd Normal


form - Examine Table 2.17:
Study the following table and then answer the questions that follows:
Table 2.21: Employee details
staff No branch No branchAddress name position hr/week
S3244 B0021 Temeke, Plt 12G DSM Asha Haji Assistant 16
S3244 B0045 Mikocheni, Plt 32A, DSM Asha Haji Assistant 9
4545 B0021 Temeke, Plt 12GDSM Mayalla Macho Assistant 14
S4545 B0045 Mikocheni, Plt 32A, DSM Mayalla Macho Assistant 10

102
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 102 23/01/2023 11:26:48


(a) Why is this table not in 3NF? Give inserting, updating and deleting data.
two reasons. Some common database management

Computer Science
(b) Describe and illustrate the process systems include MySQL, PostgreSQL,
of normalizing the data shown in Microsoft Access, SQL Server,
Table 2.20 to the Third Normal FileMaker, Oracle, RDBMS, dBASE,
form (3NF). Clipper, and FoxPro.
(c) Identify the primary, alternate, and Structured Query Language
foreign keys in your 3NF relations. Structured Query Language (SQL)
is a database programming language
Exercise 2.6 designed to retrieve and manage data in
a relational database.
1. Describe the steps you would take
to convert unnormalised tables to Importance of Structured Query
the First Normal Form, Second Language
Normal Form, and Third Normal The following are the importance of SQL:
Form. (a) Allows users to access data in the
2. Provide one (1) example relevant to relational database management
a school or college environment that systems
illustrates reasons for converting (b) Enables users to describe the data
database tables to the First, Second (c) Allows users to define the data in a
and Third Normal Forms. database and manipulate that data.
3. 
How does normalization help in (d) Allows embedding within other
improving the design of a database? languages using SQL modules,
libraries, and pre-compilers
4. What kind of inefficiencies (e) Enables users to create and drop
may exist in tables that are not databases and tables
normalised? (f) Enables users to create, view, and
store procedures and functions in a
Database management database
Database management is the process of (g) Allows users to set permissions on
organizing, storing and retrieving data tables, procedures, and views
from a computer. It involves designing, Since there are so many database
implementing and sustaining stored data management systems in this chapter,
to optimize its value, which database
you will learn about Structured Query
management represents. In designing
Language using MySQL. To use
a system, a programmer must have a
this, you need to install the XAMPP
database to store data. For example, if
application. Download and install
you want to store student results in an
academic records system, you need to XAMPP, then start MySQL and Apache
have a database so that all the data can on the XAMPP control panel to access
be stored in it. A database enables you the database; open your browser and
to perform many operations, such as type localhost/phpMyAdmin, and the

103
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 103 23/01/2023 11:26:48


browser will open the dashboard as shown in Figure 2.21.
Computer Science

Figure 2.21: PhpMyAdmin Dashboard

SQL commands (c) Using SQL, you can perform most


There are five commands in SQL of the actions in a database; and
language: Data Definition Language (d) SQL data types are binary, numeric,
(DDL) commands, Data Manipulation extract numeric, and date.
Language (DML) commands, Data
Manipulation Language (DML) Data Definition Language (DDL)
commands
commands, Data Query Language
(DQL), Data Control Language (DCL) DDL commands change the database’s
and Transaction Control Language structure, for example, by creating a
(TCL). It is crucial to keep the following table, deleting a table, and altering
considerations in mind before diving a table. DDL has the following
into SQL: commands: CREATE, ALTER, DROP,
and TRUNCATE.
(a) 
SQL statement starts with SQL
command and ends with a CREATE
semicolon (;);
The CREATE command is used to
(b) 
SQL statements are case- create a new database or table in the
insensitive, which means they can database. It has the following syntax:
be written using upper, lower, or CREATE DATABASE database_name;
mixed cases. But it is a common for the database and CREATE TABLE
practice to write out SQL keyword table_name (column_name datatypes
commands in all upper cases; [,]); for the table.

104
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 104 23/01/2023 11:26:48


The database has to be created first then, followed by the tables;

Computer Science
Example:
CREATE DATABASE student;
CREATE TABLE student_registration (
StudentID int,
FirstName varchar (255),
MiddleName varchar (255),
LastName varchar (255),
Address varchar (255)
);

To create a database and table resulting from this example, select SQL to continue
with the code and type the code; first, you need to create a database and then the table
as indicated in Figure 2.22: this is because the table shall belongs to the database.

Figure 2.22: Creating database and table.

When you run the code, it will create the database, and inside the database, the table
will also be created, as shown in Figure 2.23.

105
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 105 23/01/2023 11:26:48


Computer Science

Figure 2.23: SQL query for creating a table

ALTER To modify a column data type in a table,


Alter command is a statement used use the following syntax ALTER TABLE
to add, delete, or modify columns in table_name MODIFY COLUMN
an existing table. The syntax to alter column_name datatype;
a table by adding a column is ALTER
TABLE table_name ADD column_name DROP
datatype; For example, if you want The drop command is used to delete
to add a parent name in our database both the table structure and the record
named “student” in the table student_ stored in the table. The syntax is DROP
registration, the SQL command will be: TABLE table_name;
ALTER TABLE student_registration For example: If you want to delete table
student_registration, the command will
ADD ParentName varchar(255);
be: DROP TABLE student_registration.
This will add the ParentName column to This will delete the table and its contents.
the student_registration table. To delete
a column in a table, use the following TRUNCATE
syntax ALTER TABLE table_name It is used to delete all rows in the table.
DROP COLUMN column_name; The syntax is TRUNCATE TABLE
For example: We need to delete table_name;
ParentName from the student_ For example: If you have to delete the
registration table; the command will be: rows in the student_registration table,
ALTER TABLE student_registration you need to write TRUNCATE TABLE
DROP COLUMN ParentName; student_registration;

106
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 106 23/01/2023 11:26:48


Data Manipulation Language (DML) commands

Computer Science
DML commands are used to modify the database. Those commands are responsible
for all forms of CHANGES in the database. The command of DML is not auto
committed, which means it cannot permanently save all the changes in the database.
They can be rolled back. DML involves INSERT, UPDATE, and DELETE
commands.
INSERT
The insert command is used to add new records to the table. The syntax is INSERT
INTO table_name (column1, column2, column3, ...) VALUES (‘value1’, ‘value2’,
‘value3’, ...);
Example: Insert students’ data in student_registration table with column (studentID,
FirstName, MiddleName, LastName, Address).
An example of an INSERT query
INSERT INTO student_registration (StudentID, FirstName, MiddleName, LastName,
Address) VALUES(`1234`,‘Mwakalinga’, ‘Mwakatope’, ‘Mkinga’, ‘972 Mbeya’);
Also, see the query in Figure 2.24.

Figure 2.24: The Insert Query.

If you run this query, it will insert data in the table, as shown in Figure 2.25.

Figure 2.25: Inserted data in the table.


UPDATE
The update command is used to update the data value in a table column. After inserting
data, you can modify it by using the update command. The syntax is: UPDATE
table_name SET column1 = ‘value1’, column2 = ‘value2’, WHERE condition;

107
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 107 23/01/2023 11:26:48


WHERE is used to specify which data should be modified. If the condition is not
specified, ALL the rows in a table will be modified.
Computer Science

For example, suppose you want to update the student’s first name with studentID
number 1234 from Mwakalinga to Musawomda. In that case, you will apply the
following query:
UPDATE student_registration
SET FirstName =’Musawomda ‘
WHERE studentId = 1234;
Output is as shown in Figure 2.26 (a) and (b).

Figure 2.28 (a): Update query.

Figure 2.26 (b): Select query of the updated record.

DELETE Data Query Language (DQL)


command
The DELETE command is used to
delete existing records in a table. After DQL is used to fetch the data from the
database. It uses only one command,
inserting data, you can delete the data by
which is SELECT. Its syntax is SELECT
using the delete command. The syntax column1, column2, ...FROM table_name;
is DELETE FROM table_name WHERE
Example: If you want to retrieve the first
condition;
name and middle name only from the
For example: if you want to delete all student-registration table, the query is
the information about Musawomda from such that:
our previous example, the query will be: SELECT FirstName, MiddleName
DELETE FROM student_registration FROM student_registration
WHERE FirstName=’ Musawomda ‘; OUTPUT (see Figure 2.27):
this query will delete all records with the
first name Musawomda. If you want to
delete only the record for Musawomda
with studentId 1234, you should write
the following query:
DELETE FROM student_registration
WHERE studentId=1234; Figure 2.27: The output of the SELECT
query

108
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 108 23/01/2023 11:26:48


Data Control Language (DCL) command into logical transactions. The transaction
control language consists of COMMIT,

Computer Science
It is used to control users’ rights in
accessing data in the database. It uses ROLLBACK, and SAVEPOINT.
two controls, GRANT and REVOKE.
COMMIT
GRANT COMMIT command is used to save
any transaction into the database
It is used to give users access privileges permanently. When we use any DML
to a database. The syntax is GRANT command like INSERT, UPDATE or
privilege [,privilege], ON privilege_ DELETE, the changes made by these
level TO account_name; commands are not permanent; until the
For example, If you need to give user_M current session is closed, the changes
access to the database student, the query made by these commands can be rolled
will be: back. To avoid that, we use the COMMIT
GRANT ALL command to mark the changes as
permanent. The syntax is COMMIT;
ON student
Example:
TO user_M;
Delete from student_registration
Where address = 250 Dodoma;
REVOKE
Commit;
It is used to revoke access permissions
that were previously granted to prevent a
user from accessing the database objects. ROLLBACK
The syntax is REVOKE privilege_name If you have used the UPDATE command
ON object_name FROM {user_name to make some changes to the database
|PUBLIC |role_name} and realise that those changes were not
For example: If you need to remove required, you can use the ROLLBACK
user_M from accessing the database command to roll back those changes
student, the query will be: if they were not committed using the
COMMIT command.
REVOKE ALL
Example:
ON student
Delete from student_registration
FROM user_M;
Where address = 250 Dodoma;
Rollback;
Transaction Control Language (TCL)
command SAVEPOINT
Transaction Control Language command It is used to roll back the transaction to
is used to handle database transactions. a certain point without rolling back the
It keeps track of the modifications made entire transaction. The syntax for the
by the data manipulation language. It savepoint commands is SAVEPOINT
also enables the grouping of statements savepoint_name;

109
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 109 23/01/2023 11:26:48


Example: Security features for database
Computer Science

UPDATE class SET name = ‘Mwamtumu’ Security and protection are two of the
WHERE id = ‘5’; most critical and continually changing
SAVEPOINT A; aspects of database administration.
The major DBMS suppliers have
been introducing security features and
enhancing how you can protect your
Activity 2.10: valuable corporate data. However,
Think of any problem needing a database keeping up with these features can be
table with 10 columns, design it, create challenging; so, let’s take a quick look
it, and then populate the table with SQL at some of the more exciting and helpful
and fill it. database security choices.

Encryption
Exercise 2.7 Even though encryption has been
available for a long time, it has only
1. 
What is the difference between recently become a significant part
SQL and MySQL? of database security for securing
2. 
What do you mean by DBMS? sensitive data. When data is encrypted,
What are its different types? it is altered using an algorithm to be
incomprehensible to anyone who does
3. Describe the five groups of SQL
not have the decryption key. The main
commands.
goal is to make decrypting so tricky
4. What is the difference between that the effort of accessing the data
DELETE and TRUNCATE outweighs the gain benefit to a hacker.
commands? Data encryption can be used in two
scenarios: data in transit and data at
General database administration rest. Data “at rest” encryption protects
data kept in a database, whereas data
A person who manages the database
“in transit” encryption protects data
daily is called a database administrator
transported over a network.
(DBA).
The primary responsibility of a Label-based access control
database administrator (DBA) is
to guarantee that data is available, Label-based access control (LBAC)
secure from loss and damage, and is now available in many DBMSs,
conveniently accessible when needed. providing greater fine-grained control
The administrator will plan for whom over authorisation to specific data in
to use what and when. User role in the the database. LBAC can accommodate
database is essential; for example, a applications that require a more
super admin accesses all the privileges; granular security strategy. LBAC can be
this user assigns roles as discussed in configured to control who can read and
Data Control Language (DCL). alter data in specific rows and columns.

110
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 110 23/01/2023 11:26:48


Staying up to date models, and common relational

Computer Science
Maintaining current knowledge of your database terminologies. Other
DBMS’s security requirements and relational databases emphasise
capabilities. Understand what you have relational database models, types
at your disposal and what you may need of the relational data model, the
to supplement with extra tools. Also, Entity-Relationship model, and
keep in mind that the security features normalisation.
discussed here are not the only ones
4. Furthermore, the chapter presented
available to you for protecting your
database data. database management focusing
on Structured Query Language
(SQL) involving DDL, DML, DCL
Activity 2.11: and TCL and the general database
Assigning roles to users in the MySQL administration with a focus on
database security features to ensure the
Create a database of a law company, availability and accessibility of the
create three roles: the super admin, database.
the company manager, and the head of
human resources, and assign those roles Revision exercise
to Moris, Salima and Berth respectively.
1. What is an information system?
Give examples from your
Chapter summary community.
1. Today, people and organisations 2. 
Differentiate between any two
use various information systems components of the information
for handling their daily activities system.
socially, economically, and
3. 
There are four main types of
spiritually in areas such as
information systems. With an
education, healthcare, water,
example, briefly describe how they
power grid, restaurants, religion,
interrelate.
transport, travelling, tourism, and
entertainment. 4. 
What are the six components
that make up an information
2. In this chapter, you have learned
system? Describe the role of each
about these information systems
component.
and how to create, manage and
apply them in real life. 5. 
What are the three examples of
information system hardware?
3. The covered areas are an overview
Identify the role of each of them.
of information systems focusing
on their elements, components and 6. What is the most commonly used
type and database systems focusing database model? Differentiate it
on their advantages, database from the rest.

111
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 111 23/01/2023 11:26:48


7. What is normalisation? Explain its 15. Given two tables created and
populated as follows,
Computer Science

importance in relational database


design. CREATE TABLE dbo.envelope
(id int, user_id int);
8. Keys are an essential part of the
relational database. They are used CREATE TABLE dbo.docs(idnum
to establish and identify the relation int, pageseq int, doctext varchar
between tables. Using an example, (100));
describe various keys applicable in INSERT INTO dbo.envelope
database implementation. VALUES
(1,1),
9. What is a functional dependency?
State how it relates to, and differs (2,2),
from normalisation.
(3,3);
10. What are some of the most popular INSERT INTO dbo.docs
Relational Database Management (idnum,pageseq) VALUES
Systems?
(1,5),
11. From the database administration
perspective, differentiate the (2,6),
application of encryption and (null,0);
label-based access control and then
outline the importance of each. then, what will the result be from
the following query? Explain your
12. Explain how you can test for NULL answer?
values in a SQL database. (i) UPDATE docs SET
pageseq=7;
13. 
Identify what is wrong with the
below query.
(ii) UPDATE docs SET
SELECT EmployeeID, AVG (Salary) pageseq=11 WHERE
FROM EmployeeDetails IDNUM=2;
WHERE AVG(Salary) > 75
(iii) 
DELETE FROM envelope
GROUP BY EmployeeID WHERE id=3;
14. 
Write a SQL statement to create
a table named as country that (iv) UPDATE envelope WHERE
contains columns country_id, id=73;
country_name and region_id.

112
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 112 23/01/2023 11:26:48


Computer Science
Chapter
Three Data communication and networking

Introduction
The transmission of digital data across a network or to a device other than the
sending device is the foundation of modern telecommunications. Telephones,
computers, Internet, and wireless technology have revolutionised society in how
they interact and work due to data communication and networking. Without these,
modern civilization would be substantially different. In this chapter you will learn
data communication and computer networks, network, topologies and network
architecture. The competence develop will enable you to plan and implement a
simple data communication network in a school or home environment.

Concept of data communication Characteristics of data communication


Data and information The effectiveness of any data
Data refers to the raw facts collected, communication system depends
such as text, images, and symbols, while upon the following four fundamental
information refers to the processed data characteristics:
that enables us to take decisions. For (a) Delivery: The system must deliver
example, when the result of a particular data to the correct destination. Data
test is declared, it contains data from all must be received by the intended
students. When you find the marks you device or user and only by that
have scored, you have the information device or user.
that lets you know whether you have (b) Accuracy: The communication
passed or failed. The data transmission system should deliver the data
is from one point, called the source or accurately, without introducing any
transmitter to another point, called a errors. The data may get corrupted
destination or receiver. during transmission, affecting the
Data transmission can be defined as the delivered data’s accuracy. Data that
exchange of data between two devices have been altered in transmission
via some form of transmission media and left uncorrected are unusable.
such as a wire cable or wireless. For (c) Timeliness: Audio and video data
data communications to occur, the have to be delivered on time without
communicating devices must be part delay. Such a data delivery is called
of a communication system made up of real-time data transmission.
hardware and software.

113
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 113 23/01/2023 11:26:48


(d) An unsteady: It is the variation in resolution) and the bit pattern used
the packet arrival time. Uneven to indicate the value of each pixel.
Computer Science

signals may affect the timeliness of Example: If an image is purely


data being transmitted. black and white (two colours),
each pixel can be represented by a
Data representation forms value of 0 or 1. So, an image made
Data is the collection of raw facts which is up of 10 x 10-pixel elements would
processed to deduce information. There require only 100 bits in memory to
are different forms in which data can be be stored.
represented. Some data representation (d) Audio: Data can also be in the form
forms used in communications are as of sound, which can be recorded
follows: and broadcast. For example what
(a) Text: Text includes a combination we hear on the radio is a source of
of alphabets in small cases and data or information. Audio data is
upper cases. It is stored as a pattern continuous, not discrete.
of bits. Prevalent encoding systems (e) Video: Video refers to the
are American Standard Code for broadcasting of data in the form of
Information Interchange (ASCII) moving pictures or movies.
and Unicode
(b) 
Numbers: Numbers include a Data communication model
combination of digits from 0 to Generally, the data communication
9. It is stored as a pattern of bits. model represents the holistic structure
Prevalent encoding system are of the communication system.
ASCII and Unicode
Basic components of the data
(c) Images: Is a visual representation communication model
of something. In computers, images
are digitally stored. It is formed by A basic data communication model
picture elements called a pixel. A consists of three components: source,
pixel is found in the image and it is medium, and destination. Figure 3.1
the smallest element of an image. shows the components of the basic data
In simple terms, a picture or image communication model.
is a matrix of pixel elements.
Sender/Souce
The pixels are represented in the
form of bits whereby each pixel
would require a different number of Medium
bits to represent the value of a pixel
depending on the type of image Receiver/Destination
(black and white or coloured).
The size of an image depends on Figure 3.1: Components of data
the number of pixels (also called communication

114
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 114 23/01/2023 11:26:48


The description of the communication model elements

Computer Science
Sender/Source: The device that generates the data transmission is known as the
sender, for example, a terminal computer or mainframe computer.
Transmission medium: The path through which the message passes or propagates
from the sender to the recipient—for example, cables, microwaves, fibre optics, and
radio frequency.
Receiver: The device that receives the message, for example, printer, terminal,
computer, and mainframe.

Data communication models key elements


The exchange of data between two parties is the primary goal of a communications
system.
Let us look at a simple communication paradigm whereby the significant features
of the model were invented by Shannon (1948). According to Shannon, data
communication can be modelled using a systematic view with five components.
These components are the source, transmitter, medium, receiver, and destination, as
shown in Figure 3.2.

Figure 3.2: Data communication model block diagram

The description of each data communication model component


Source: The data to be transferred is generated by this device; examples include
telephones and personal computers.

Transmitter: The data generated by a source system is not directly delivered in the
form it was generated. A transmitter converts and encodes that data into a format
appropriate for transmission before transmitting it via a transmission system.

Transmission System: A transmission system is a single transmission line or medium


that connects the source and destination and allows them to transfer data.

Receiver: The receiver receives and transforms the signal from the transmission
system.

115
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 115 23/01/2023 11:26:48


Destination: This is the point that Advantages of analog communication
Computer Science

receives data from the sender. Analog communication offers the


following advantages:
Data communication modes (a) They use less bandwidth
The process of sending data between (b) They are easier to process
two devices connected over a network
is a communication mode or method. (c) They are inexpensive
These modes control the direction of
information flow. Disadvantages of analog
communication
Assume that you have two devices
that need to communicate, whereby (a) Analog signals usually are lower
device A is a transmitting device and quality signals than digital signals.
device B is a receiving device; TxD (b) Data transmission at long distances
in data communication represents the may result in undesirable signal
transmitting device, and RxD represents disturbances.
the receiving device. Data transferred
(c) 
Analog signals are prone to
over the medium can either use analog
generation loss.
or digital communication systems.
(d) Analog signals are subject to noise
Analog communication mode is
and distortion compared to digital
a transmission mode made of the
signals with much higher immunity.
continuous varying waveforms that are
transmitted between TxD and RxD, as Digital communication mode transfers
shown in Figure 3.3(a). the message signal in digital form, that
is to say, in a non-continuous discrete
form, as shown in Fig 3.3(b)

Figure 3.3: (a) Analog data signal

116
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 116 23/01/2023 11:26:48


Computer Science
Data flow direction from sender to receiver

Figure 3.3(b): Digital data signal

Advantages of digital communication (g) Digital information can be saved


(a) 
In digital communication, the and retrieved when required, while
speech, video and other data may be it is not possible in analog.
merged and transmitted over a shared (h) The error correction and detection
channel using the multiplexing techniques are implemented
technique. Through multiplexing efficiently in the digital
techniques, digital communication communication system.
can combine multiple signals into
(i) Digital communication is
one shared medium.
cheaper compared to analog
(b) The digital communication system communication.
is simpler and cheaper because
of the advancement of integrated It is simpler to design and configure
circuit (IC) technologies. digital communication systems than
(c) It has a mechanism for controlling analog ones, even though they are
the amount of interference. challenging.
(d) The devices used are mostly similar Disadvantages of digital communication
in digital communication because (a) Due to analog to digital conversion,
they have a common structure for the data rate becomes high;
encoding signals. therefore, more transmission
(e) The digital communication system bandwidth is required for digital
has more protection against noise communication
and outdoor interference.
(b) 
Synchronization is required in
(f) 
Digital communications provide digital communication during the
added security to information process of synchronous modulation.
signals because the transmission
of information is done in digital (c) 
Digital commutation has high
or encoded form, which means the power consumption rate.
signals are encrypted.

117
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 117 23/01/2023 11:26:48


 ctivity 3.1: Advantages and
A Classification of data transmission mode
disadvantages of analog and
Computer Science

Data can be transmitted from source to


digital television destination device in different ways. This
In 2013, the Government of Tanzania was section describes various classifications
the first East African country to migrate of data transmission modes based on
from analogue broadcasting to digital three criteria, as shown in Figure 3.4.
terrestrial television broadcasting. It (a) 
Based on the number of wire
directed analog broadcasting companies connections and number of bits
to switch off their devices. In your own sent simultaneously:
words, discuss both the advantages and (i) Parallel transmission
disadvantages of analog and digital (ii) Serial transmission
television broadcasting. (b) Based on bit synchronization and
time control:
To ensure that each device can send to (i) Asynchronous
and receive data from other digital, the (ii) Synchronous
International Standard Organization
(c) 
Based on the direction of signal
(ISO) established interface standards to
flow or direction of exchange of the
govern hardware designers not to create
information:
their own signalling representation for
their devices; hence harmonizing the (i) Simplex
intercommunication between different (ii) Half-duplex
hardware devices regardless of vendor. (iii) Full-duplex

Data transmission method

Parallel transmission Serial transmission

Asynchronous Synchronous Isochronous

Figure 3.4: Types of data transmission modes

118
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 118 23/01/2023 11:26:49


Based on the number of wire connections serial transmission uses only one circuit
and the number of bits sent simultaneously to connect the two devices. As a result,

Computer Science
Serial transmission serial transmission is appropriate for
long-distance transmission, as shown in
Sending data sequentially across a data Figure 3.5.
transmission medium is called serial
communication. In serial transmission, Data are usually transmitted as packets.
data are transmitted bit after bit. The Each packet is given a packet identifier
Least Significant Bit (LSB) is usually (packet ID) before being transmitted for
transmitted first. While sending data the proper reception and reassembling of
serially, characters or bytes are broken data on the receiver side. The packet ID
into bits before being transmitted. As a is the part of a small header that is added
result, hardware is needed to transform at the beginning of each packet of data
the data from parallel to serial. At the created as a result of the fragmentation
destination, all of the bits are gathered, of the original message. The header of
measured, and assembled as bytes in the each packet contains other information
destination’s memory. This necessitates like routing information (source and
a serial-to-parallel conversion. destination IP address and Media Access
Control (MAC) address).
As opposed to parallel transmission, the

Figure 3.5: Serial data communication

Serial transmission is used when


(a) The data is to be transmitted over a long distance;
(b) In cases where the amount of data being sent is relatively small.

Parallel transmission
As demonstrated in Figure 3.6, the parallel transmission simultaneously sends all
of the bits of a byte on separate channels. Multiple connections between the two
devices are thus required in this case. This is the fastest means of sending data
from one location to another. The disadvantage of parallel transmission is that, it is
quite expensive because it necessitates using many lines for both transmitting and
receiving devices. Second, it necessitates remarkable precision, which cannot be
guaranteed across large distances.

119
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 119 23/01/2023 11:26:49


Parallel transmission is used when:
Computer Science

(a) A large amount of digital data is to be transmitted


(b) The digital data to be sent is time-sensitive; and
(c) The digital data needs to be sent quickly.
For example, parallel transmission is used to send data in video streaming. Since
video streaming requires the transmission of large volumes of data, the data being
sent is also time-sensitive as slow data streams result in poor viewer experience.
Figure 3.6 shows parallel data communication.

Figure 3.6: Parallel data communication

Table 3.1 shows the difference between serial and parallel transmission.
Table 3. 1: Comparison between serial and parallel transmission
Serial Transmission Parallel Transmission
Data flows in both direction bit by bit Data flows in multiple directions, 8 bits at
a time
Inexpensive Expensive
The number of bits transferred per clock The number of bits transmitted per clock
pulse is 1 bit pulse is 8 bits
Used for low-speed data transmission Used for high-speed data transmission
Used for long-distance communication Used for short-distance communication
It can be used to connect computer to It can be used to connect the computer to
computer the printer

Based on bit synchronization and time control


One of the most difficult aspects of data transmission is keeping the receiver
(destination) synchronised with the sender (source). This is the core concern with
serial communication. The receiver must be able to recognize the beginning of each
new character in the bit stream that is being presented to it; otherwise, it will be
unable to interpret the incoming bit stream correctly.

120
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 120 23/01/2023 11:26:49


There are two main types of serial data transmission methods based on bit
synchronization and time control. These are:

Computer Science
(a) Asynchronous
(b) Synchronous
These types of transmission use bit synchronization. Bit synchronization is necessary
to identify the beginning and end of the data transmission. Bit synchronization
supports the receiving computer in recognising when data transmission begins and
ends. Therefore, bit synchronization offers timing control.

Asynchronous communication: This sends one character at a time, separated by


a start bit and one or two stop bits as in Figure 3.7. Every frame starts with a start
bit, which allows the receiving device to adjust to the timing of the sent signal. The
message can start whenever it wants. Messages are kept as short as possible in this
case because the sending and receiving devices should not be out of sync while the
message is being sent. Asynchronous communication is the most often used method
for transmitting character data and is best suited for characters that are delivered at
irregular intervals, such as when users type in character data from the keyboard.

Figure 3.7: Asynchronous communication mode

A frame used to transmit character data has four components:


A start bit: It is starting frame and enables the receiving device to synchronize itself
with the message. It tells the receiver the end of one bit in the data transmission
process.
Data Bits: Consists of 7 or 8 bits when character data is being transmitted.
Parity Bits: Eight bits are transmitted at a time with a start and stop bit which are 0
and 1, respectively. These bits (start and stop) are known as Parity bits are used as a
crude method for detecting transmission errors.
The parity bit: Is used for error detection in asynchronous transmission. Parity
approaches can detect errors that affect only one bit; but, if errors affect two or more
bits, parity techniques may be unable to detect them.

121
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 121 23/01/2023 11:26:49


A stop bit or bits: Signals the end of the (c) Overhead data bits are start bit (1 bit),
data frame. stop bit (1 bit), and parity bit (1 bit).
Computer Science

Advantages of asynchronous Example 1: Determine the efficiency


communication of 30KB data transmission using the
(a) Asynchronous transmission is easy Asynchronous transmission method.
and affordable. Solution:
(b) It is perfect for transferring small Actual data = 30KB=30×8Kb=240Kb
frames at irregular intervals (e.g., =1000×240b=240,000 bit
data entry from a keyboard). Overhead data bit required for each
Because each individual character group of 8 bit = 3 bit
is complete in itself, if a character
So, total overhead data bits required for
is corrupted during transmission,
240000 bit data transmission
its successor and predecessor are
unaffected. = (3/8)× 240,000 = 90,000bit
(c) 
No synchronization is required Total bits = Actual data bit + overhead
between the transmitter and data bits = 240,000 bit + 90,000 bit
receiver devices. The sender can = 330,000 bit
directly transmit data and the So, efficiency
receiver can receive that data. = (240,000/330,000) × 100% = 72%
(d) 
The sender does not require any Synchronous communication
primary storage device.
Instead of sending one character at a
(e) The cost is very low to implement time, synchronous communication sends
this method. an entire block (chunks or frames) of
data bits at once. Transmission starts at a
Disadvantages of asynchronous
predefined regular time interval in this case.
communication
A synchronisation signal is used to inform
(a) 
Unsuitable for huge amounts of the receiving station of the arrival of a new
data transmission. frame and to synchronize the receiving
(b) Less efficient. station as illustrated in Figure 3.8.
In this method, bit stream is combined
The efficiency of asynchronous
into longer frames that may contain
transmission:
multiple bytes.
In order to evaluate the efficiency of
Note: Data is stored in memory before
the asynchronous data transmission, the
it can be transmitted to divide it into
following formula is applicable:
several blocks. Then, it is transmitted
Where, block by block with regular interval.
(a) Actual data bits refer to the amount A block consists of several characters
of data bits to be sent over the (normally 128, 256, 512, 1024
medium. characters) with header information
(b) Total bits refer to the sum of actual (16 bits) at the beginning and trailer
data bits and overhead data bits. information (16 bits) at the end.

122
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 122 23/01/2023 11:26:49


Computer Science
Figure 3.8: Synchronous communication

Synchronous signals often use a bit receives this CRC value appended to it.
pattern that cannot be found anywhere The receiver does the same algorithm
else in the transmission, ensuring that to recalculate the CRC and compare
they are always distinct and easily the CRC in the frame to the calculated
recognised by the receiver. Frames value. If these values match, the frame
can be longer since the transmitter and was sent successfully.
receiver remain in synchronization for An end-bit pattern indicates the end
the whole period of the transmission. of the frame. End’s bit pattern is
As frames become longer, the parity similar to synchronisation signal, in
method of error detection becomes that it does not exist elsewhere in
ineffective because, if many bits are the messages, ensuring that they are
affected, the parity technique will not always distinct and easily recognised
reliably report the fault. As a result, at the end of the frame. For high-speed
the Cyclic Redundancy Check (CRC) communication between computers,
is employed with the synchronous serial synchronous transmission is used.
transmission. When large amounts of data must be
A CRC value is calculated by the sent, it is employed. Table 3.2 shows
transmitter using an algorithm that sums the advantages and disadvantages of
the value of all data bits. The data frame synchronous and communication.

Table 3. 2: Advantages and disadvantages of synchronous communication


Advantages Disadvantages
Efficiency is comparatively It is comparatively expensive since it requires a complex
very high. circuit and its implementation is difficult.
The speed of data The entire data block is lost when a transmission error
transmission is very high. occurs, not just a single character.
No need to transmit the start The sender cannot just transmit characters as they occur
and stop bit. but must store them until a block has been built up. As
a result, it becomes ineffective, where characters are
generated at irregular intervals.
It is suitable for a large The primary storage device is required.
amount of data transmission.
Synchronization between the source and target is
required.

123
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 123 23/01/2023 11:26:49


The efficiency of synchronous transmission
Computer Science

In order to evaluate the efficiency of the synchronous data transmission, the following
formula is applicable:
Actual data distance
Efficiency = × 100
Total bits
Where,
(i) Actual data bits refer to the amount of data bits to be sent over the medium
(ii) Total bits refer to the sum of actual data bits and overhead data bits
(iii) Overhead are header information (16 bits) and trailer information (16 bits)

Example 2: D
 etermine the efficiency of 30KB data transmission using the
asynchronous transmission method.
Solution:
Actual data = 30KB=30×8Kb=240Kb=1000×240b=240,000 bit
Suppose, a block has 80 characters, So, block size = 80×8 bit = 640 bit
Overhead data bit required for each block of 640 bit group = 32 bit
So, total overhead data bits required for 240,000 bit data transmission
= 32/640)×240,000 = 12,000 bit
Total bits = Actual data bit + overhead data bits = 240,000 bit + 12,000 bit
= 252,000 bit
So, Efficiency = (240,000/252,000) × 100% = 95%

Note: The more a block has characters, the more method has efficiency.

The difference between synchronous and asynchronous transmission is as indicated


in the Table 3.3.
Table 3.3: Synchronous vs Asynchronous transmission
Synchronous Transmission Asynchronous Transmission
Transmit data in the form of blocks, Transmits 1 byte or character at a time
chunks or frames
The transmission speed is high The transmission speed is low
Expensive Economical
It has a constant time interval Has random time interval
There are gaps between the data There are no gaps between the data
They are used in Chatrooms, Telephone They are used in Emails, forums and
conversations and video conferencing. letters.

124
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 124 23/01/2023 11:26:49


Based on the direction of signal flow or direction of exchange of the information

Computer Science
There are three types of transmission modes under this subclass. These are simplex
mode, half duplex and full duplex.
Simplex mode: Data can only be transmitted in one direction; hence communication
is unidirectional. As a result, they cannot convey a message to the sender. Simplex
systems use unidirectional communication, in which we only need to provide
a command/signal and do not require a response. Loudspeakers, television and
remote control, radio call, keyboard and monitor are examples of simplex mode,
as in Figure 3.9.

Figure 3.9: Simplex mode

Half-duplex mode
Half-duplex data transmission implies that data can be delivered in both directions
on a single signal carrier, but not simultaneously.
For example, on a local area network using half-duplex transmission technology,
one workstation can send data on the line and then immediately receive data on
the line from the same direction in which the data was just transferred. On contrary
to the half-duplex transmission, which requires a bidirectional line (one that can
transmit data in both ways), data can only be delivered in one direction at a time.
A radio call used by police is an example of half-duplex communication in which
messages are sent one at a time but in both directions. Figure 3.10 shows the half-
duplex mode.

Figure 3.10: Half-duplex mode

125
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 125 23/01/2023 11:26:49


Full duplex mode
Computer Science

Full duplex mode allows data transfer in both directions simultaneously. A telephone
network is an example of full duplex communication since it allows two people to
talk and listen simultaneously across a telephone line.
There are two lines in a full duplex system, one for sending and receiving data.
Figure 3.11 illustrates full-duplex mode.

Figure 3.11: Full-duplex mode

Exercise 3.1
1. Colour image uses 16 bits to represent a pixel. What is the maximum number
of different colours that can be represented?
2. Discuss the concept of data communication system.
3. Calculate the efficiency of 1MB data transmission using asynchronous
transmission method.
4. Calculate the efficiency of 1MB data transmission using synchronous
transmission method.
5. Discuss the real life application of Simplex, Half-duplex, Full-duplex
communication modes at your environment.
6. What are the advantages of digital data over analog data?

126
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 126 23/01/2023 11:26:49


Computer networks like Coaxial cable, Twisted and

Computer Science
Computer networking has changed the Untwisted pair cable and fiber
way people communicate information optics cable; unguided transmission
globally and locally. It has also changed media such as radio waves,
business operations, social services, microwaves and infrared.
and knowledge sharing. It is on these
Classification of computer networks
grounds the study of computer networks
becomes essential. A computer network can be classified
based on various criteria. However, the
Concept of computer network most common criteria are:
A network is a collection of devices (a) Classification based on
(nodes) linked together by a geographical area
communication medium. A node can (b) Classification based on ownership/
be a computer, printer, or any other access restriction
device that can send and/or receive data
(c) Classification based on topology
generated by other network nodes.
(d) Classification based on architecture
The computer network can be defined
as the collection of computers and other
Classification of computer networks
communication devices linked together
based on geographical area
using communication media for the
purpose of data communication and The geographic area and number of
resource sharing. Electronic devices on computers that are part of a network
the network may be connected by cables should be used to represent the size of
or wireless. a network. It ranges from devices in
a single room to millions of devices
Components of computer network dispersed worldwide. The following are
The computer networks environment is the most common types of computer
made up of the following: networks under this category:
(a) Network devices include Network Personal Area Network
Interface Cards (NIC), hubs, Personal Area Network (PAN) is a
switches, routers, repeaters, bridges computer network built around a single
and modems. person. It comprises a computer, mobile
(b) Network software such as Network device, or personal digital assistant. PAN
connects personal gadgets to a digital
Operating Systems (NOS) such
network and the internet by establishing
as Microsoft Window server and
communication between them. PAN
Ubuntu Server. Network software
is the smallest network which is very
manages end-user devices such as
personal. This type of network normally
PC, printers and servers.
ranges from around 10 meters. Figure
(c) 
Transmission media include 3.12 shows an example of a Personal
bounded transmission media Area Network.

127
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 127 23/01/2023 11:26:49


Computer Science

Figure 3.12: Personal Area Network

Personal Area Networks may include (c) It can be wirelessly connected to
Bluetooth-enabled devices or infrared- the internet called WPAN.
enabled devices. When we connect two
or more devices using Bluetooth or (d) Appliances used for PAN: cordless
infrared for data transfer, we create a mice, keyboards, and Bluetooth
network in our personal space. systems.

All Bluetooth-enabled devices, like Advantages of PAN


Bluetooth-enabled headphones and (a) PAN networks are relatively secure
speakers can be a part of the Personal and safe.
Area Network. Also, Infrared enabled
devices like TV remotes, cordless (b) No wire connectivity is required
mouse/keyboards, and infrared touch (c) Easy data synchronization
screens are also part of the personal area
network.
Disadvantages of PAN
Characteristics of Personal Area Network
(a) 
It may establish a malicious
(a) 
It is mostly personal devices connection to other networks on
network equipped within a limited the same radio channel.
area (approximately 10 meters).
(b) Bluetooth and infrared have a slow
(b) 
Allows you to handle the data transfer rate compared to other
interconnection of digital devices networks like LAN (local area
in the surrounding area of a single network).
user.

128
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 128 23/01/2023 11:26:49


(c) Distance limitation: The signal range is a maximum of 10 meters, limiting
long-distance sharing.

Computer Science
(d) A personal area network also uses infrared to interfere with radio signals, and
data can be dropped.

Local Area Network


A Local Area Network (LAN) is a collection of computer and peripheral devices
that are linked in a specific location, such as a school, laboratory, home, or business
building. It is a network that is extensively used for sharing resources such as files,
printers, games, and other applications. For example, connecting computers and
printers at home or office, as shown in Figure 3.13.

Figure 3.13: Local Area Network

LAN is a privately owned network, can reach up to 1000Mbps (1Gbps).


which means anyone can create it. You Characteristics of LAN
just need cables like Ethernet cables or
The following are the important
central devices like a hub or switch to
characteristics of a LAN network:
create it. The Local Area Network is
so secure because there is no external (a) It is a private network; so an outside
connection with the local area network; regulatory body has no control over
so the data shared within the LAN it.
network is safe and cannot be accessed (b) LAN operates at a relatively higher
outside unless one of the member speed compared to other types of
nodes of the network is connected to networks.
the internet. LAN networks are small (c) Uses various kinds of media access
size networks, so they are faster. Data control methods like token ring and
transfer speed over the LAN network Ethernet.

129
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 129 23/01/2023 11:26:49


LAN application area Disadvantages of LAN
Computer Science

(a) 
LAN networks are used in (a) Although LAN saves money due
businesses where all business data to pooled computer resources, the
are stored on servers. initial cost of setting up a Local
(b) LAN can be used in factories. Area Network is relatively high.
(c) 
It can be used at schools and (b) 
Because the LAN administrator
colleges where students, teachers can see any LAN user’s data files, it
and other staff data are stored on does not provide adequate privacy.
the servers. (c) Unauthorized users can gain access
(d) It can also be used in our homes to an organization’s essential
where all computers, mobiles, and data if the LAN administrator
printers are connected through cannot secure the centralized data
central devices (hub/ switch/router) repository.
for the aim of data exchange. (d) 
There are challenges with
software configuration and
Advantages of LAN hardware failures; So, Local Area
Networks necessitate continual
(a) Local area networks can be used administration.
to share computer resources such
as hard disks, DVD-ROMs, and
printers. This drastically reduces Metropolitan Area Network
the cost of purchasing hardware. Metropolitan Area Network (MAN) is
(b) 
Instead of purchasing licensed a computer network that extends across
software for each client in the an entire city, college campus, or a
network, you can use network small region. This network type is larger
licenced software over the network than LAN, which is mainly limited to a
which reduces cost. single building or site. Depending upon
the type of configuration, this type of
(c) Data of all network users can be network allows you to cover an area
stored on a single hard disk of the from several miles to tens of miles.
server computer. In other words, when two or more
(d) You can quickly send files and LANs network are connected for
messages through networked communication, it becomes a MAN
computers. network. Example: If the university
has branches in different locations and
(e) It will be easier to manage data in every branch uses a LANs network, as
a single location, making it more illustrated in Figure 3.14 this types of
secure. network is known as MAN. The company
(f) The Local Area Network allows all connects all LAN networks through a
LAN users to share a single internet telephone line so that all branches can
connection. share data and resources. This type of
network will be called MAN.

130
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 130 23/01/2023 11:26:49


Computer Science
Figure 3.14: Metropolitan Area Network

Characteristics of MAN Advantages of MAN


(a) 
It covers towns and cities in a (a) It offers fast communication using
maximum 50 km range. high-speed carriers, like fibre optic
(b) The most used medium is optical cables.
fibre cables. (b) 
It provides excellent support for
(c) 
It provides an adequate data an extensive network and greater
transmission rate for distributed WAN access.
computing applications. (c) The dual bus in the MAN network
Applications of MAN supports transmitting data in both
directions concurrently.
(a) Since MAN covers the entire city,
this type of network is suitable for (d) 
A MAN network mostly includes
cable Television networks. some areas of a city or an entire city.
(b) It can be used in private industries
Disadvantages of MAN
(c) It can be used in universities and
colleges (a) 
Requires more cable to establish
MAN connection from one place to
(d) 
It can be used in railways and another.
airlines
(b) In a MAN network, securing the
(e) It can be used in military areas for system from hackers is difficult.
communication

131
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 131 23/01/2023 11:26:49


Wide Area Network longer distances. WAN provides
the means by which all offices can
Computer Science

Wide Area Network (WAN) is a type


of computer network that extends over be organized and managed easily
large geographical areas, such as whole through this type of network.
country, states, and the continent or (b) Similar to MAN, the fault tolerance
entire globe. An example of a Wide of a WAN is less, and there is more
Area Network is the internet. When congestion in the network.
many LANs and MAN networks are
connected to each other for the purpose Disadvantages of WAN
of communication, the formed network (a) The initial setup cost of investment
will be termed WAN. There are two is very high.
types of WAN: Switched WAN and (b) Due to long-distance transmission,
Point-to-Point WAN. An example of a noise and error are more frequent
Switched WAN is the Asynchronous in WAN.
Transfer Mode (ATM) network, and
(c) 
Propagation delay is one of the
Point-to-Point WAN is a dial-up line
biggest problems faced here in
that connects a home computer to the
MAN.
Internet.
(d) 
Designing and maintaining the
Characteristics of WAN WAN network is difficult; you need
(a) A communication medium used for skilled technicians and network
WAN is Public Switched Telephone administrators.
Network (PSTN) or Satellite.
(e) 
It requires more time to resolve
(b) WAN’s data rate is slow, about a issues because of the involvement
10th LAN’s speed, since it involves of multiple wired and wireless
increased distance and an increased technologies.
number of servers and terminals.
(f) 
Offers lower security compared
(c) Software files will be shared to other types of networks in the
among all the users on the network; computer.
therefore, all can access the latest
files.
(d) Any organization can form its global Network type based on ownership/
integrated network using WAN. access restriction
(e) Optic wires, Microwaves, and This type of network is sub-categorised
Satellites are used to transmit data into a public and private networks. A
through WAN. public network is a type of network
(f) Speeds of WAN range from a wherein anyone, namely the general
few kilobits per second (Kbps) to public, has access and can connect to
megabits per second (Mbps). other networks or the Internet through it.
This is in contrast to a private network,
Advantages of WAN where restrictions and access rules are
(a) The WAN network is the solution established in order to relegate access to
for business offices situated at a select few.

132
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 132 23/01/2023 11:26:49


Characteristics of Private Network Advantages of computer network

Computer Science
(a) This type of network is owned and Computer systems and peripherals are
controlled by a person or private connected to form a network. They
organization. provide
(b) This type of network is not open to numerous advantages, such as:
all members of the given network. (a) Resource sharing like printers and
Only registered members can use storage devices
this network.
(b) 
Exchange of information using
(c) The security of this type of network E-Mails and FTP
is extremely strong. (c) Information sharing by using the
(d) Has low traffic. Web or the Internet
(e) Computers on this network are not (d) Interaction with other users using
visible to the public. dynamic web pages
(f) 
The administering authority
determines access restrictions. Network topologies
For example: Different banks have their Meaning of network topology
own network system or Intranet of an Computer network topology is the
organisation. way various components of a network
Characteristics of public Network (like nodes, links and peripherals) are
arranged. Network topologies define the
(a) This network belongs to a company layout, virtual shape or structure of the
or Government but allows public network, not only physically but also
service access, usually at a charge. logically. How different systems and
(b) 
This network is not owned and nodes are connected and communicate
controlled by any person or private with each other is determined by the
organisation, but an organization topology of that given network.
runs it. Classification of network topologies
(c) 
Computers on this network are Network topologies are categorised into
visible to the public. two types which are logical topology
For example, the Internet is a public and physical topology.
network because it uses public IP Logical topology refers to how data is
addressing space to enable anyone transmitted from one device to another
access to the resources on the internet, in the network. There are two types of
mobile phone or telephone network logical topologies, Ethernet and token
systems etc. ring.
Note: Computer networks are also Ethernet topology: All computers
(a) 
classified based on architecture and listen to the network media and can
topology as will be described in the next only send data when none of the
subtopics. others is sending.

133
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 133 23/01/2023 11:26:49


Token ring topology: In a token
(b)  from others. A backbone is a single long
ring topology, a special package for cable connecting all network devices.
Computer Science

data called a token goes around the In a bus topology, as in Figure 3.15, all
network. This token will be taken computers or stations attach directly to
by the computers whose addresses a bus network through the appropriate
were attached to the token. hardware interfacing, known as a tap.
Computers will release the token Full duplex operation between the station
after reading the data. In contrast and tap allows data to transmit onto the
to its design, logical topology bus and received from the bus. Any
relates to how data moves through station’s transmission travels the length
a network. of the medium in both directions and can
Physical topology: The physical be received by all other stations. At each
topology refers to the physical layout of end of the bus is a terminator, which
a network which includes the devices, absorbs any signal, removing it from
installation, and location. the bus. Drop lines and taps connect the
The physical topology can be classified nodes to the bus cable. A drop line is a
as bus, ring, star, tree, mesh and hybrid. connection running between the device
They are complex networks which can and the main cable. A tap is a connector
be built of two or more topologies. that either splices into the main cable
These topologies are described in this or punctures the sheathing of a cable to
section as follows: create contact with the metallic core. A
Bus topology: The usage of a multi-point bus network works best with a limited
medium distinguishes bus topology number of computers.

Figure 3.15: Bus topology


Advantages of bus topology
(a) It is an easy installation type of topology.
(b) Bus topology utilizes few amounts of cables in comparison to other types of
topologies.
(c) Bus topology is suitable for a small network.
(d) If one computer fails in the network, the other computers are not affected and
will continue to work.

134
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 134 23/01/2023 11:26:49


(e) It is also less expensive than a star connection and a set of repeaters in a
topology. closed loop. A token is passed along

Computer Science
Disadvantages of bus topology the ring in one direction, from device to
device, until it reaches its destination.
(a) The cable length will be limited,
limiting the number of stations. It may be clockwise or anticlockwise.
When a device receives a signal intended
(b) If the backbone cable fails, the for another device, its repeater generates
entire network will go down.
the bits and passes them along. For the
(c) It is very difficult to troubleshoot. bus and tree, data are transmitted in
(d) Maintenance cost is very high in frames. As a frame circulates past all
the long run. the other stations, the destination station
(e) Terminators are required for both recognizes its address and copies the
ends of the cable. frame into a local buffer as it goes by.
The frame continues to circulate until
Ring topology it returns to the source station, where it
On this type of topology, as shown in is removed. These topologies are used
Figure 3.16 (a) and (b), the network in school campuses and some office
consists of a dedicated point-to-point buildings.

Figure 3.16(a): Ring topology, physical representation (PCs are connected to MAU)

Figure 3.16(b): Ring topology, electrical representation

135
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 135 23/01/2023 11:26:49


Advantages of ring topology (c) Any moves, changes and adds of
the devices can affect the network.
Computer Science

(a) Relatively easy to install and


reconfigure. (d) Network connection devices (like
(b) Fault isolation is simplified. Network adapter cards and MAU)
(c) It performs better than star topology are much more expense than
under a heavy workload. Ethernet cards.
(d) There is no need for the network
server to manage the connection Star topology
between the computers. Each station in a star topology is directly
(e) It is cheaper than star topology connected to a central node known as
because of less wiring. the hub/switch. The devices are not
(f) One can create a large network physically connected to one another,
by adding the token ring to the unlike mesh topology. Direct traffic
network. between devices is not possible in a
(g) It is an ordered network because star topology. When one device wishes
all the devices have access to the to transfer data to another, it sends it to
token ring and the opportunity to the controller, which then, relays it to
transmit. the connected device. Each device in a
Disadvantages of ring topology star only requires one connection and
(a) 
A break in the ring (such as a one I/O port to connect to any number
disabled station) can disable the of others. Local area networks (LANs)
entire network. and high-speed LANs frequently adopt
a star architecture with a central hub.
(b) It is much slower than an Ethernet
network under normal load. Figure 3.17 shows star topology.

Figure 3.17: Star topology (the central device is the hub)

136
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 136 23/01/2023 11:26:49


Advantages of star topology central networking device (hub)
goes down.

Computer Science
(a) If one link fails in the star topology,
only that link is affected. All other (b) 
It requires more cable length
links remain active. compared to the linear bus topology.
(b) It is easy to identify the fault and (c) It is much more expensive than bus
fault isolation. topology because of the cost of the
(c) It is easy to expand the network in hubs.
the star topology. Mesh topology
(d) There are no network disruptions Every device in a mesh topology has its
when connecting or removing dedicated point-to-point link to every
devices from the network. other device. The term “dedicated” refers
(e) It is very easy to manage because to the link that exclusively transports
of its simplicity of function. data between the two devices it links.
Figure 3.18 shows mesh topology.
Disadvantages of star topology
(a) The entire network will fail if the

Figure 3.18: Mesh topology


Types of mesh topology
Partially Mesh: Not all hosts have a point-to-point connection to every other host.
Hosts connect to each other in some arbitrary fashion. This topology exists where
we need to provide reliability to some hosts out of all.
Full Mesh: All hosts have a point-to-point connection to every other host in the
network. Thus, for every new host ‘n(n-1)/2’, connections are required. Full mesh
provides the most reliable network structure among all network topologies.
To calculate the number of physical links in a fully linked mesh network with n nodes,
we must first consider that each node will be connected to at least one other node.

137
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 137 23/01/2023 11:26:49


Node 1 must connect to n-1 nodes, node Advantages of full mesh
2 must connect to n-1 nodes, and node
Computer Science

(a) There is no traffic problem because


n must connect to n-1 nodes. However, of the dedicated link in the mesh
if each physical link can communicate network.
in both directions, the total number of
links can be reduced by two. To put it (b) 
Mesh topology is robust. If one
in another way, we require n (n-1)/2 in a link becomes unusable, it does not
full mesh topology. hinder the entire system.
(c) 
Point-to-point links make full
identification and fault isolation
Example 3 Calculate number of cables easy.
required to connect 4 computers in a
full mesh topology. (d) Security or privacy for data travels
along the dedicated line.
Solution
(e) 
The network can be expanded
Nc = n(n-1)/2 without any disruptions to the
where Nc = Number of cables users.
n = number of nodes Disadvantages of full mesh
n=4 (a) 
Installation and reconnection are
Nc = 4(4-1)/2 difficult
= 4x3/2=6 (b) A large amount of cabling and a
Nc = 6 number of I/O ports is required
The number of cable required to connect (c) The sheer bulk of wiring can be
four (4) computers in a full mesh greater than the available space it
topology is 6 cable. can accommodate
(d) 
The hardware needed to connect
each link can be prohibitively
Example 4 If you are connecting 13 expensive
nodes in a full mesh topology, what will
be the required number of cables? Tree topology
Solution: This is the most popular type of network
Nc = n (n-1)/2 topology in use nowaday. It is also
Where known as hierarchical topology. This
topology imitates extended star topology
Nc = Number of cables
and inherits bus topology traits.
n = Number of nodes
This network topology divides the
= 13 (13 – 1)/2= 78 network into numerous levels/layers. A
Therefore, the total number of cables network is divided into three layers: the
required for connecting 13 nodes = 78 lowest layer is the access-layer, where
computers are connected; the middle

138
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 138 23/01/2023 11:26:49


layer, which is known as the distribution layer, and it serves as a bridge between the

Computer Science
top and lower layers; and the uppermost layer, which is known as the core layer, and
it serves as the network’s central point, i.e. the root of the tree from which all nodes
diverge. Figure 3.19 shows tree topology.

Figure 3.19: Tree topology

All nearby hosts are linked together via a point-to-point connection. Similar to the
bus topology, if the root fails, the entire network suffers. Despite the fact that it is
not the only point of failure, every link serves as a point of failure, and its failure
separates the network into inaccessible segments.

Hybrid topology
A hybrid topology is a network structure designed with more than one topology.
Hybrid topology inherits the benefits and drawbacks of all incorporated topologies.
Figure 3.20 shows the hybrid topology.
The combining topologies can have characteristics of the star, ring and bus
topologies. Most WANs are connected using Dual-Ring topology and the networks
that connect to them are largely Star topology networks. The Internet is the most
prominent example of a huge hybrid topology.

139
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 139 23/01/2023 11:26:49


Computer Science

Figure 3.20: Hybrid topology

 ctivity 3.2: Configure a star


A 5. Create a folder into one computer
network topology and make it shared. Then, try to
Materials: 5 UTP cables, switch/hub, access the shared folder from each
printer, A4 printing papers, two laptops, computer.
and two desktop computers 6. Draw and label the network you
Procedure: have designed and configured.
1.  Take UTP cables and connect
each to a computer and node (hub/ Network architecture
switch) using RJ45 Ethernet ports.
Concept of network architecture
2. Switch on the devices and set the IP
address so that all nodes are in the Computer network architecture refers
same network. to the design and implementation of a
3. Set the printer as a shared one so computer network. It is the physical and
that every user can print from his/ logical organization and arrangement of
her computer. various network devices ( clients such as
PCs, desktops, laptops, mobiles, and so
4.  Load the papers into the printer on) to meet the needs of the end user/
and test if you can print from each customer. In this part, you will learn in
connected computer. detail two classifications of well-known

140
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 140 23/01/2023 11:26:49


computer network architectures, which Advantages of peer-to-peer network
are:

Computer Science
(a) No particular device is a client or a
(a) Peer-to-peer server; the tasks and responsibilities
(b) Client-server network of servers are distributed among
all the devices (which also act as
Peer-to-peer network architecture clients).
In this network, no server is used for (b) 
This network architecture is
control; every node is itself a client inexpensive to set up as there is
and server. Each node can request and no requirement for a centralized
respond for the services and share server. It also ensures that, in case
resources. of any failure in the network, all
In peer-to-peer network architecture, unaffected devices continue to
individual devices are directly linked operate normally.
together and have equal obligations and (c) It is simple to set up and maintain
powers in the absence of any central because each computer runs
authority. Since no central device is in independently.
charge of tasks, this design is sometimes Disadvantages of peer-to-peer network
referred to as decentralized architecture.
Each computer has particular rights (a) No centralized system, thus difficult
for resource sharing. Nevertheless, to keep a backup of the data in case
if the computer with the resource is of any fault.
unavailable, this may cause problems. (b) 
It has a security flaw because
This type of architecture is useful in a computers are self-managed.
small environment with few computers. (c) 
With a growth in the number
Figure 3.21 shows how peer-to-peer of nodes on this network,
network architecture is connected. performance, security, and access
may all become more challenging.

Client-server network architecture


It is a computer networking model
that comprises of a powerful central
computer that controls and provides
services to all terminals/client PCs
connected to it. This central computer is
called a server. Client computers connect
to the server only when they need to use
shared resources or data. All exchanged
data is saved entirely on the server, not
on any other machine.
Figure 3.21: P
 eer-to-peer network The server computer does all types
architecture of processing and controlling in

141
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 141 23/01/2023 11:26:49


this networking arrangement. A server is a specialized computer that handles all
key functions, such as security and network management, as well as controlling
Computer Science

network resources and providing services to other computers on the network. A


server provides the desired services to a client computer, as shown in Figure 3.22.

Figure 3.22: The client-server architecture

Classification of client/server
computing network architecture nodes are directly connected to a server
computer. This is the most popular
Depending on the number of servers and system used in many organizations, in
the storage media, client/server network which a client submits a request to a
architecture can be further divided into server and receives responses.
two types.
In other words, centralized architecture
(a) Centralized Client-Server is one of client/server architecture
Network architecture. having one powerful computer utilized
to service one or more low-powered
(b) Distributed Client-Server Network computers in centralized computing
architecture. architecture. The nodes under the
Centralised Client/Server computing centralized architecture are not linked;
architecture: Centralized network they are only connected to the server.
architecture is a client/server architecture Figure 3.23 shows the centralized
system in which one or more client computing architecture.

142
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 142 23/01/2023 11:26:49


Computer Science
Figure 3.23: Centralised client-server computing architecture

Components of centralised client-server connected to it. It supports various


architecture functions, including file, hardware,
The centralised client-server architecture and network sharing. Client-server
includes the following components: computers process their own data and
transmit the most recent modifications
(a) Server computer/main frame computer: to the mainframe. The mainframe server
The powerful computer which computer handles some of the processes.
handles all processing. Figure 3.24 illustrates distributed
(b) 
Terminals: These are computer computing architecture.
connected to a central computer and The following features are found in
function as input/output devices. distributed client-server architecture:
Linking of at least two mainframe
computers together via networks, (i) Different computers are effective at
terminals communicate solely with performing independently
the mainframe and never with one (ii) 
Completion of tasks on multiple
another. computers locally
Distributed Client/Server architecture: (iii) 
Networks enable computers to
There is a mainframe server that manages exchange data and services but do
other servers in the network that are not offer processing help.

143
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 143 23/01/2023 11:26:50


Computer Science

Figure 3.24: Distributed client-server computing architecture

Collaborative computing architecture


Collaborative computing architecture is a hybrid of centralized and distributive
computing architecture. Under the collaborative paradigm, individual network
members can process their users’ basic needs. Figure 3.25 shows collaborative
computing architecture.

Figure 3.25: Collaborative computing architecture

144
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 144 23/01/2023 11:26:50


Table 3.4: Difference between Client-Server and Peer-to-Peer architecture

Computer Science
Basis of Client-server architecture Peer-to-peer
comparisons architecture
Focus area Information sharing Connectivity
Data Data are stored in the central server Each peer has its own
in the case of a centralized server, data
whereas, in the case of the distributed
server, data are stored on various
servers located on different sites
Implementation Expensive compared to a peer-to-peer Less expensive to
network implement
Differentiation Client and server are differentiated; Client and server are
specific servers and clients are not differentiated
presents
Stability More stable and scalable Less stable if the
number of peers
increases
Services The client request service from the Each node can do both
server and the server responds with requests and responses
a service for the services
Security More secure than a peer-to-peer It is less secure
network because the server can compared to a
authenticate a client’s access to any Client-server network
part of a network.
Performance Does not experience performance The increase in
problems with the increase of clients clients will affect the
since most of the heavy tasks are performance of the
carried by sever network
Reliability It is less reliable compared to It is more reliable
Peer-to-Peer
Access time for Multiple clients request services Service providing nodes
service from the server and therefore, access are distributed; for
time for service is high that reason, a service-
requesting note does not
need to wait long

Advantages of Client-Server architecture


(a) This type of architecture is much easier to scale up since it is much more
convenient to add more server computers than configure the network on each
computer (as in peer-to-peer architecture).

145
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 145 23/01/2023 11:26:50


(b) It has a much faster network speed 4. Assume six devices are arranged in
compared to peer-to-peer network a Mesh full topology, then
Computer Science

architecture (a) Calculate number cables that


(c) This network architecture is more will be required to make the
secure than peer-to-peer because, topology.
in this type of architecture, a single (b) 
How many ports will be
server manages the shared resources required for each device?
in a Client/Server network
5. 
Describe in details merits and
(d) Backing up data is easy because of demerits of distributed network
the centralized system. architecture over centralized
(e) The server provides a customized architecture.
Network Operating System (NOS)
to offer resources to multiple users
who require them.
Activity 3.3: Peer-to-peer file
Disadvantages of Client-Server and folder sharing
architecture Follow the following steps to share your
(a) 
It is more prone to downtime file or folder on your network
because, if the server fails, none Step 1: Navigate to the desktop
of the client machines can get their Step 2: Create your folder
requests served.
Step 3: Navigate to the folder and open
(b) 
Require a dedicated network the properties
administrator to handle all of the
resources. Step 4: Choose who you want to share with
(c) It is far more expensive than P2P. Step 5: Share the folder
This is due to the requirement Step 6: Permissions: Make sure you
for a server with more RAM as give full control to the people that have
well as the necessity for several access to the shared folder. Click Apply,
networking devices such as hubs, then click OK. Once you press OK, you
routers, switches, and so on. will be back at the advanced sharing
page. Press Apply and OK on that page
Exercise 3.2 too.
Step 7: Open Control Panel
1. Explain different types of computer
networks. Step 8: Network and sharing
2. Describes six networking devices Step 9: Navigate to the advanced sharing
used in data communication. settings
3. What is network topology? Discuss Step 10: Choose Home and Work / Public
the classification of network Step 11: Select all options
topologies. Contrast between Tree Step 12: Navigate to networks: Go onto
topology and Mesh topology. another computer and open the file

146
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 146 23/01/2023 11:26:50


explorer. Go into the Network section on the computer is digital, whereas a
found on the left hand side at the bottom telephone line or cable wire can transmit

Computer Science
Step 13: Find the device: Find the only analog data.
original device that the file was shared The primary function of the modem is to
from convert the digital signal into analog and
Step 14: Find the folder that was shared vice versa. A modem is a combination
of two devices modulator and a
Step 15: Open the folder to see the file
demodulator. The modulator converts
contained in it
digital data into analog data when
Step 16: Done the computer is sending the data.
The demodulator converts analog signals
Network devices into digital data when the computer
Network devices are physical hardware receives it.
that allows electronic devices to
communicate with each other. Examples Types of modem
of network devices include routers, The modem can be categorised in several
modems, Switches and Network ways depending on how it can transmit
Interface Cards (NIC). data, the type of connection to the
Modem: Modem is a device that enables transmission line, transmission mode,
a computer to send or receive data over etc. Figure 3.26 shows the modem and
telephone or cable lines. The data stored router connection.
Cable to PC

Cable to ISP

Wireless router

ISP

Socket
Cable to router PC
Moderm

Power cable
Power cable
Figure 3.26: Modem and router connection

Repeater: A repeater is a physical layer device. Its main function is to regenerate


the signal over the same network before the signal becomes too weak or corrupted
to extend the length to which the signal can be transmitted over the same network.

147
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 147 23/01/2023 11:26:50


An important point to be noted about supply from the active hub. These hubs
relay signals onto the network without
Computer Science

repeaters is that they do not amplify the


signal. When the signal becomes weak, cleaning and boosting them and can not
they copy it bit by bit and regenerate it at be used to extend the distance between
its original strength. It is a 2-port device. nodes.
Figure 3.27 shows a multipoint repeater. Intelligent Hub: This is the type of hub
that works like active hubs and includes
remote management capabilities. It also
provides flexible data rates to network
devices. Moreover, they enable an
administrator to monitor the traffic
Figure 3.27: Dual multiport repeater
passing through the hub and configure
Hub: This is a multiport repeater. It each port.
connects multiple wires coming from Bridge: This operates at the data link
different branches; for example, the layer. A bridge is a repeater with add
connector in a star topology connects on the functionality of filtering content
different stations. Hubs cannot filter by reading the MAC addresses of the
data, so data packets are sent to all source and destination. It is also used for
connected devices. In other words, the interconnecting two LANs working on
collision domain of all hosts connected the same protocol. It has a single input
through a hub remains one. Also, they and single output port, thus making it
do not have the intelligence to find the a 2 port device. Figure 3.29 shows the
best path for data packets, leading to network bridge.
inefficiencies and waste. Figure 3.28
shows Hub (D-Link)

Figure 3.28: Hub (D-Link)


Figure 3.29: Example of network bridge
Types of Hubs
Types of Bridges
Active Hub: This type of hub has its own
Transparent Bridges: These are bridges
power supply and can clean, boost, and
in which the stations are completely
relay the signal along with the network.
unaware of the bridge’s existence, i.e.
It serves both as a repeater and as a
whether or not a bridge is added or deleted
wiring centre. It is used to extend the
from the network, thus, reconfiguration
maximum distance between nodes.
of the stations is unnecessary. These
Passive Hub: This is the type of hub that bridges use two processes, i.e. bridge
collects wiring from nodes and power forwarding and bridge learning.

148
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 148 23/01/2023 11:26:51


Source Routing Bridges: In these bridges, a Network Layer device. Routers
routing operation is performed by the normally connect LANs and WANs

Computer Science
source station and the frame specifies together and have a dynamically
which route to follow. The host can updating routing table based on which
discover the frame by sending a special they make decisions on routing the data
frame called the discovery frame, which packets. The router divides the broadcast
spreads through the entire network using
domains of hosts connected through it. A
all possible paths to the destination.
router also strengthens the signals before
Switch: This network device uses a transmitting them; that is why it is also
packet switching technique to receive, called a repeater. Figure 3.31 shows the
store and forward data packets on the Wireless router.
network. The switch maintains a list
of network addresses of all the devices
connected to it. It is sometimes known
as an intelligent hub
Upon receiving a packet, it checks the
destination MAC address and transmits
the packets to the correct port. Before
forwarding, the packets are checked for
collision and other network errors. The
data is transmitted in full duplex mode. Figure 3.31: Wireless router
It forwards data based on the MAC
address. Routing Table: A router reads its routing
table to decide the best available
Data transmission speed in switches can
be double that of other network devices route the packet can take to reach its
like hubs used for networking. This is destination quickly and accurately. The
because a switch shares its maximum routing table may be of these two types:
speed with all the connected devices. Static − In a static routing table, the
This helps to maintain the network speed routes are fed manually. So, it is suitable
even during high traffic. In fact, higher only for very small networks with a
data speeds are achieved on networks maximum of two to three routers.
through the use of multiple switches.
Figure 3.30 shows the Switch with 24 Dynamic − In a dynamic routing table,
ports. the router communicates with other
routers through protocols to determine
free routes. This is suited for larger
networks where manual feeding may
not be feasible due to a large number of
routers.
Gateway: A gateway, as the name
Figure 3.30: Switch with 24 ports suggests, is a passage to connect two
networks together that may work upon
Routers: This is a device like a switch
different networking models. They
that routes data packets based on their
basically work as messenger agents that
IP addresses. The router is mainly
take data from one system, interpret

149
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 149 23/01/2023 11:26:51


it and transfer it to another system. Brouter: This is also known as the
Gateways are also called protocol
Computer Science

bridging router, which is a device that


converters and can operate at any combines features of both bridge and
network layer. Gateways are generally router. It can work either at the data
more complex than switches or routers.
link layer or a network layer. Working
Figure 3.32 shows a Gateway.
as a router, it can route packets across
networks, and when working as a
bridge, it can filter local area network
traffic. Table 3.5 shows the difference
between Router and Brouter.
Figure 3.32: Gateway

Table 3. 5: Difference between Router and Brouter


S.No Router Brouter

A router is a networking
A Brouter is a networking device used both as
device that forwards data
1. a bridge and a router; it combines a network
packets between computer
bridge and a router.
networks.

It operates either at a Data link layer or a


2. It operates at a Network layer.
Network layer.

Brouter stores the routing table when


The router stores the routing
3. configured as a router and stores the MAC
table.
address as a bridge.

Forwarding decisions are based on IP address


It takes forwarding decisions
4. when configured as a router or MAC address
based on IP address.
when configured as a bridge.

Brouter transmits data in the form of packets


The router transmits data in
5. when it is configured as a router and frames
the form of packets.
when configured as a bridge.

Brouter works on more than one broadcast


The router works on more
6. domain when configured as a router and a
than one broadcast domain.
single broadcast domain as a bridge.

Brouter is a full duplex when configured as a


7. The router is a full duplex.
router and a half-duplex as a bridge.

150
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 150 23/01/2023 11:26:51


Network interface card (NIC) Wi-Fi card

Computer Science
This is the network adapter that is used Wi-Fi is the acronym for wireless fidelity.
to connect the computer to the network. Wi-Fi technology is used to achieve
The earliest network cards were external wireless connection to any network. A
to the system and needed to be installed Wi-Fi card is a card used to connect any
manually to establish a network. In device to the local network wirelessly.
modern computer systems, it is an The physical area of the network which
internal hardware component. provides internet access through Wi-
NIC has a unique ID (MAC address/ Fi is called a Wi-Fi hotspot. Hotspots
physical address) written on the chip, can be set up at the home, office or
and it has a connector to connect the public space. Hotspots themselves are
cable. The cable acts as an interface connected to the network through wires.
between the computer and the router or The wireless Network card is shown in
modem. NIC card is a layer 2 device that Figure 3.34.
works on the network in the physical
and data link layers.
Types of network card
There are two types of network cards
namely: Ethernet Card for Ethernet
connection and wireless network card
(Wi-fi) for wireless network connection.
Ethernet card: To establish a network
connection using wire, the device
should have an Ethernet card to support Figure 3.34: Wireless Network card
the connection. The NIC has an RJ45
socket where the network cable is A Wi-Fi card is used to add capabilities
physically plugged in. like teleconferencing, downloading
digital camera images, video chat, etc.,
Ethernet card speeds may vary
to old devices. Modern devices come
depending on the protocols it supports.
with their in-built wireless network
Old Ethernet cards had a maximum
adapter.
speed of 10 Mbps. However, modern
cards support fast Ethernets up to a speed
of 100 Mbps. Some cards even have a Networking models
capacity of 1 Gbps. This is generally There are two types of network models:
known as bandwidth speed. The Ethernet the OSI Model and the TCP/IP model.
Card is shown in Figure 3.33. This section will describe the concept
behind these models with respect to the
data transmission process in the network.
Open System Interconnection (OSI)
model
OSI, stands for Open System
Figure 3.33: The Ethernet card Interconnection, is a reference model

151
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 151 23/01/2023 11:26:51


that describes how information from a inter-computer communications. OSI
software application in one computer
Computer Science

model divides the whole task into seven


moves through a physical medium to smaller and more manageable tasks.
the software application in another Each layer is assigned a particular task
computer. and each layer is self-contained so that
OSI model describes seven layers that the task assigned to each layer can be
computer systems use to communicate performed independently.
over a network. Each layer performs a
particular task. It was the first standard The modern internet is established
model for network communications, based on the TCP/IP model, a simplified
adopted by all major computer and version of the OSI model. However, the
telecommunication companies in the OSI 7-layer model is still widely used, as
early 1980s. it helps visualize and communicate how
The International Organization for networks operate and helps to isolate
Standardization (ISO) developed the and troubleshoot networking problems.
OSI model in 1984, and it is now Table 3.6 shows OSI model layers, their
considered an architectural model for functions and examples.

Table 3.6: OSI Model layers and their function


Layer Function Example
Application (7) Services that are used with
SMTP
end user applications
Presentation (6) Formats the data so that it
can be viewed by the user JPG, GIF, HTTPS, SSL, TLS
Encrypt and decrypt
Session (5) Establishes/ends connections
NetBIOS, PPTP
between two hosts
Transport (4) Responsible for the transport
TCP, UDP
protocol and error handling
Network (3) Reads the IP address from
Routers, Layer 3 Switches
the data packet
Data Link (2) Reads the MAC address from
Switches
the data packet
Physical (1) Send data on to the physical
Hubs, NICS, Cable
wire

Characteristics of OSI layers


The OSI model is divided into two layers; upper layers and lower layers.
The upper layer of the OSI model mainly deals with application-related issues,
which are implemented only in the application software. The application layer is
closest to the end user such that the end user uses the application layer to interact
with the software applications.

152
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 152 23/01/2023 11:26:51


The lower layer of the OSI model deals Layer 4-Transport: The transport layer
with data transport issues. The data link takes data transferred in the session

Computer Science
and physical layers are implemented in layer and breaks it into “segments” on
hardware and software. The physical the transmitting end. It is responsible
layer is the lowest layer of the OSI for reassembling the segments on the
model and is closest to the physical receiving end, and turning them back into
medium. The physical layer is mainly data that the session layer can use. The
responsible for placing the data on the transport layer carries out flow control,
physical medium. sending data at a rate that matches
Functions of OSI layers the connection speed of the receiving
device, and error control, checking if
Layer 7-Application: The application data was received incorrectly; and, if
layer is used by end-user software such not, requesting it again. There are two
as web browsers and email clients. It main protocols under this layer.
provides protocols that allow application
software to send and receive data and (a) Transmission Control Protocol
present meaningful information to users. Transmission Control Protocol
A few examples of application layer is responsible for the systems to
protocols are the Hypertext Transfer communicate over the internet. It
Protocol (HTTP), File Transfer Protocol establishes and maintains a connection
(FTP), Post Office Protocol (POP), and between hosts when sending the
Simple Mail Transfer Protocol (SMTP). data. In order to send the data, the
Layer 6-Presentation: The presentation message to be sent will be divided into
layer prepares data for the application smaller units regarded as segments.
layer. It defines how two devices should During transmission, each segment is
encode, encrypt, and compress data to transmitted through multiple routers,
receive it correctly on the other end. once they reach the destination, TCP
The presentation layer takes any data reorders the packets in the correct order.
transmitted by the application layer and (b) User Datagram Protocol (UDP)
prepares it for transmission over the
session layer. User Datagram Protocol is a transport
layer protocol. It is an unreliable
Layer 5-Session: The session layer transport protocol since, in this
creates communication channels, case, the receiver does not send any
called sessions, between devices. It acknowledgement when the packet is
is responsible for opening sessions, received, and the sender does not wait
ensuring they remain open and functional for any acknowledgement. Therefore,
while data is being transferred, and this makes a protocol unreliable.
closing them when communication
ends. The session layer can also set Layer 3-Network: The network layer
checkpoints during a data transfer has two main functions. One is breaking
if the session is interrupted, devices up segments into network packets,
can resume data transfer from the last and reassembling the packets on the
checkpoint. receiving end. The other is routing

153
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 153 23/01/2023 11:26:51


packets by discovering the best path identifying which network
across a physical network. The network layer is causing an issue and
Computer Science

layer uses network addresses (typically focusing efforts on that layer.


Internet Protocol addresses) to route (b)  The OSI Model helps the network
packets to a destination node. device manufacturers and
Layer 2-Data Link: The data link layer networking software vendors to;
establishes and terminates a connection (i)  create devices and software
between two physically-connected that can communicate with
nodes on a network. It breaks up packets products from any other
into frames and sends them from source vendor, allowing open
to destination. This layer comprises two interoperability.
parts: Logical Link Control (LLC), which (ii) define which parts of the
identifies network protocols, performs network their products should
error checking and synchronizes frames, work with.
and Media Access Control (MAC), (iii) communicate to users at which
which uses MAC addresses to connect network layers their product
devices and defines permissions to operates.
transmit and receive data.
Layer 1-Physical: The physical layer TCP/IP Model
is responsible for the physical cable or The TCP/IP model is sometimes called
wireless connection between network TCP/IP protocol suite. It is a suite
nodes. It defines the connector, the of communication protocols used to
electrical cable or wireless technology interconnect network devices on the
connecting the devices, and is internet. This model was designed and
responsible for transmitting the raw developed by the US Department of
data, which is simply a series of 0s and Defense (DoD) in the 1960s and is based
1s, while taking care of bit rate control. on standard protocols. It stands for
Transmission Control Protocol/Internet
Advantages of OSI Model
Protocol. It contains four layers, unlike
The following are the advantages of the the seven layers in the OSI model. The
OSI model : following are the TCP/IP protocol suite
(a) 
The OSI Model helps the users and layers:
operators of computer networks to; (a) Application layer
(i) determine the required
hardware and software to (b) Transport layer
build their network. (c) Internet layer
(ii) 
understand and communicate (d) Network Access layer
the process followed by
components communicating The diagrammatic comparison of the
across a network. TCP/IP and OSI model is as in
Figure 3.35.
(iii) 
perform troubleshooting by

154
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 154 23/01/2023 11:26:51


Computer Science
Figure 3.35: TCP/IP vs OSI Model layers

Layer 1. Network Access Host-to-host communication: It uses this


This layer combines the Data Link function to determine the path through
Layer and the Physical Layer of the which the data is transmitted.
OSI model. The protocols in this layer Data encapsulation and formatting:
support hardware addressing to allow It uses this function to encapsulate the
for the physical transmission of data. data into a message format known as an
IP datagram to ensure data is sent and
Layer 2. Internet received securely.
An Internet layer is the second layer Fragmentation and reassembly: This
that is also known as the network layer function splits the IP datagram into
with the main responsibility of sending smaller units if the size of the datagram is
the packets from any network to the greater than the Maximum Transmission
destination irrespective of the route they Unit (MTU), which is a limit imposed
take. The following are the protocols by the datalink layer protocol. On the
used in this layer: receiving side, the function reassembles
IP Protocol: IP protocol is the most fragmented units to form the original
significant part of the entire TCP/IP datagram.
suite with the following responsibilities: Routing: When an IP datagram is sent
IP Addressing: IP protocol implements over the same local network, such as
logical host addresses known as IP LAN, MAN, or WAN, it is known as
addresses, which are used by the internet direct delivery. The IP datagram is
and higher layers to identify the device sent indirectly when the source and
and provide internetwork routing. destination are on a distant network.
This can be accomplished by routing

155
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 155 23/01/2023 11:26:51


the IP datagram through various devices HTTPS, TFTP, SMTP, SNP and DHCP.
such as routers.
Computer Science

TCP and UDP mechanism


ARP Protocol
Transmission Control Protocol (TCP)
Address Resolution Procol (ARP) is a
TCP is a communication protocol
network layer protocol with the function
that enables application programs
of finding physical addresses from IP
and computing devices to exchange
addresses. ARP protocol contains ARP
messages over a network. It is designed
requests and ARP replies.
to send packets across the Internet and
ARP request: ARP request is used to find ensure the successful delivery of data
the device’s physical address. and messages over networks.
ARP reply: Nodes within a network will TCP Features
process the request from ARP request,
The following are the features of the TCP:
and the receiving device will understand
the request and reply to the device’s (i) Data delivery: TCP ensures that
physical address in the form of an ARP the data is received correctly, no data is
reply. missing, and it reaches the destination in
the order it was sent. If TCP is not used,
Layer 3. Transport
incorrect data can be received or be out
Its main function is to handle end-to-end of order. For example, some data or
communication and error-free delivery images can be missing if we try to view
of data. Transport layers have two main the web page or download a file without
protocols: TCP.
Transmission Control Protocol (TCP): (ii) Protocol: TCP is a connection-
TCP ensures reliable and error-free oriented protocol which means it
communication between the end system. establishes a connection before
It performs sequencing and segmentation communicating. The process of
of data. It is a very effective protocol establishing a connection is done
but has a lot of overhead due to such through a three-way handshake process.
features. Increased overhead leads to First, the sender sends the SYN message
increased costs. to the receiver, and the receiver sends
User Datagram Protocol (UDP): Unlike back the SYN-ACK message to confirm
TCP, UDP is not considered reliable and that the message has been received.
error-free. After receiving the SYN-ACK message,
the sender sends the acknowledgement
Layer 4. Application
message to the receiver. In this way,
The application layer functions are the connection is established between
similar to the top three OSI model layers: the computers. Once the connection is
Application, Presentation, and Session. established, the data will be delivered.
The application layer is used to manage With TCP, there is a guarantee that, data
node-to-node communication and user- will be delivered successfully, if the data
interface specifications. Protocols found is not received, the TCP will resend the
in application layers include HTTP, FTP, data. Figure 3.36 shows the TCP three-
way handshake process.

156
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 156 23/01/2023 11:26:51


Computer Science
Figure 3.36: TCP three-way handshake mechanism

User Datagram Protocol (UDP)


Similarly to TCP, UDP is also used for sending and receiving messages. Unlike TCP,
UDP is a connectionless protocol, meaning it does not need to establish a connection
before sending the message. This means, UDP does not guarantee the delivery of
the data packet to the receiver side. UDP is also known as the “fire-and-forget”
protocol, because it sends the data and does not care whether the data is received or
not. Differences between the TCP and UDP are shown in Table 3.7.
Table 3.7: The difference between TCP and UDP
TCP UDP
Type of connection It is a connection-oriented It is a connectionless
protocol, meaning the protocol that sends the data
connection needs to be without checking whether
established before the data the system is ready to
is transmitted over the receive it.
network.
Reliable It is a reliable protocol as it It is an unreliable protocol
assures the delivery of data as it does not guarantee the
packets. delivery of packets.
Speed It is slower than UDP as it It is faster than TCP as
performs error checking and it does not guarantee the
flow control and assures the delivery of data packets
delivery of data packets
Header size The size of TCP is 20 bytes. The size of the UDP is 8
bytes
Acknowledgement It uses a three-way It does not wait for any
handshake concept. In acknowledgement rather, it
this concept, if the sender just sends the data.
receives the ACK, the sender
will send the data. TCP also
can resend the lost data.

157
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 157 23/01/2023 11:26:51


Flow control It follows the flow control This protocol follows no
Computer Science

mechanism mechanism in which too such mechanism


many packets cannot
be sent to the receiver
simultaneously
Error checking It performs error checking It does not perform any
by using a checksum. When error checking and does not
the data is corrected, the resend the lost data packets
data is retransmitted to the
receiver
Applications It is mainly used where It is used where fast
a secure and reliable communication is required
communication process and does not care about
is required (like military reliability, like VoIP, game
services, web browsing, and streaming, video and music
e-mail). streaming, etc.

Data encapsulation and data transmission, it is referred to as


de-capsulation process Segments, while when UDP is used for
Data encapsulation: This is the process transmission, it is referred as Datagrams.
of adding additional information when L4 Header Data Datagram
data is processed along layers of OSI
or TCP/IP model. The data application The data will travel and reach the
software is processed across application Network layer. Additional information,
presentation, and session layers of which includes source IP and destination
the OSI model without any additional IP, from the layer 3 header is added. A
information added across these three combination of all data is referred as
upper layers. Packets.
Data Encapsulation process
L3 Header L4 Header Data Packet
In the transport layer, the data is broken
up into pieces. The transport layer adds The Network layer sends the Packets
the header in each broken data, which to the Data Link layer. On reaching the
contains information such as, source Data Link layer, additional information
port, destination port, sequence number, referred to as trailer, which contains
etc. So, everything is combined into a MAC address, destination MAC address
new form. etc., is added. Furthermore, the trailer
The encapsulated data in the Transport added is also used for error checking.
layer is referred as Segments or In the Data Link layer, the encapsulated
Datagrams. When TCP is used in data is referred as Frames.

L2 Header L3 Leader L4 Header Data L2 Trailer Frame

158
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 158 23/01/2023 11:26:51


The Frame in the Data Link layer is Data De-encapsulation process
delivered to the physical layer and is

Computer Science
The Physical layer gets the bits, de-
referred as Bits. encapsulates them into frames, and
Protocol Data Unit (PDU): The sends them to the upper layer.
encapsulated data tends to attain The Data Link layer receives the frames
different names referred as Protocol and checks whether the MAC address
Data Unit when travelling into different matches or not. If everything is matched
layers, as shown in Table 3.8. and no error is found, the layer 2 header
Table 3.8: Protocol Data Unit and layer 2 trailers are removed. It de-
encapsulates the data and packet sent to
LAYER PDU the upper layer.
Application Data The Network layer receives the packet
Presentation Data from the Data Link layer and checks for
Session Data IP addresses. If it matches, the header
Transport Segments/Datagrams in layer 3 is removed. Now the de-
Network Packets encapsulated data packet is delivered to
the Transport layer.
Data Link Frames
Physical Bits Then, the Transport layer gets the data
segments/datagrams from the Network
De-encapsulation layer and removes the layer 4 header.
De-encapsulation is considered as the After travelling through Session,
opposite process of encapsulation. All Presentation, and Application layers,
information added during encapsulation the de-encapsulated data is sent to
is removed when travelling on the the recipient. That is how the de-
receiver’s side from the physical layer encapsulation takes place: Figure 3.37
to the application layer. data encapsulation and de-encapsulation.

Figure 3.37: Data encapsulation and de-encapsulation


159
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 159 23/01/2023 11:26:51


The difference between the TCP/IP IP Address: This is a logical numeric
model and OSI model address that is assigned to every single
Computer Science

The key difference between the TCP/IP computer, printer, switch, router, or any
model and the OSI model is that TCP/ other device that is part of a TCP/IP-
IP is simpler and combines several OSI based network.
layers into one layer. Other defferences It is also, an identifier since this address
are: is used to identify the device on a
(a) 
OSI layers 5, 6, and 7 are combined network. It defines the technical format
into one Application Layer in TCP/ of the packets. Mainly, both network
IP. models, i.e., IP and TCP, are combined
together, so they are referred to as a
(b) 
OSI layers 1, and 2 are combined
TCP/IP. It creates a virtual connection
into one Network Access layer in
TCP/IP. between the source and the destination.

(c) 
TCP/IP does not take To facilitate the routing of packets, the
responsibility for sequencing and TCP/IP protocol uses a 32-bit logical
acknowledgement functions but addresses known as IPv4 (Internet
leaves these responsibilities to the Protocol version 4).
underlying transport layer. Types of IP Addresses
(d) 
TCP/IP is a functional model There are two types of Internet Protocol
designed to solve specific addresses:
communication problems which
are based on specific standard (a) Internet Protocol version 4 (IPv4):
protocols. At the same time, OSI Currently used Internet Protocol version
is a generic protocol-independent (b) Internet Protocol version 6 (IPv6):
model intended to describe all It is an ongoing replacement for IPv4. It
forms of network communication. contains some significant improvements
(e) 
In TCP/IP, most applications use and new features. In this section, IPv4
all the layers, while in OSI, simple will be covered in detail.
applications do not use all seven IP addressing scheme
layers. Only layers 1, 2, and 3
are mandatory to enable any data There are two types of addressing
communication. schemes which are: classful address and
classless address.
Internet Protocol (IP) addressing Classful addressing
Concepts of IP addressing This was the first addressing system
The Internet Protocol is the cornerstone implemented as part of the Internet
of the TCP/IP architecture. All computers Protocol. In 1981, the Classful
on the Internet understand IP. The main addressing network architecture was
tasks of IP are addressing the computers first used on the Internet. The Classful
and the fragmentation of packets. addressing system was superseded by
a Classless addressing scheme with the

160
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 160 23/01/2023 11:26:51


introduction of Classless Inter-Domain Number of addresses = 2n,

Computer Science
Routing (CIDR) in 1993.
where by n=number of host bits.
Classful addressing is a technique
n=32, therefore
that divides the IP addresses into five
categories. Number of addresses
= 232 = 4,294,967,296
Classful IPv4 address
The identifier used in the network layer The IPv4 produces 4,294,967,296
to identify each device connected to addresses, which is not enough for each
device connected to the internet on a
the Internet is the Internet address or
planet. However, various techniques
IP address. An IPv4 address is a 32-bit
were invented, such as variable-length
address that uniquely and universally mask, network address translation, port
defines the connection of a device (for address translation, classes, and inter-
example, a computer or a router) to the domain translation, to conserve the
Internet. It contains no functions for bandwidth of IP addresses and slow
end-to-end message reliability or flow down the depletion of an IP address. In
control. IP makes the ‘best effort’ to these techniques, public IP is converted
forward packets to the next destination into a private IP which the user having
but does not guarantee delivery because public IP can also use the internet. But
it is connectionless. still, this was not so efficient, giving
rise to the development of the next
IP Address categories generation (current generation) of IP
addresses (IPv6).
The IP address can be classified into two
categories: Internet Protocol version 6 (IPv6)
(a) Public address: This address is IPv6 is compatible with all other Internet
considered as any valid address assigned protocols, including TCP, UDP, and
ICMP.
to any user and the organization that is
responsible for registering IP ranges Main IPv6 features
called Internet Service Providers (ISPs), IPv6 is the next generation of IP
and this address will be unique. addresses. The main difference between
IPv4 and IPv6 is the address size of
(b) Private address: this address is IP addresses. IPv4 is a 32-bit address,
considered as any number or address whereas IPv6 is a 128-bit hexadecimal
assigned to a device on a private TCP/ address. IPv6 provides a large address
IP Local Area Network that is accessible space and contains a simple header
only within the Local Area Network. compared to IPv4. It provides transition
IPv4 is a 32-bit address which means strategies that convert IPv4 into IPv6,
that the maximum number of addresses and these strategies are as follows:
that can be supported can be calculated Dual stacking: It allows the user to have
from this formula: both versions, i.e., IPv4 and IPv6, on the
same device.

161
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 161 23/01/2023 11:26:51


Tunnelling: In this approach, all users Classful IPv4 address format
who have IPv6 can communicate with
Computer Science

The 32-bit IP address is separated into


an IPv4 network to reach IPv6. four 8-bit octets, allowing each octet to
Network Address Translation: The have a value ranging from 0 to 255.
translation allows communication Furthermore, the IP address is logically
between the hosts having a different separated into two distinct components,
version of the IP. the network ID and the host ID. The
Number of addresses = 2n , where by n network ID is used to identify the subnet
= number of host bits. upon which the host resides. The host
ID is used to determine the host within
N = 128, therefore,
the given subnet. Figure 3.38(a) IPv4
Number addresses = 2(128) = 340,282, address format.
366,920,938,463,463,374,607,431,76
8,211,456

This hexadecimal address contains both


numbers and alphabets. Due to the usage Figure 3.38(a): IPv4 address format
of both the numbers and alphabets,
IPv6 can produce over 340 undecillion Each IP address consists of four sets
(3.4*1038) addresses. of eight bits, each called octet, which
This 340,282,366,920,938,463,463,374, gives out 32 bits in total. An example
of the IPv4 address format is shown in
607,431,768,211,456 can be read as
Figure 3.38(b).
(340 undecillion, 282 decillion, 366
nonillion, 920 octillion, 938 septillions, 172 . 16 . 254 . 1
463 sextillions, 463 quintillions, 374
quadrillions, 607 trillion, 431 billion, 10101100 00010000 11111110 00000001
768 million, 211 thousand and 456. 1 byte = 8 bits
Parts of classful IPv4 address
32 bits (4 × 8), or 4 bytes
Each network interface connected to the
Internet has a unique address consisting Figure 3.38(b): Example of IPv4
of two parts: address format
The Network address: This is
(i) 
the network’s address within IP addresses can be displayed in three
the Internet (used by gateways typical formats:
for routing IP packets between Binary notation: This is the format
networks). systems on the network used to process
The Host address: This is the
(ii)  the address. An example of binary
computer’s address within the notation is 11000000.10101000.000000
network (used for delivering 01.01100100
packets to a particular network Hexadecimal notation: This is the
interface within the network). format typically used when identifying
IPv6 addresses. An example of

162
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 162 23/01/2023 11:26:51


hexadecimal notation of an IPv4 address The IP address starts from 128.0.0.0 to
is C0.A8.01.64 191.255.255.255, and the mask address

Computer Science
Dotted-decimal notation: This is is 255.255.0.0
the format that is typically used for Class C: Allows 2 million networks,
displaying the IP address in a human- 254 hosts each
readable format. An example of dotted- The IP address starts from 192.0.0.0 to
decimal notation is 192.168.1.100 223.255.255.255, and the mask address
Classful IPv4 Address classes is 255.255.255.0
Different networks have different Class D: Multicast networks, the IP
sizes. There are many small and large address begins from 224.0.0.0 to
networks. To provide efficient use of 239.255.255.255.
32-bit address space, IPv4 is used to Class E: Reserved for future use.
define several address classes and their From 240 to 255, the 255.255.255.255
associated address formats, which are: broadcasts to all the subnets.
Class A: Allows 128 networks, 16 One of the benefits of classful addresses
million hosts each is that they provide a hierarchy to the
The IP address starts from 1.0.0.0 to network through the use of the network
127.255.255.255, and the mask address ID. This translates into an efficient
is 255.0.0.0 routing environment because it is easy
Class B: Allows 16,382 networks, for a router to determine what networks
65,534 hosts each can be grouped and treated as a single
routing entry. Table 3.9 shows the five
different IP address classes.

Table 3. 9: Five IP address classes

First Octat Hosts per


First Octat No. of
Class decimal IP Range Subnet Mask network
binary (range) networks
(Range) ID

0.0.0.0- 224 – 2 27
Class A 0 – 27 0XXXXXXX 27.255.255.255 255.0.0.0

128.0.0.0- 216 – 2 214


Class B 128-191 10XXXXXX 191.255.255.255 255.255.0.0

192.0.0.0– 28 – 2 221
Class C 192- 223 110XXXXX 223.255.255.255 255.255.255.0
Class D 224 - 239 224.0.0.0-
1110XXXX 239.255.255.255
(Multicast)
Class E 240-255 240.0.0.0-
1111XXXX 255.255.255.255
(Experimental)

163
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 163 23/01/2023 11:26:51


Strategies to conserve addresses delays associated with this operation.
Computer Science

Several strategies have been developed (b) Port Address Translation (PAT)
and implemented to help the Internet
community manage IP addresses Port Address Translation (PAT) is
well. These strategies help to reduce another technique to convert a private
the load on Internet routers and help address to a public one. During PAT,
administrators use globally unique IP each computer on LAN is translated to
addresses more efficiently. There are the same IP address (public) but with
two common strategies, which are: a different port number assignment.
This way is much better than the NAT
(a) Private Addressing because we can use one public address
(b) Classless Inter-Domain Routing to translate any private address, saving
(CIDR) costs. Table 3.10 shows the process of
the PAT.
Private address
Table 3.10: Example of PAT process
If the internetwork is limited to one
organization, the IP addresses must be Private Port Public Port
unique within that organization. Only Address Address Address Number
networks that interface with public 192.68.1.3 50133 200.0.1.2 1
networks, such as the Internet, need 192.68.1.5 63887 200.0.1.2 2
public addresses. Using public addresses
on the outside and private addresses for The port address will be any random
inside networks is very effective. number in the allowed range the device
According to RFC1918, there are three creates when it wants to access the
ranges of IP addresses as private: internet.
In class A: The packet will contain the port number
10.0.0.0 through 10.255.255.255 assigned to the device that wants to
In class B: access the internet, and through this
172.16.0.0 through 172.31.255.255 port number, the router, when it gets the
In class C: response message, will translate it and
map this message to its private address
192.168.0.0 through 192.168.255.255
on the port number.
There are two ways to convert a private
Addressing without subnet
address to a public address:
If we have a class B with a Flat Network,
(a) Network Address Translation (NAT)
the number of hosts will be more than
This technique converts the private
216=65,536. So, the problem comes
address to a public address, and the
here as managing this network with this
NAT allows us to access the internet
number of hosts is too tricky, and this
and get services. The basic idea is that
network’s performance will decrease
the technique uses a pool of public
because of the heavy load. In other
addresses and assigns one public address
words, any single broadcast can slow
for each private address. Thus, this way
down the network.
is inefficient because there are costs and

164
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 164 23/01/2023 11:26:51


Therefore, the solution is subnetting. The solution to the problem is to
Subnetting means dividing or separating allow a network to be split into several

Computer Science
the single network into multiple independent parts for internal use but
networks that can reduce the loading still act like a single network to the
from one network. outside world. In the Internet literature,
The advantages of using subnetting are: these parts are called subnets.
(a) Reduces the traffic and increases Subnet masks
the performance A mask is a 32-bit binary number
(b) The smaller network can be easier expressed in dotted decimal notation. By
to manage default, a mask contains two fields, the
network field and the host field. These
Classful address subnetting correspond to the network number
As the number of distinct local networks and the locally administered part of the
grows, managing them becomes a serious network address. When an administrator
challenge. Every time a new network subnets, they adjust the way they view the
is installed, the system administrator IP address. The default masks for classful
must contact NIC to get a new network addressing are shown in Table 3.11.
number.

Table 3.11: Default masks for classful addressing


Address Bits used for subnet mask Dotted decimal
class notation
Class A 11111111 00000000 00000000 00000000 255.0.0.0
Class B 11111111 11111111 00000000 00000000 255.255.0.0
Class C 11111111 11111111 11111111 00000000 255.255.255.0
1 Octec 2 Octec 3 Octec 4 Octec

Routers and hosts still assume class subnet masks by default as shown in Table 3.12.
Table 3.12: Default subnet mask
Class Subnet mask prefix The subnet mask in dot notation
Class A /8 255.0.0.0
Class B /16 255.255.0.0
Class C /24 255.255.255.0

Three important things that should be taken into consideration when we are thinking
about subnetting are network address, broadcast address, and host addresses

165
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 165 23/01/2023 11:26:51


Moreover, to find the number of hosts Classless addressing is concerned with
per subnet, we can use the formula 2n - 2, the following three rules when allocating
Computer Science

where (n) is the number of unmasked a block.


bits (0’s). Rule 1: All CIDR block’s IP addresses
For example, in 11000000, the number must all be contiguous.
of zeros gives us 26 – 2 = 62 hosts. In Rule 2: The block size must be a power
this example, there are 62 hosts per of two to be attractive. Furthermore, the
subnet and we subtract because the first block’s size equals the number of IP
IP address is reserved for the network addresses in the block.
address, and the last one is for the Rule 3: The block’s first IP address must
network broadcast. be divisible by the block size.
When we want to find the number of This addressing scheme is used for
networks, we can use this formula 2y assigning IP addresses to the device on
Where, y represents the number of the network without using the standard
masked bits (1’s). For example, in IP address classes like Class A, Class
11000000, the number of ones gives us = 4 B, or Class C. In CIDR, an IP address
Reserved and restricted addresses is represented as A.B.C.D /n, where “/n”
is the IP prefix or network prefix. The IP
Certain addresses cannot be assigned prefix identifies the number of significant
to an individual device in any subnet bits used to identify the network.
because they have a special purpose.
The subnet address is the first address in For example, 172.168.20.70 /20 means
that the first 20 bits represent the network,
a range that identifies the subnet. In the
and the remaining 12 bits are used to
range, the broadcast address is the last;
identify hosts. It is basically the method
all hosts on the subnet receive traffic if
that ISPs (Internet Service Providers)
anything is sent to it.
use to allocate several addresses to a
For example, if a subnet address company, a home, or a customer. They
is 192.50.10.0 with a mask of provide addresses in specific block sizes.
255.255.255.0, then the subnet address When you receive a block of addresses
will be 172.31.9.0, and the broadcast from an ISP, the results you get will look
address 192.5010.255. something like this: 172.168.10.40/29.
This tells you what your subnet mask
Classless Inter-Domain Routing is. The slash notation (/) means how the
Classless Inter-Domain Routing (CIDR) number bits turned on (1s).
is also called classless addressing. CIDR The Class A default subnet mask is
is an addressing scheme that aids in the 255.0.0.0, which means that the first
more efficient allocation of IP addresses. byte of the subnet mask is all ones
This technique assigns a block of IP (1s), or 11111111. When referring to
addresses based on specified conditions a slash notation, you need to count all
when the user demands a specific amount the 1s bits to figure out your mask. The
of IP addresses. This block is known as a 255.0.0.0 is considered a /8 because it
“CIDR block”, containing the necessary has 8 bits which are 1s; that is, 8 bits that
number of IP addresses. are turned on.

166
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 166 23/01/2023 11:26:51


Subnetting Class C address We have 6 host bits off (11000000);
therefore, the number of hosts per each

Computer Science
In a Class C address, only 8 bits are
available for defining the hosts whose subnet will be:
subnet bits start at the left and go to the 26-2 = 62
right without skipping bits. This means Find the valid subnets: 256 – 192 = 64;
that the only Class C subnet masks are remember, we always start from 0 and
the following: count in our block size, so our subnets
are: 0, 64, 128, and 192.

Example 2: Your school has been


granted the site address 201.70.64.0
(class C). The school need six subnets.
Design the subnet for your school.
Solution:
The fast-way method for sub-netting a Our network address is 201.20.64.0,
Class C address and the default subnet mask for class
Start by using the second subnet mask C is 255.255.255.0, or you can write:
available with a Class C address, which 201.70.64.0/24.
borrows 2 bits for sub-netting: The subnet mask in binary:
192 = 11000000. 11111111.11111111.11111111.
The 1s represent the subnet bits, and the 00000000 = 255.255.255.0
0’s represent the host bits available in The school needs six subnets, 6 is not
each subnet. 192 provides 2 bits for sub- a power of 2; therefore, you will need
netting and 6 bits for defining the hosts to go for the next number that is in the
in each subnet. power of 2, which is 8(23); so, you will
need to borrow 3 bits for the network
from host part.
Example 1: Given the network Therefore, the new subnet mask will be:
address 192.168.10.0 and subnet mask 24+3=27
255.255.255.192,
find the number of subnets. The new subnet mask will be 11111111.
11111111.11111111.11100000
Solution:
= 255.255.255.224
Since 192 is 2 bits on (11000000), the
answer will be 22 = 4 Number of subnets = 8
Therefore, the number of subnets will be 4. The total number of host addresses per
Find the number of hosts per subnet. subnet will be 25 = 32
The number of usable host addresses per
subnet will be 25 = 32 - 2 = 30.

167
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 167 23/01/2023 11:26:52


Exercise 3.3 Transmission media
Computer Science

1. What is the purpose of the OSI Concept of transmission media


model in the modern internet? Does
it always serve that purpose? Give A computer network is a collection of
reasons to justify your answer. two or more computer systems linked
together. A network connection can
2. Suppose you have been given a
network address: 172.168.10.0 and be established using either cable or
subnet mask: 255.255.255. Follow wireless media. Transmission media are
all procedures to find out the number used to connect nodes in any network.
of subnets, number of host per A computer network consists of various
network and valid subnets. nodes such as; servers, networking
hardware, personal computers, and other
3. Contrast between classful and
classless IP addresses. specialized or general-purpose hosts.
4. Describe the importance of Meaning of transmission media
subnetting in network .
A transmission media is any
5. Explain the mechanism for data communication channel that uses
encapsulation and de-encapsulation electromagnetic signals to transmit data
in OSI Model. from the transmitter to the receiver. The
6. Describe NAT and PAT mechanism. primary role is to transmit data in the
7. Explain the OSI reference models form of bits across the network. Data
with a neat diagram. transmission functions similarly to a
physical path between the sender and
the recipient. For instance, in a copper
 ctivity 3.4: Assign IP address
A
cable network, the bits are in the form
to networked computers
of electrical signals, whereas in a fibre
An ISP has granted a certain university network, the bits are available in light
a block of addresses starting with pulses. The quality and characteristics
193.164.120.0/24. Since you are an of data transmission can be determined
administrator, you have been tasked
by the characteristics of the medium
to distribute the addresses to three
campuses as follows: and signal. The properties of different
transmission media are delay, bandwidth,
(a) Mwanza Campus has 50 staff’s maintenance, cost, and easy installation.
offices, each needs 120 addresses
(b) Dar es salaam campus has 89 staff’s Types of transmission media
offices, each needs 54 addresses Transmission media are categorised into
(c) Arusha Campus has 68 staff’s two types: Guided (wired) and unguided
offices, each needs 68 addresses (wireless) transmission media. Also,
(i)  Design the sub blocks and guided and unguided are known as
give the slash notation for bounded and unbounded, respectively.
each sub blocks. Figure 3.39 illustrates the types of
(ii) Find out how many addresses transmission media.
will be remaining after these
allocations.

168
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 168 23/01/2023 11:26:52


Factors to be considered while selecting a transmission medium

Computer Science
(a) Transmission rate
(b) Cost and ease of installation
(c) Resistance to environmental conditions
(d) Distances

Transmission modes

Bounded medium Unbounded medium

Fiber Radio Microwave


Coaxial Twisted Infrared
optics Transmission Transmission

Baseband Broadband Unshielded Shielded

Figure 3.39: Transmission media types


Guided transmission media Advantages of twisted pair cable
In guided media, signals are transmitted (a) Installation is easy
through a physical path. The features of
(b) Lightweight cable
guide media are high speed and security.
Guided media are also known as Wired (c) High speed
or Bounded transmission media. There (d) Can carry both analog and digital data
are three types of guided media: Twisted (e) Cheaper than other transmission media
pair cable, Coaxial cable, and Fiber
optics cable. (f) 
If some part of the twisted pair
cable is damaged, it does not affect
Twisted pair cable the entire network
A twisted pair cable is made up of two
insulated wires twisted with each other. Disadvantages of twisted pair cable
One wire carries the signal from the (a) Poor security
source to the destination, and the other
(b) Not durable (easy to break)
is for ground reference. Twisting is
done to avoid exterior electromagnetic (c) Attenuation is high
interference. It is the most widely used (d) They support only lower bandwidth
transmission media.

169
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 169 23/01/2023 11:26:52


Applications of twisted pair cables
Computer Science

(a) Applied in telephone lines.


(b) Applied Local Area Networks such as small offices and data centres use twisted
pair cables.
Types of twisted pair cable
There are two types of twisted-pair cables:
(a) Unshielded Twisted-Pair Cable (UTP)
(b) Shielded Twisted-Pair Cable (UTP)
Unshielded Twisted-pair cable: UTP cables consist of 2 or 4 pairs of twisted cables.
The Cable with 2 pairs uses an RJ-11 connector, and 4 pair cables use an RJ-45
connector. RJ means Registered Jack. Figure 3.40 shows the Unshielded Twisted
Pair cable (UTP).

Figure 3.40: Unshielded Twisted Pair cable


Unshielded twisted pair cable is widely used in telecommunications. Unshielded
Twisted pair (UTP) cable is categorized as follows:
(a) Category 1 UTP: CAT1 (b) Category 2 UTP: CAT2
(c) Category 3 UTP: CAT3 (d) Category 4 UTP: CAT4
(e) Category 5 UTP: CAT5 &5e (f) Category 6 UTP: CAT6&6a
The twisted pair cables and their characteristics are summarized in Table 3.13.

Table 3.13: Twisted Pair cable characteristics


Cable ATTRIBUTES
Category Frequency Max. Distance Cable Connector Applications
Transm. (M) type type
Speed
Old telephone
CAT1 - >=1Mbps UTP RJ-11
cable
Token ring
CAT2 - >=4Mbps UTP
network

170
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 170 23/01/2023 11:26:52


Token ring and

Computer Science
CAT3 16MHz >=10Mbps 100 UTP RJ-45 10-BASE-T
Ethernet
Token ring
CAT4 20MHz >=20Mbps 100 UTP RJ-45
network
Ethernet, token
CAT5 100MHz >=100Mbps 100 UTP RJ-45 ring, Fast
Ethernet
Ethernet, Fast
Ethernet,
CAT5e 125MHz >=1Gps 100 UTP. RJ-45
Gigabit
Ethernet
Gigabit
STP/ Ethernet
CAT6 250MHz >=10Gbps 100 RJ-45
UTP and 10Gbit
Ethernet
Gigabit
UTP/ Ethernet
CT6a 500MHz >=10Gbps 100 RJ-45
STP and 10Gbit
Ethernet
GigaGate45 Gigabit
(GG45) Ethernet
CAT7 600MHz >=10Gbps 100 STP
and RJ-45 and 10Gbit
Ethernet
GG45 / 10Gbit
CAT7a 1000MHz >=100Gbps 100 STP
RJ-45 Ethernet
GG45/ RJ- 25Gbit
45 Ethernet
CAT8 2000MHz 25/40Gbps 30 STP
and 40GBit
Ethernet

Note: TP= Twisted pair


Advantages of Unshielded Twisted-Pair Disadvantages of Unshielded Twisted-
Cable Pair Cable
(a) 
It can support high data speed, (a) Bandwidth is limited
which can be used in high-speed
LAN implementation. (b) Noise reduction is not possible

(b) Very easy to set up and install (c) Not ideal for long distance
communications due to the
(c) It is a flexible and cheap option for
attenuation.
the physical transmission media

171
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 171 23/01/2023 11:26:52


Shielded twisted-pair cable Disadvantages of Shielded Twisted-Pair
Cable
Computer Science

Shielded twisted pair cable contains the


metal foil surrounding the twisted copper (a) It is more costly than an unshielded
wires to avoid external interference. twisted pair cable (it is more
Shielding also eliminates crosstalk. expensive)
Shielded twisted pair cable has the same (b) It is difficult to manufacture and
attenuation as unshielded twisted pair. has heavyweight
It is faster than unshielded and coaxial
cable. It is more expensive than a coaxial Coaxial cable
and unshielded twisted pair. Figure 3.41 Coaxial cable has a centre conductor
shows Shielded Twisted pair. enclosed in an insulating cover enclosed
in a metal foil shield. The whole cable
is covered in a plastic cover. The metal
foil shield protects against the noise. As
the name suggests, it consists of two
parallel conductors. The inner conductor
is made up of copper and the outer
Figure 3.41: Shielded Twisted pair conductor is composed of copper mesh.
An insulating cover separates these two
Advantages of Shielded Twisted-Pair Cable conductors. The inner centre conductor
(a) Better performance than unshielded is used for data transfer, while the outer
twisted pair cable copper mesh conductor protects against
(b) Installation is easy the noise. Figure 3.42 illustrates the
coaxial cable.
(c) It supports higher bandwidth and
high speed because it’s shielded.

Figure 3.42: Coaxial cable

172
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 172 23/01/2023 11:26:52


Coaxial cable standards

Computer Science
Coaxial cables are categorized based on their Radio Government (RG) ratings.
Each RG number denotes a unique set of physical specifications, including the wire
gauge of the inner conductor, the thickness and the type of the inner insulator, the
construction of the shield, and the size and type of the outer casing. Each cable
defined by an RG rating is adapted for a specialized function as shown in Table 3.14.
Table 3.14: The most common coaxial standards.
50-Ohm RG-7 or RG-11 used with thick Ethernet
50-Ohm RG-58 used with thin Ethernet
75-Ohm RG-59 used with cable television
93-Ohm RG-62 used with ARCNET

Coaxial cable connectors


To connect coaxial cables to devices, we need coaxial connectors. The most common
type of connector used today is the Bayonet Neill-Councilman (BNC). Figure 3.43
shows three (3) popular types of these connectors: the BNC Connector, the BNC T
connector and the BNC terminator.
The BNC connector is used to connect the end of the cable to the device, such as
a TV set. The BNC T connector is used in Ethernet networks to branch out to a
connection to a computer or other device. The BNC terminator is used at the end of
the cable to prevent the reflection of the signal.

Figure 3.43: BNC Connectors


Types of coaxial cable
(a) Base Band Transmission cable is used to transmit a single signal at high speed.
It is used for digital transmission.
(b) Broadband Transmission cable is used for the transmission of multiple signals
simultaneously. It is used for analog transmission.
Advantages of Coaxial cable
(a) They are used in long-distance telephone lines
(b) Transmit digital signals at a very high rate

173
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 173 23/01/2023 11:26:52


(c) Data is transmitted without digital transmission in early Ethernet
distortion LANs.
Computer Science

(d) They can span to a longer distance The 10Base-2 or Thin Ethernet uses RG-
at higher speeds as they have 58 coaxial cable with BNC connectors
better shielding when compared to to transmit data at 10Mbps with a range
twisted pair cable of 185M.
(e) It has high-speed data transmission Fibre optic cable
(f) Better noise reduction compared to Fibre optics cable is made of glass and
twisted pair cable data transmission is based on the concept
(g) It supports high bandwidth. of reflection of light through glass. In
fibre optic cable, the optical fibres are
Disadvantages of coaxial cables coated in plastic. These optical fibres
(a) They are more expensive than a send the data by pulses of light. The
twisted pair cables plastic coating protects the cable from
(b) Single cable failure can result in temperature, electromagnetic inference,
the entire network failure and other wiring issues. Figure 3.44
(c) Difficult to install and costly when shows the fibre optic cable components.
compared to twisted pair
(d) If the shield is imperfect, it can lead Components of a fibre optic cable
to a grounded loop. Core: The core of the fibre optic cable
Applications of coaxial cable contains optical fibres and is responsible
Coaxial cable was widely used in analog for data transmission in the form of light
telephone networks, where a single pulses.
coaxial network could carry 10,000 Cladding: The core is enclosed in a layer
voice signals. Cable TV networks also of glass, which is called cladding. The
use coaxial cables. In the traditional main use of cladding is to reflect the light
cable TV network, the entire network so that the light can be transmitted from
uses coaxial cables. Cable TV uses RG- the source to the destination through
59 coaxial cable. reflection.
In traditional settings, coaxial cable it Jacket: The jacket is the outer layer of
is used in the Ethernet LAN. Due to its fibre optic cable made up of plastic, and
high bandwidth, consequence and high the whole purpose of the jacket is to
data rate, coaxial cable was chosen for protect the cable.

Figure 3.44: Fiber optics cable components

174
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 174 23/01/2023 11:26:52


Fibre optic cable propagation modes Disadvantages of fibre optic cable

Computer Science
Multimode: Multiple light sources move (a) 
It requires skilled people to
through different paths inside the coaxial administer, install and maintain.
cable. Multiple data transmission is done (b) Optical fibres are unidirectional for
simultaneously. two-way communication; so two
Single-mode: Light moves in a single fibres are required.
path close to the horizontal of the cable. (c) It is too expensive to deploy.
Advantages of fibre optic cable (d) Fibre optics cables are fragile, i.e.,
(a) The fibre optic cable supports high they are easier to break than wires.
bandwidth compared to the copper
cables. Thus, it transfers more data Applications of Fiber Optic Cable
compared to the copper cables. (a) Often found in backbone networks
(b) 
Since the data is transmitted in because its wide bandwidth is cost-
the form of light, the transmission effective.
speed is very high. (b) Some cable TV companies use a
combination of optical fibre and
(c) The fibre optic cable can be used coaxial cable, thus creating a hybrid
for more extensive distance data network.
transmission than copper wires
cable. (c) Optical fibres are now used in
telephone systems
(d) It is more reliable than copper cables
(d) Used in the Local Area Networks
as the core is protected against
temperature and electromagnetic
disturbances. Unguided transmission media
Unguided media does not use a
(e) It is durable
physical medium to transmit the data
(f) It is lightweight from source to destination. This type
of communication is often referred to
(g) It is resistant to corrosive materials
as wireless communication. Unguided
(h) 
Fibres do not leak light and are media uses air as a transmission medium
quite difficult to tap to transfer data. Thus, it is called wireless
transmission media. The unguided
(i) There is no cross-talk problem in
media uses an antenna for transmitting
optical fibres
and receiving the data in the form of
(j) Optical fibres cost lower than electromagnetic waves. Figure 3.45
cables with metallic conductors shows the part of the electromagnetic
spectrum, ranging from 3 kHz to 900
THz, used for wireless communication.

175
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 175 23/01/2023 11:26:52


Light wave
Computer Science

Radio wave and microwave Infrared


3 300 400 900
kHz GHz THz THz

Figure 3.45: Electromagnetic spectrum

Wireless signal propagation modes transmitting antenna and follow the


Wireless signals can travel from the planet’s curvature.
source to the destination using three (b) Sky Propagation: In this mode,
types of propagation modes: Ground higher-frequency radio waves radiate
propagation, sky propagation and line- upward into the ionosphere, reflecting
of-sight propagation. Figure 3.46 shows back to the earth. This type of
wireless propagation modes. transmission allows for greater distances
(a) Ground Propagation: In this mode, with lower output power.
radio waves travel through the lowest (c) Line-of-sight Propagation: in this
portion of the atmosphere, hugging the type, very high-frequency signals are
Earth. These low-frequency signals transmitted directly from antenna to
originate in all directions from the antenna in straight lines.

Figure 3.46: Wireless signal propagation modes

176
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 176 23/01/2023 11:26:52


Types of wireless transmission media (c) The microwave band is relatively
wide, almost 299 GHz. Therefore,

Computer Science
(a) Microwave transmission
wider sub-bands can be assigned,
(b) Radio transmission and a high data rate is possible.
(c) Infrared transmission (d) 
Use of certain portions of the
Microwave transmission band requires permission from
Electromagnetic waves having authorities.
frequencies between 1 and 300 GHz
are called microwaves. Microwaves Antenna for Microwaves
are unidirectional. When an antenna
transmits microwaves, they can be Microwaves need unidirectional
narrowly focused. This means that antennas that send out signals in one
the sending and receiving antennas direction. Two types of antennas are
need to be aligned. The unidirectional used for microwave communications:
property has an obvious advantage. A Parabolic Dish and Horn.
pair of antennas can be aligned without A parabolic antenna: It works as a
interfering with another pair of aligned funnel, catching a wide range of waves
antennas. and directing them to a common point. In
Characteristics of microwaves this way, more of the signal is recovered
propagation than would be possible with a single-
point receiver.
(a) 
Microwave propagation is line-
of-sight since the towers with A horn antenna: It looks like a huge scoop.
the mounted antennas need to be Outgoing transmissions are broadcast
in direct sight of each other, and up a stem and deflected outward in a
towers that are far apart needed to series of narrow parallel beams by the
be very tall. curved head. Received transmissions
are collected by the scooped shape of
(b) 
Very high-frequency microwaves the horn, like the parabolic dish, and are
cannot penetrate walls. This deflected down into the stem as shown
characteristic can be a disadvantage in Figures 3.47(a) and (b).
if receivers are inside the buildings.

Figure 3.47: (a) Parabolic antenna (b) Horn antenna

177
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 177 23/01/2023 11:26:52


Applications of Microwaves.
Computer Science

Due to their unidirectional properties, microwaves are very useful when unicast
(one-to-one) communication is needed between the sender and the receiver. They
are used in cellular phones, satellite networks, and wireless LANs. There are two
types of microwaves transmission;
(i) Terrestrial Microwave Transmission
(ii) Satellite Microwave Transmission
Terrestrial type microwave transmission
In this type of microwave transmission, both the sender and receiver antennas are in
direct sight of each other. Repeaters can be installed with each antenna to increase
the distance served by terrestrial microwaves. The signal received by an antenna
can be converted into transmittable form and relayed to the next antenna. It is an
example of telephone systems all over the world. Figure 3.48 illustrates terrestrial
microwave transmission.

Figure 3.48: Terrestrial microwave transmission.


Features of terrestrial type microwave transmission
Frequency range: The frequency range of terrestrial microwave ranges from 4 to
6GHz.
Bandwidth: It supports bandwidth from 1 to 10 Mbps.
Cost: If used in short-distance communication, the implementation cost is cheap as
we do not need relay towers. However, when terrestrial type microwave transmission
is used for long distances, the implementation cost goes high as we need relay towers
to extend the signals.
Attenuation: Attenuation means loss of signal. In terrestrial type microwave
transmission, attenuation mainly depends on the frequency and signal strength.

178
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 178 23/01/2023 11:26:52


Implementation: Implementation is receiver antenna. Figure 3.49 shows
difficult as the tower needs to be in the satellite microwave transmission.

Computer Science
line of sight and the signal requirement
makes it even more challenging to
implement.
Advantages of terrestrial type
microwave transmission:
(a) It is cheaper than cable transmission
(b) 
Possible to implement in areas
where cable transmission is difficult
to implement, such as hill areas.
Disadvantages of terrestrial type
microwave transmission: Figure 3.49: Satellite microwave
transmission
(a) Not secure, susceptible to
eavesdropping, Features of satellite microwave
transmission
(b) Weather conditions can affect the
transmission, (i) Bandwidth capacity depends on the
frequency used.
(c) Limited bandwidth,
(ii) 
Satellite microwave deployment
Satellite microwave transmission for orbiting satellites is difficult.
This is a microwave relay station that Advantages of satellite type transmission:
is placed in outer space. The satellites (a) 
The transmitting station can
are launched either by rockets or space receive back its transmission and
shuttles carrying them. check whether the satellite has
These are positioned at 36000Km transmitted information correctly.
above the equator with an orbit speed (b) The transmission can be done over
that exactly matches the earth’s rotation long distances
speed. As the satellite is positioned in a
geo-synchronous orbit, it is stationary (c) 
Unlike terrestrial transmission,
relative to the earth and always stays where the implementation cost goes
over the same point on the ground. This is higher based on the transmission
usually done to allow ground stations to distance, satellite communication is
aim the antenna at a fixed point in the sky. unaffected by the data transmission
distance.
This type of communication uses the
satellite antenna for communication. (d) Easy to install compared to
The sender antenna sends the signal terrestrial type
to the satellite antenna that revolves Disadvantages of satellite type
around the earth at a known height. transmission
The satellite antenna then amplifies
(a) Installation of the satellite is
the received signal and sends it to the
extremely tough.

179
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 179 23/01/2023 11:26:52


(b) 
Installation cost is high, and Advantages of radio transmission
development requires more time.
Computer Science

(a) Radio waves are mainly used for


Radio transmission Wide Area Networks (WAN), for
example, mobile networks.
Radio waves are very low-frequency
electromagnetic waves that are (b) Suitable for long distance
transmitted in all directions within the communications.
range. Radio transmission frequency (c) Signals can penetrate walls.
ranges from 3KHz to 1GHz. In radio (d) Higher data transmission rate
transmissions, the antennas need compared to other transmission
neither be aligned nor required to be mediums.
set in a particular manner to send and Disadvantages of radio transmission
receive signals. Since radio waves are
omnidirectional (in all directions), (a) Waves are omnidirectional, so they
face interference from other signals
isolating communication inside a
of the same frequency. Therefore,
building is impossible.
there can be disturbances.
Antenna for radio waves (b) Not possible to isolate the
Radio waves use omnidirectional communication inside the building
antennas that send signals in all Infrared transmission
directions, as illustrated in Figure 3.50.
Infrared waves are the highest frequency
waves, and their frequency ranges from
300GHz to 400 THz.
Characteristics of infrared transmission
(a) Suitable for short-distance
communication.
(b) Bandwidth is high, so the data
transmission rate is high compared
to other mediums.
(c) These waves cannot penetrate
walls; thus, they are ideal for
isolated communications.
Advantages of infrared transmission
Figure. 3.50. Applications of Radio Waves (a) Secure
The omnidirectional characteristics (b) High speed
of radio waves make them useful for (c) High-frequency signals
multicasting in which there is one (d) High data transfer rate
sender but many receivers. Amplitude (e) Low interference
Modulation (AM) and Frequency
Modulation (FM) radio, television, Disadvantages of infrared transmission:
maritime radio, cordless phones, and (a) Sun rays interfere with infrared
paging are examples of multicasting. rays, so they are not ideal for
outdoor communication.

180
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 180 23/01/2023 11:26:52


(b) Suitable for short-distance Explain to him how would
communication only. he make use of this antenna

Computer Science
(c) It cannot penetrate walls, so difficult to suit his purpose. Give the
to establish communication between consequences that Makame
two different walls. will encounter for using these
antennas in transmitting data
over a long distance.
Infrared Applications.
2. Describe Infrared and Radio waves
The infrared band, almost 400 THz, transmission mechanism
has an excellent potential for data
transmission. Such a wide bandwidth 3. Explain how to set terrestrial antenna
can be used to transmit digital data with for microwave transmission.
a very high data rate. 4. With the aid of a diagram, explain
The Infrared Data Association (IrDA), how the horn antenna works.
an association sponsoring infrared 5. How parabolic antenna differ from
waves, has established standards for horn antenna?
using these signals for communication 6. Describe the types of propagation
between devices such as keyboards, modes.
mice, PCs, and printers.
7. Describe the components of fibre
Infrared signals can be used for short- optic cable.
range communication in a closed area
using line-of-sight propagation.

Wireless network
Exercise 3.4
Concepts of wireless network
1. Makame wants to make business
Wireless means the media made up of
on data communication. He wants
to establish a communication electromagnetic waves (EM Waves) or
centre that will enable customers to infrared waves without a wire. Antennas
send data over both short and long or sensors will be present on all wireless
distance. How would you describe devices. Cellular phones, wireless
the classification of transmission sensors, TV remotes, satellite dish
media to him? receivers, and laptops with WLAN cards
are all examples of wireless devices. A
(a) What are factors would you wireless network uses radio frequency
advise him to consider in
waves rather than wires for data or voice
the selection of transmission
communication. Installation of wireless
medium?
networks, particularly WLANs, can
(b) 
Makame has already bought bring convenience and accessibility,
the terrestrial antenna that allowing businesses to gain maximum
he want to install for long mobility and flexibility around the office
distance communication. or at home.

181
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 181 23/01/2023 11:26:52


Wireless Local Area Network standards to the internet.
Computer Science

Wi-Fi is the industry-standard Wi-Fi operation mechanism


wireless local area network (WLAN) The IEEE 802.11 standard defines
technology for linking computers the protocols that allow existing Wi-
and other electronic devices to the Fi-enabled wireless devices such as
Internet. It is a wireless variant of wireless routers and access points to
a wired Ethernet network that is communicate. Wireless access points
frequently used in conjunction with it. support different IEEE standards.
Wi-Fi is a type of wireless networking Each standard results from a series of
that uses radio frequencies to send and amendments that have been ratified over
receive data. It allows users to connect time. The standards operate at different
to the Internet at high speeds without frequencies, have different bandwidths,
the necessity of cables. Wi-Fi stands and support varied channel counts.
for “wireless fidelity” and is a phrase
that is often used to refer to wireless
Types and characteristics of various
networking technologies. A wireless
IEEE 802.11 wireless standards
router is used to connect to the internet.
When you connect to Wi-Fi, you’re Table 3.15 illustrates the type and
connecting to a wireless router that characteristics of various IEEE 802.11
connects your Wi-Fi-enabled devices wireless standards.

Table 3. 15: The 802.11 wireless standards


IEEE Frequency/ Transmission Access
Speed Topology
Standard Medium Range method
Adhoc/
802.11 2.4GHz RF 1-2Mbps 20 feet indoors CSMA/CA
infrastructure
25-75 feet indoors, the
Adhoc/
802.11a 5GHz >=54Mbps range can be affected CSMA/CA
infrastructure
by building materials
Up to 150 feet
Adhoc/ indoors, the range
802.11b 2.4GHz >=11Mbps CSMA/CA
infrastructure can be affected by
building materials
Up to 150 feet
Adhoc/ indoors, the range
802.11g 2.4GHz >=54Mbps CSMA/CA
infrastructure can be affected by
building materials
175+feet indoors, the
2.4GHz/ Adhoc/
802.11n >=600Mbps range can be affected CSMA/CA
5GHz infrastructure
by building materials

182
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 182 23/01/2023 11:26:52


Types of wireless network

Computer Science
Table 3.16 provides an overview of the different types of wireless networks.
Table 3.16: Wireless network types

S/N Network types Geographical Usage Standards


range
1. Wireless Personal Within reach of Alternative or Bluetooth, Zigbee,
Area Network individual replacement NFC
(WPAN) to cables for
peripherals
2. Wireless Local Within the Wireless IEEE82.11
Area Network building or extension of (Wi-Fi)
(WLAN) campus wired network
3. Wireless ad hoc 100M but can Variety of
network (wireless be extended applications Not restricted
mesh network by multi-hop where central to any one
or mobile ad communication notes cannot technology or
hoc network, or of nodes rely upon, i.e., protocol
MANET) field operation,
surveillance
networks, home
and street light
networks
4. Wireless Citywide Allows several IEEE 802.116
Metropolitan Area WLANs to (WiMAX)
Network (WMAN) interconnect
to cover a
metropolitan
area and provide
a connection to a
WAN
5. Wireless Wide Area Regional, Delivered to GSM/UMTS,
Network (Wireless National or smartphones and CDMA one/
MAN or WWAN) Global other handheld CDMA2000 and
devices WiMAX
6. Cellular network Regional, Voice and Cellular (UMTS,
National or other cellular LTE,0G-5G etc.)
Global networks

183
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 183 23/01/2023 11:26:52


Basic components of wireless network Wireless bridge: Operates to either
improve Wi-Fi network coverage or
Computer Science

End device: This can include, but is not


limited to, devices such as, PCs, Printers, extend it. The primary purpose of the
Servers, etc. device is to receive the existing Wi-Fi
signal, relay requests, and respond back
Wireless network card/wireless adapter: and forth between the devices and the
Wireless adapter is categorized into two main Wi-Fi router/AP. The repeater
forms: USB or PCI card. It can connect can be used to double the WLAN range.
the specific computing device to WLAN Wireless bridges are available in the
and receive and transmit radio waves. high-speed, long-range outdoor link to
Modern devices have an inbuilt wireless use between buildings.
adapter.
Wireless LAN controller: Wireless LAN
Wireless Access Point (WAP or AP): network controllers Figure 3.51 is used
Is the wireless network device that on the network when many access points
provides a wireless connection to the (AP) are required. As a centralized
remaining wired LAN. Some of the APs device in the network, the wireless LAN
devices look very similar to the wireless controller is usually located at the data
router. AP receives and transmits data to centre, to which all the wireless APs on
all wireless devices in a particular area. the network are directly or indirectly
It can manage multiple connections connected. It provides centralized Wi-
between different devices working at Fi management functions that manage
once. all campus access points. The wireless
Wireless Routers: Most modern wireless controller offers advanced features
router integrates WAP, Ethernet switch, and management capabilities such
and router into a single device. Wireless as centralized authentication, access
router permits wired and wireless to control, the ability to restrict bandwidth
connect to the internet via a cable (ADSL by user or ground, quality of service
or DSL modem) (QoS), and traffic prioritization.

Figure 3.51: Wireless Network controller

184
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 184 23/01/2023 11:26:52


Wireless LAN controller operation controller can easily detect interference
between nearby APs and automatically

Computer Science
The wireless access controller takes
the bandwidth produced from a router re-configure their power and channel
and stretches it to fit the network’s settings. If an AP goes down, it can
needs. Similar to an amplifier in a instruct nearby APs to increase their
stereo system, the wireless controller power levels to fill the coverage gap.
allows devices from farther distances to
Wireless repeater
connect. Besides, it enables the network
A Wi-Fi repeater or extender is used to
administrators to check all the network
extend the coverage area of your Wi-
data and detect rogue access points and
Fi network. It works by receiving your
recent traps generated by the access
existing Wi-Fi signal, amplifying it, and
points.
transmitting the boosted signal. With
Benefits of a wireless LAN controller a Wi-Fi repeater, you can effectively
Secured wired and wireless network: double the coverage area of your Wi-
Controlling wireless users’ access Fi network - reaching far corners of
privileges using a variety of deterministic your home or office, different floors,
criteria (including authentication method, or even extending coverage to your
device type and the application yard. Figure 3.52 shows the wireless
requested) to provide differentiated repeater.
access for maintaining security.
Centralized and flexible network
management: Centralised wireless
controller provides flexibility for
deployment, which will reduce the
overall budget, planning tools, and time
spent to organize a wireless network in
the business. They enable the centralised
monitoring of the entire wireless
infrastructure which decreases the total
cost of ownership and unification of
wired and wireless access, a future-
proofing investment for upgrades.
Simplified network maintenance: Figure 3.52: Wireless repeater
Wireless LAN controllers eliminate
site surveys by including intelligent Wired and wireless computer networks
RF planning software. The self- comparison
configuring and self-healing wireless
network is better for management There are differences between wired and
and troubleshooting. It can accurately wireless computer networks. Table 3.17
locate and identify each user. Due describes the differences between wired
to the RF nature, the wireless access and wireless networks.

185
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 185 23/01/2023 11:26:52


Table 3.17: Differences between wired and wireless network
Computer Science

S.No Wired network Wireless network


1. A wired network employs Without the wire, “ Wireless “ means
wires to link devices to the media made up of electromagnetic waves
Internet or another network, (EM Waves) or infrared waves. Antennas
such as laptops or desktop or sensors will be present on all wireless
PCs devices
2. Faster transmission speed Slow transmission speed
3. Propagation delay is low Propagation delay is high
4. More secure & hence reliable Less secure and therefore less reliable
5. Less expensive More expensive
6. High installation and Low installation and maintenance cost
maintenance cost

Factors to consider in choosing a Multiplexing


wired or wireless network
Concept of multiplexing
In order to come up with the right
Multiplexing is the process of combining
solution, whether to go for a wired or
multiple signals into one signal over a
wireless network, you need to carry
shared medium. If the analog signals
on wireless network requirement needs
are multiplexed, then it is called analog
analysis by focusing on the followings:
multiplexing. Similarly, if the digital
(a) Coverage requirements: Does your signals are multiplexed, then it is called
network cover a small or large digital multiplexing.
area?
Multiplexing was first developed in
(b) Network mobility: Assess how the telephony. A number of signals were
user will be moving around. Will combined to send through a single cable.
users need a reliable network in all The process of multiplexing divides a
areas? communication channel into several
(c) Security: You need to evaluate the logical channels, allotting each one for a
level of protection your data need different message signal or a data stream
against threats to be transferred. The device that does
multiplexing can be called a Multiplexer
(d) Compatibility issues: Record your
or MUX.
existing applications and systems
to check whether the wireless The reverse process, i.e., extracting
network will be the right choice or the number of channels from one
not channel, which is done at the receiver,
is called de-multiplexing. The device
(e) Number and type of users: Identify
that does de-multiplexing can be called
the number of users, number, and
as de-multiplexer or DEMUX. In data
type of devices which will be
transmission, both the multiplexer and de-
connected to the wireless network.

186
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 186 23/01/2023 11:26:53


multiplexer are combinational circuits. standard logic gates. When it is used for
Figure 3.53: illustrate the concept of digital applications, the multiplexer is

Computer Science
MUX and DEMUX. Their primary use called a digital multiplexer.
is in the field of communications. Multiplexer types
Multiplexers are classified into four types:
(i) 2-1 multiplexer (1select line)
(ii) 4-1 multiplexer (2 select lines)
(iii) 8-1 multiplexer (3 select lines)
Figure 3.53: Multiplexing and
(iv) 16-1 multiplexer (4 select lines)
De-multiplexing
The multiplexer is a combinational
Multiplexer and De-multiplexer
circuit with 2nd input signal lines and
Multiplexer: The multiplexer is a device a single output line. For example, 4 -1
with multiple inputs and single line multiplexer has 4 input data lines and
output. The select lines define what input 1 output line. The 8 -1 multiplexer has
is connected to the output and increase 8 input data lines and 1 output line, as
the data sent over a network at a given in Figure 3.55. The multiplexer is used
time. Also, it is called a data selector. for the multiplexing technique as it
Figure 3.54 shows a multiplexer. combines multiple signals and produces
a single output signal.

Figure 3.55: The 8-to-1 Multiplexer


with 8 input line, 1 output
line and 3 selector lines

Importance of using multiplexing


Figure 3.54: Multiplexer Multiplexing reduces the number
of physical connections or wireless
Multiplexers are able to accept analog channels to transmit multiple signals
and digital applications, whereby by combining them and sending them
in analog applications, multiplexers over a single transmission medium. It
contains relays and transistor switches. reduces the cost of transmission services.
In contrast, in digital applications, Bandwidth is utilized effectively when
the multiplexers are made up of using a multiplexer.

187
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 187 23/01/2023 11:26:53


Applications of multiplexers
Computer Science

Multiplexers are used in various


applications wherein multiple data must
be transmitted using a single line.
Communication system: A
communication system has both
a communication network and a
transmission system. By using a
multiplexer, the efficiency of the
communication system can be increased
by allowing the transmission of data,
such as audio and video data, from
Figure 3.56: De-multiplexer
different channels through single lines
or cables. Types of de-multiplexer
Computer memory: Multiplexers are De-multiplexers are classified into four
used in computer memory to maintain a types
huge amount of memory in the computers (i) 1-2 de-multiplexer (1 select line)
and reduce the number of copper lines
required to connect the memory to other (ii) 1-4 de-multiplexer (2 select lines)
computer parts. (iii) 1-8 de-multiplexer (3 select lines)
Telephone network: In telephone (iv) 1-16 de-multiplexer (4 select lines)
networks, multiple audio signals are
integrated on a single line of transmission De-multiplexer works on the principles
with the help of a multiplexer. of one-to-many. For example, a 1-4 De-
Transmission from the computer: The multiplexer is used to generate 4 output
system of a satellite multiplexer is used signals from a single signal
to transmit the data signals from the Applications of de-multiplexer
computer system of a spacecraft or a
De-multiplexers are used to connect a
satellite to the ground system by using a
single source to multiple destinations.
GSM satellite.
These applications include the following:
De-multiplexer (DEMUX): De- Communication system: Multiplexer
multiplexer does exactly the opposite of and de-multiplexer are both used in
multiplexing. It receives a single input communication systems to carry out
signal and generates 2nd output signal. the data transmission process. A de-
The multiplexer is used at the source multiplexer receives the output signals
to combine the multiple input signals, from the multiplexer; and, at the receiver
while De-multiplexer is used at the end, it converts them back to the original
receiving side to generate multiple form.
signals from the received signal. Arithmetic logic unit: The output of the
Figure 3.56 shows De –multiplexer. arithmetic logic unit is fed as an input to

188
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 188 23/01/2023 11:26:53


the de-multiplexer, and the output of the regular intervals. A counter is attached
de-multiplexer is connected to multiple

Computer Science
to the de-multiplexer at the control input
registers. The output of the ALU can be to sense the data signal de-multiplexer’s
stored in multiple registers. output. When all data signals are
Serial to parallel converter: The serial stored, the output of the de-multiplexer
to parallel converter is used to reform can be read out in parallel. Table 3.18
parallel data. This method gives serial summarise the difference between the
data as input to the de-multiplexer at multiplexer and the de-multiplexer.

Table 3. 18: Difference between multiplexer and de-multiplexer


Multiplexer De-multiplexer
In multiplexers, the set of selection In de-multiplexer, the output line
lines is used to control the specific selection can be controlled through
input n-selection lines bit values
It uses several data inputs to generate a It uses single input that can be directed
single output through several outputs
The multiplexer has several inputs and De-multiplexer has a single input and
the single output several outputs
It is used in Time Division It is used in TDM at the end of the
Multiplexing (TDM) at the end of the receiver
transmitter
It is a digital switch It is a digital circuit
Parallel to serial conversion is used Serial-to-parallel conversion is used
It is a data selector It is a data distributor
It is called MUX It is called DEMUX
In multiplexers, control signals are used De-multiplexer uses the control signal
to choose the specific input that has to to permit us to include several outputs
be sent to the output
Different types of multiplexers are 4-1 Different types of de-multiplexers
MUX, 8-1 MUX, 16-1 MUX, and 32-1 ar:1-4 DEMUX,1-8 DEMUX, 1-16
MUX DEMUX, and 1-32 DEMUX
It operates on the principle of many to It operates on the principle of
one one-to-many
It is used to improve the efficiency De-multiplexer gets the output signals
of the communication system using from the Mux and changes them to the
transmission data like transmission of unique form at the end of the receiver
audio as well as video
It doesn’t use any extra gates while Additional gates are necessary while
designing it designing DEMUX

189
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 189 23/01/2023 11:26:53


Types of multiplexing techniques
Computer Science

There are mainly two types of multiplexing techniques, namely analog and digital.
They are further divided into Frequency Division Multiplexing (FDM), Wavelength
Division Multiplexing (WDM), and Time Division Multiplexing (TDM) as it is
illustrated in Figure 3.57.
Multiplex Techniques

Analog Digital

Frequency Wavalength Time


Division Division Division
Multiplexing Multiplex Multiplex
(FDM) (WDM) (TDM)

Asynchronous Syncronous TDM

Figure 3.57: Multiplexing techniques types

Analog multiplexing
Advantages of frequency division
The signals used in analog multiplexing
multiplexing
techniques are analog in nature. The
analog signals are multiplexed according (a) It doesn’t require synchronization
to their frequency or wavelength. between the sender and receiver.
Frequency division multiplexing: (b) It is simple, easy to implement and
The most used technique is FDM in a less expensive technique.
analog multiplexing. This technique (c) FDM is a reliable system compared
uses various frequencies to combine to other multiplexing systems.
data streams, for sending them on a (d) This technique is mainly used for
communication medium as a single analog signals.
signal.
(e) 
This technique allows a large
For example, a traditional television number of signals to be transmitted
transmitter, which sends several simultaneously over a single
channels through a single cable, uses transmission medium.
FDM.

190
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 190 23/01/2023 11:26:53


Disadvantages of frequency division For example, Optical fibre communica-
multiplexing tions use the WDM technique to merge

Computer Science
(a) FDM suffers from interference different wavelengths into a single light
caused by electromagnetic signals, for communication.
generally referred as cross talk. Digital multiplexing
(b) FDM provides less throughput. The term digital represents discrete bits
Throughput is the rate of of information. Hence, the available
successful message delivery over a data is in the form of frames or packets,
communication channel. which are discrete.
(c) FDM doesn’t utilize the full Time-division multiplexing: In TDM,
bandwidth of the transmission the time frame is divided into slots. This
medium. technique is used to transmit a signal
(d) FDM requires a significantly large over a single communication channel,
number of modulators and filters to by allotting one slot for each message.
transmit multiple signals. TDM can be classified into Synchronous
(e) Unlike TDM, FDM needs a carrier TDM and Asynchronous TDM.
signal to transmit multiple signals. Synchronous TDM: In synchronous
Wavelength division multiplexing: WDM TDM, the input is connected to a frame.
is an analog technique in which many If there are ‘n’ number of connections,
data streams of different wavelengths then the frame is divided into ‘n’ time
are transmitted in the light spectrum. If slots. One slot is allocated for each input
the wavelength increases, the frequency line.
of the signal decreases. A prism, which In this technique, the sampling rate is
can turn different wavelengths into a common for all signals, and hence the
single line can be used at the output of same clock input is given. The MUX
MUX and input of DEMUX. allocates the same slot to each device at
Advantages of wavelength division all times.
multiplexing Asynchronous TDM: In asynchronous
(a) Easy to implement TDM, the sampling rate is different
(b) Full duplex transmission is possible for each signal, and a common clock is
in WDM not required. If the allotted device for a
(c) Provides better security of data time slot transmits nothing and sits idle,
(d) WDM provides higher bandwidth then that slot can be allotted to another
device, unlike synchronous
Disadvantages of wavelength division This type of TDM is used in asynchronous
multiplexing transfer mode networks.
(a) Transmitted signals cannot be very The following are common examples of
close to each other
time-division multiplexing applications:
(b) WDM is more expensive compared
to FDM (a) It is used in a type of telephone line
that uses Integrated Services Digital
(c) It is difficult to fine-tune wavelength Network (ISDN) technology.
in the WDM technique

191
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 191 23/01/2023 11:26:53


(b) It is deployed in Public Switched Crosstalk is not a huge
(h) 
Telephone Network (PSTN). issue: Crosstalk can be triggered by
Computer Science

(c) It’s a significant component of a pulse overlapping; that being said,


telephone system. it can be minimized by employing
(d) In a digital audio mixing system, guard time. As a consequence, there
TDM is implemented. is not anything to be particularly
concerned about.
(e) It is employed in a half-duplex
communication system. Ensures optimal performance:
(i) 
Dynamic coordination is a core
(f) TDM is a technique utilized
feature of TDM. Since TDM uses
in Global Systems for Mobile
Communication. dynamic coordination, it is more
efficient and reliable than FDM.
Advantages of time-division multiplexing A diverse range of application
(j) 
areas: TDM allows the
Easy adaptation: TDM can
(a) 
surely adapt to the transport of administrator to do operations such
information in the same fashion as as faxing, voiceband data, and
voice communication. SMS, as well as activities such as
mixed media and video calls.
Fairly high transmission speed: It
(b) 
can transport messages at speeds Cost-benefit analysis: TDM brings
(k) 
spanning from 64 kbps to 120 considerable investment funds in
Mbps. base station equipment, space, and
Absence of external impedance: The
(c)  support, which is becoming extremely
synchronous transmission has no important as cell sizes shrink.
impedance.
Disadvantages of time-division
Digitization potential: TDM is a
(d) 
multiplexing
sophisticated way to transform a
simple framework into a digitized Memory space distribution problem:
(a) 
one. Every client creates a designated
Bandwidth efficiency: The signal
(e)  memory space, so clients who
is conveyed using the maximum move from one unit to the next do
channel bandwidth. not automatically receive a planned
opening. A cell can be disconnected
No particular need for the carrier:
(f) 
TDM systems do not necessitate if, all of the time, allotments in the
a carrier wave or carrier signal, succeeding cell are now engaged.
although FDM systems must. Similarly to that way, if all of the
Carrier signal partitions the main time allotments in the cell where a
signal as per frequency range. customer ultimately ended up are
now occupied, the customer will
No intermodulation disruption:
(g) 
TDM does not tend to suffer from not receive a phone line.
Intermodulation distortions. (b) 
Need for major
modifications: Increased data rates
necessitated adjustment.

192
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 192 23/01/2023 11:26:53


(c) The effort required for synchroni- Chapter summary
zation: The synchronization burden

Computer Science
1. Data refers to the raw facts that
is substantial. To maintain adequate are collected, such as text, image
signal transmission and reception, and symbols, while information
the transmitter and receiver com- refers to the processed data that
ponents must be correctly and con- are meaningful to the person who
sistently synchronised. receives it, which enables us to take
a decision. Data communications
Exercise 3.5 are the exchange of data between
two devices via a transmission
1. Describe the types of multiplexing medium such as a wire cable and
techniques. wireless (bound and unbound
medium). A data communications
2. Give an example of multiplexing
system must transmit data to
in a real, non-computer-related
the right device accurately and
system. Is the multiplexing
promptly. The five components that
centralised or distributed? Why?
make up a data communications
Give reasons. system are: message, sender,
3. Give the applications of a receiver, medium, and protocol.
multiplexer. Text, numbers, images, audio,
4. What kind of network traffic is and video are different forms of
suited to synchronous time-division information.
multiplexing? 2. Data communication systems can
perform different tasks such as
signal generation, interface, data
synchronization, error detection
and correction, flow control,
 ctivity 3.5: Identification of
A addressing and routing.
multiplexer and demultiplexer
devices. 3. The process for sending data
between two devices connected
Resources: internet or library resources, over a network is referred to as
Procedures: transmission or communication
(a) Visit internet or library modes. These modes are classified
based on the number of wire
(b) 
Search for multiplexers and connections and number of bits sent
demultiplex devices simultaneously, such as parallel
(c) From your search, identify any four and serial transmission; based on
synchronization and time control,
devices on each
such as asynchronous, synchronous
(d) Describe the roles each identified and isochronous; based on the
devices and its communication direction of signal flow or direction
mechanism of exchange of the information
such as simplex, half-duplex and
full-duplex.

193
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 193 23/01/2023 11:26:53


4. A computer network is a collection from the sent data as it travels from
of communication devices linked the physical layer to the application
Computer Science

together using transmission layer in the OSI model. TCP is a


media for data communication connection-oriented protocol while
and resource sharing. Computer UDP is a connectionless protocol.
network elements include network An IP address is the logical numeric
devices, software, end-user devices address that is assigned to every
and transmission media. Computer node within a network.
networks are basically classified 7. 
IP is of two types: IPv4, which
based on geographical coverage, can support a maximum of 4.3
which are: PAN, LAN, MAN billion addresses, and IPv6, which
and WAN; network type is based supports up to 340 undecillion. IP
on ownership/access restriction, addresses are classified as class A,
based on topology, and based on B, C, D and E.
architecture. Topology refers to the
physical or logical arrangement of 8. 
Subnetting means dividing or
a network. Network devices may separating a single network into
be arranged in a mesh, star, bus, or multiple networks that can reduce
ring topology. the loading from one network. The
subnet mask contains two fields,
5. 
Computer network architecture the network field and the host field.
refers to the design and
implementation of a computer 9. 
Classless Inter Domain Routing
network. It is the physical (CIDR) is a method for assigning
and logical organization and IP addresses without using the
arrangement of various network standard IP address classes like
devices (i.e clients such as PCs, Class A, Class B or Class C.
desktops, laptops and mobiles) 10. There are two transmission media
to meet the needs of the end user/ types: guided/wired and unguided/
customer. There are two main types wireless. Wired transmission media
of network architecture: peer-to- are subcategorized as coaxial
peer and client/server architectures. cable, twisted pair cable and fiber
Client/server architecture can either optics cable, whereas unguided
be centralized or distributed. are categorized as infrared
6. 
There are two types of network transmission, radio transmission
models: the OSI model and the TCP/ and microwave transmission.
IP model. OSI model consists of The wireless network is the type
seven layers while TCP/IP consists of network whereby the type of
of four. Each layer performs its communication medium is air.
specific tasks. Data encapsulation 11. 
Wi-Fi (Wireless Fidelity) is the
is adding additional information industry-standard wireless local
when data travels in OSI or TCP/IP area network (WLAN) technology
model. Data de-encapsulation is the for linking computers and other
process of detaching information electronic devices to one another

194
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 194 23/01/2023 11:26:53


and the Internet. Wireless network 13. Multiplexing is the process of
based on geographical area is

Computer Science
combining multiple signals into
classified as: Wireless Personal one signal over a shared medium.
Area Network (WPA); wireless There are mainly two types of
local area network (WLAN); multiplexing techniques, namely
wireless ad hoc network (MANET); analog and digital. They are further
Wireless MAN, Wireless WAN, divided into Frequency Division
and cellular network. The main
Multiplexing (FDM), Wavelength
elements of wireless networks
Division Multiplexing (WDM),
are wireless access point (WAP),
wireless repeater, wireless router, and Time Division Multiplexing
wireless network card, wireless (TDM). Multiplexers are used in
controller etc. communication systems, computer
memory and telephone network and
12. Some factors must be considered
when choosing a wired or wireless transmission from the computer
network: network coverage using satellite multiplexers. De-
requirements, network mobility, multiplexer is used on the receiving
security, compatibility issues and side to generate multiple signals
the number and types of users. from the received signal.

PROJECTS
Project 1: Ethernet cable construction and testing
Things to note
The making of the cable will depend on the purpose of the intended cable, whether
for the same device connection, different device connection or configuration.
Straight-through cable: Is used to connect a different device such as a computer to
switch, switch to router and switch to hub.
Crossover cable: Is used to connect the same device, such as computer to computer,
switch to switch, router to router etc.
Rollover: Rollover cables, sometimes called Yost cables, are most commonly used
to connect to a device’s console port to make programming changes to the device.
The two standards for wiring Ethernet cables are T568A and T568B. The
T568B is the most common and is the one you will be using for your Ethernet
cable. Table 3.62 shows the proper orientation of the coloured wires to the
pins.
Requirements
(i) Unshielded twisted pair (UTP) cable (length of the cable will depend on your
application area)
(ii) Modular connector (8P8C plug, also known as RJ45)

195
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 195 23/01/2023 11:26:53


(iii) Crimping tool
Computer Science

(iv) Cable tester


Procedure for making straight-through, crossover and rollover cable
Procedures for making straight-through cable
Step 1: Strip the cable jacket about 1.5 inches down from the end
Step 2: Spread the four pairs of twisted wire apart
Step 3: Untwist the wire pairs and neatly align them in the T568B orientation
(Figure 3.58). Be sure not to untwist them any farther down the cable than where
the jacket begins.

Figure 3.58: Straight through wiring guide

Step 4: Cut the wires as straight as possible, about 0.5 inches above the end of the jacket.
Step 5: Carefully insert the wires into the modular connector, ensuring that each
wire passes through the appropriate guides inside the connector.
Step 6: Push the connector inside the crimping tool and squeeze the crimper down.
Step 7: Repeat steps 1-6 for the other end of the cable.
Step 8: To make sure you’ve successfully terminated each end of the cable, use a
cable tester to test each pin.

Procedures for making a crossover cable


Follow the same procedure as for the straight-through cable above, except step 3 pin
arrangement will be as on the Figure 3.59.

196
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 196 23/01/2023 11:26:53


Computer Science
Figure 3.59: Crossover wiring pins arrangement

Procedures for making a crossover cable


Following the same procedure as for the straight-through cable above, except for
step 3, the pin arrangement will be as shown in Figure 3.60.

Figure 3.60: Crossover cable

Project 2: Configure switch and router B. Router


for internet connectivity Basic router configurations
A. Switch (i) Device name
Basic switch configurations: (ii) Secure access control
(i) Device name, (iii) Port security
(ii) VLANs Routing configurations:
(iii) Secure access control, (i) Static and dynamic
(iv) Port configuration (ii) Test for connectivity

197
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 197 23/01/2023 11:26:53


Revision exercise 11. 
Based on question 10 for those
which are peer-to-peer, explain
Computer Science

1. Describe the components of data


communication systems. how a new client joins the network
and locates the data it is interested in.
2. Write short notes on the importance 12. Give three ways in which synchro-
of data communication in nous Time-Division Multiplexing
education. is more complex than Synchronous
3. Contrast between: Time-Division Multiplexing. Why
is asynchronous TDM used on the
(a) Digital and analog data Internet?
(b) Parallel and serial transmission 13. Contrast between TCP/IP and OSI
4. 
Describe the mechanism for model.
character by character data 14. 
Describe the encapsulation and
transmission method. de-encapsulation process in OSI
Model.
5. Give the reason why asynchronous
transmission takes more time than 15. 
Contrast between classful and
data transmission. CIDR addressing scheme.
16. 
What is the network address
6. 
Account for the transmission if one of the host addresses is
method for transmitting data from 220.220.20.89/24?
the keyboard to the computer.
17. 
You have been allocated a class
7. Describe the transmission method B network address of 135.1.0.0
of the zoom online meeting and need to create 4 subnets each
with around 200 hosts, what is the
8. The contrast between parabolic and easiest mask to use to satisfy the
horn antenna mechanism criteria?
9. 
Describe the relative merits of 18. Describe the main configuration
client/server and peer-to-peer parameters which DHCP provides
application models. to nodes and the online purpose of
each.
10. Classify each of the technology or
systems as client/server, peer-to- 19. Compare and contrast DHCP with
peer or hybrid, and explain why IPv6 autoconfiguration in terms of;
the designers may have decided to (a) how IP addresses are assigned
implement the system in that way: to nodes;
(a) eBay (b) the configuration parameters
provided to nodes;
(b) easybuy
(c) the interactions between
(c) Skype nodes and the configuration
(d) BitTorrent server; and
(e) SSH (Secure Shell) (d) the design motivation.
(f) DNS

198
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 198 23/01/2023 11:26:53


20. Under what circumstances would 22. 
Domain Name System (DNS)
is an application layer protocol

Computer Science
you choose TCP, and when would
you use UDP? In responding used to look up the corresponding
to this question, you might be IP addresses of host names such
as www.cl.cam.ac.uk which
interested in considering example
originally. used UDP only. Suggest
cases such as: why DNS might have been
(a) 
Fast transactions (where designed based on UDP rather than
TCP.
you want to send a short
notification to another system 23. 
Recently, the internet has started
to deploy DNSSEC (DNS Security
with minimal latency)
extensions), which involves
(b) Bulk data transfers transmitting cryptographic
signatures and DNS data. These
(c) 
Timeliness (suppose data is signatures are sometimes multiple
being output from a sensor at kilobytes in size. Why might this
one sample per second, and motivate the use of TCP rather than
the receiver needs to have UDP for DNS?
the most recent value of the 24. 
Discuss bounded and unbounded
sensor’s reading rather than transmission media.
all values, i.e. the receiver 25. What are the factors to be considered
should get the current value in choosing transmission media?
rather than an outdated value) 26. 
For each of the following four
networks, discuss the consequences
21. 
UDP provides very few features if the connection cable fails.
above those provided by IP, and is (a) 
Five devices arranged in a
used by applications which do not mesh topology
require TCP’s reliability and flow (b) Five devices arranged in a star
control (e.g. live video streaming). topology
Why can such an application not (c) Five devices arranged in a bus
just opt to use IP directly without a topology
transport layer protocol? (d) 
Five devices arranged in a
ring topology

199
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 199 23/01/2023 11:26:53


Computer Science

Chapter
Four Visual programming

Introduction

Computer programming, which is the process of preparing computer programs, is


at the heart of today’s digital services. This is because almost every modern-day
technology is driven by software. There are many tools and techniques for writing
computer programs. In this chapter you will learn how to write computer programs
visually (visual programming) to solve various problems using the Visual Basic
.NET programming language. The competence generated will help you to write
window-based programs.

Think about the following: programming enables the programmer


to write a program using both text and
1. Accessing the command line (text) graphical components. For example,
based program and GUI based unlike in text-based programming where
program. a programmer has to write code to create
graphical components such windows
2 Developing a program using text
and buttons, in visual programming
based and Visual i.e. drag and drop
these components are available for the
techniques. Which one do you
programmer to use, usually by dragging
find ease to use or user friendly
and dropping. All the programmer has to
when you are required to creating
do is to customise them and add business
GUI components, working with
logic to a program.
databases, and web programming?
Writing any GUI program of moderate
complexity using the traditional text-
Concept of visual programming based approach is difficult, as it requires
Computer programs can be written in a programmer to write a lot of code just
one of two ways: using the traditional to create graphical components, let alone
text-based approach or using the visual writing code for solving the problem
programming approach. In text-based at hand. Thus, the major and obvious
programming a programmer writes advantage of using visual programming
a program entirely in a text editor. techniques is to increase programmer
This applies to both console as well productivity, that is, the programmer
as Graphical User Interface (GUI)- focuses on writing business logic code
based programs. In contrast, visual to solve the problem at hand instead

200
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 200 23/01/2023 11:26:53


of worrying about creating graphical interface like forms and can be
components. As creating graphical resized and moved more quickly.

Computer Science
components requires a lot of code, (c) 
The developer may quickly
visual programming offers a significant progress in writing code without
productivity boost to programmers. learning the syntax of the entire
Examples of visual programming programming language. This
languages results to graphic representation of
the entire design process.
Not all programming languages are
visual in nature, but visual programming (d) 
Visual programming enables
capabilities can be added to any text- developers to test several new ideas
based programming language. For at a rapid speed, and are comfortable
example, the Basic programming to its graphical presentation flow,
language is text-based; when visual ease of use, and traceability.
programming capabilities were added (e) 
Visual programming offers the
to the language it became to be known users the ability of programming
as Visual Basic. Similar capabilities are without the necessity to learn code.
available in languages such as C++, (f) 
With visual programming, users
Java, and Python. Visual programming links the outputs of one segment
capabilities are usually added to a to inputs of another, creating a
programming language by means program that moves from segment
of software libraries together with to segment by connectors more
integrated development environments easily.
(IDEs), for example the .NET (Visual
(g) Visual programming languages are
Basic), QT (C++), Swing (Java), and
easier to learn and use.
PyQT (Python) libraries used in different
IDEs to add visual programming
capabilities in the respective languages.
Visual Basic .NET and the .NET
This chapter is based on Visual Basic
Framework
.NET (VB. NET), a visual programming This section discusses the VB. NET
language that is based on the .NET programming language and the .NET
framework. framework on which it relies for most of
its functionality.
Importance of visual programming
Visual Basic .NET
Visual programming has the following
importance: The concept of Visual Basic .NET
(a) 
Visual programming is most Visual Basic .NET is a modern object
useful when the consideration is oriented programming language
in speed, automation, and ease of developed by Microsoft. The language
programming. is based on the .NET framework and
was introduced in 2002 as a successor
(b) 
The user interface are designed
to the Visual Basic 6 programming
very quickly, using a mouse. The
language. In addition to object-oriented
components are placed on the main

201
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 201 23/01/2023 11:26:53


capabilities, the language support of user activities such as mouse
event-driven programming, that is, the clicks. This enables a programmer
Computer Science

ability of a program to respond to user to write code that is executed when


actions such as mouse clicks. Although the event occurs.
the language is a successor to Visual Conditional compilation: Selective
(e) 
Basic 6, it is not compatible with the compilation of blocks of code based
latter meaning that programs written on certain conditions. Conditional
in VB.NET will not compile in Visual compilation is used when different
Basic 6. Being built on top of the versions of a program with different
.NET framework, the language has full features need to be produced from
access to all the libraries and facilities the same source file; for example,
offered by the framework including web when the same program is needed
programming frameworks, numerical on two different platforms.
libraries, and 3D graphics programming
libraries. Simple multithreading: The ability
(f) 
for a program to have multiple
Features of visual basic .NET parallel execution paths. This
VB.NET has many attractive features technique is often used to speedup
that make it appealing to programmers. programs by making use of multiple
Some of its prominent features include: processors on a computer.
Easy to learn and use: One can learn
(a)  Advantages of VB.NET
and be able to use the language to
do something useful in a relatively Visual Basic .NET has the following
short period. advantages:
Automatic garbage collection: The
(b)  (a) 
The .NET Framework is a software
ability to automatically reclaim framework with a large library
memory that is no longer in active collection, which helps develop
use by a program, for example, applications that are more robust.
when a data structure is no longer (b) 
Error handling is possible in the
needed the memory it occupies Visual Basic .NET Framework.
is reclaimed and used for other It allows appropriate action to be
purposes in the program. taken where it encounters an error.
A rich standard library: A collection
(c)  (c) 
You can develop a simple program
of classes and frameworks ready which works faster with a large
for use by programmers in solving desktop and web application using
various programming problems. Visual Studio IDE.
For example, components like (d) 
It is an object-oriented programming
buttons, check boxes and the like language having objects and
used in GUI programming. classes.
Properties
(d)  and events: (e) 
It employs drop and drag elements
Characteristics of components to create web forms in .NET
such as color and signals that notify applications.
components on the occurrence

202
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 202 23/01/2023 11:26:53


(f) 
Code will be automatically simplifies the process of developing
formatted in a VB.NET software. Software frameworks

Computer Science
(g) 
Visual Basic .NET allows implement and make available
connecting one application to to programmers commonly used
another created in the same programming functionality such as
language to run on the .NET creating GUI components, working
framework. with databases, and web programming.
The .NET framework provides a
(h) 
You can connect your applications platform for developing desktop, mobile
to other applications created in and web applications using different
languages that run on the .NET programming languages such as VB, C#
framework. (reads C sharp), and F# (reads F sharp).
Disadvantages of VB.NET To use the .NET framework for
The following are some disadvantages developing software you will need to
of VB.NET: install the .NET Developer Pack on your
computer. You will also need to install
(a) 
It contains a large collection of an IDE to use in your development
libraries which holds a vast space work. Microsoft provides an excellent
in the system that takes more IDE, Visual Studio (VS) 2022, for this
computing time during compilation. purpose. VS 2022 comes bundled with
(b) 
It reduces jobs in the programming the .NET framework, so if you install
field as a VB.NET programmer it you will not need to install the .NET
because it is easy to learn resulting framework separately.
to more skilled programmers in the
market. Components of .NET framework
(c) 
The computer needs a JIT compiler The .NET Framework is composed of
to interpret the Intermediate the following components:
Language source program, which (a) 
.Net Framework Class Library:
requires an additional CPU cycle It consists of a huge library of
that degrades the performance of reusable types; the interfaces,
an application. classes, structures, and enumerated
(d) 
It requires a lot of programming, values, together called types.
and it is not easy to manage every (b) 
Common Language Runtime or
address by a pointer, resulting in CLR: It is responsible for memory
additional coding, which takes management, debugging, code
more CPU cycles, and increases execution, code safety, exception
processing time. Hence, slows the handling, thread execution,
VB.NET application. security checking, verification,
and compilation. It converts the
The .NET framework program into native code. It acts as
Introduction to .NET framework an interface between the framework
and operating system.
.NET is a software framework that

203
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 203 23/01/2023 11:26:54


(c) 
Windows Forms: This contains (i) 
Windows Presentation Foundation:
the graphical representation of It provides a separation between
Computer Science

any window displayed in the the user interface and the business
application. logic. It helps in developing
(d) 
ASP.NET and ASP.NET AJAX: It visually stunning interfaces using
is used to develop websites, web media, documents, animations,
applications, and web services. 2-D and 3-D graphics, and others.
It provides a strange integration (j) 
Windows CardSpace: It provides
of HTML, CSS, and JavaScript. safety for accessing resources and
It contains AJAX, an extension sharing personal information on
for developing and implementing the internet.
AJAX functionality. ASP.NET (k) 
Windows Workflow Foundation
AJAX contains the components (WF): It used in building workflow-
that allow the developer to update based applications in Windows.
data on a website without reload It consists of activities, workflow
the page completely. designer, workflow runtime, and a
(e) 
ADO.NET: It is the technology rules engine.
used for working with data and (l) 
Windows Communication
databases. It provides access to Foundation (WCF): It is the
data sources like SQL server, OLE technology for developing and
DB, XML etc. The ADO.NET executing connected systems. It is
allows connection to data sources a framework for building service-
for retrieving, manipulating, and oriented applications. It can assist
updating data. in sending data as asynchronous
(f) 
Common Language Specification: messages from one service
It contains the specifications for endpoint to the next.
the .Net supported languages
and implementation of language Features of .NET framework
integration. .NET Framework contain several
(g) 
Common Type System: It provides features, which make it better, and more
guidelines for declaring, using, and ease to modern programming activities.
managing types at runtime, and The following list describes .NET
cross-language communication. Framework main features:
(h) 
Metadata and Assemblies: Metadata (a) Interoperability: Normally,
is the binary information describing interaction between new and
the program, which is either stored old applications is required, so,
in a portable executable file (PE) .NET Framework provides a
or in the memory. Assembly is way to access features that are
a logical unit consisting of the implemented in programs that run
assembly manifest, type metadata, outside the .NET environment.
IL code, and a set of resources like (b) 
Support Multi languages: The .
image files. NET has a Common Type System

204
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 204 23/01/2023 11:26:54


(CTS) that defines all possible data memory, database connections,
types and programming constructs network, etc. It invokes built-in

Computer Science
supported and provides the means functions to allocate and deallocate
how they interact with each other. the memory used by objects
This allows .NET to support during runtime. This removes the
multiple application development developer’s burden of managing
programming languages, including memory.
C#, or Visual Basic. (g) 
Deployment made easy: When it is
(c) Portability: Applications written time for application deployment,
using .NET language are portable. depending on the desired
That means that when the source deployment environment (mobile,
code of a program written in a desktop, cloud, etc.) the developer
Common Language Runtime has abundant options to package
(CLR) compliant language the application.
compiles, it generates machine- (h) 
Security: .NET allows code to run in
independent, intermediate code. It different levels of security without
is also possible to mix and match separate security mechanism.
code written in the languages
supported by the framework. (i) Easy and rich profiling and
debugging support: Integrated
(d) Base Class Library: The Base Class Development Environments (IDEs)
Library (BCL) is a type library like Visual Studio or Visual Studio
available for all languages that use Code provide a place to develop
.NET. The BCL provides classes and debug .NET applications. The
that encapsulate many common framework provides rich debugging
functions, including reading and and profiling information, which
writing files, database interaction, is highly integrated within these
image design, XML and JSON IDEs. This helps us to check the
manipulation, etc. application performance and track
(e) 
Common Language Runtime down runtime exceptions.
(CLR): All the programming
Languages in .NET are compiled Installing Visual Studio (VS) 2022
into an intermediate language Before you can start programming in
known as Common Intermediate VB.NET you need to install the VS
Language (CIL). This intermediate IDE. It is recommended that you install
language is not interpreted but the latest version. In this book VS 2022
compiled to native code in a way will be used. There are about five steps
known as Just In Time compilation in installing VS 2022. While these steps
(JIT). The combination of these are mandatory, also some are optional.
is called Common Language To install VS 2022, follow the following
Infrastructure (CLI). steps.
(f) 
Automatic Resource Management: . 1. Check your computer for readiness:
NET CLR automatically manages Before installing VS on a computer,

205
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 205 23/01/2023 11:26:54


you should ensure the computer and required system components for
Computer Science

meets the following requirements: VS installation.


Windows 10 or higher on an x64
processor with at least 1.8 GHz 3. Download the VS bootstrapper file:
and a minimum of 4 cores. In The bootstrapper is a small file that
addition, at least 4 GB of RAM are when run downloads the VS installer.
required and a minimum of 850 Mb Go to https://visualstudio.microsoft.
of hard disk space (an SSD hard com/downloads to download the
disk is recommended). Finally, the file. Choose the community edition
computer should have a video card of VS. The file will have a name
with a resolution of at least 1366 x similar to vs_community.exe.
768.
4. Run the bootstrapper file: To
2. Update Windows: Update the download the VS installer, run the
Windows Operating system to ensure bootstrapper file. Agree to the terms
it includes the latest security updates stated on the shown dialog box by
choosing continue (see Figure 4.1.)

Figure 4.1: Running the VS bootstrapper file

 hoose features (workloads) to install: When the installation is complete


5. C
select the features you want to install; In this case choose the .NET desktop
development option (see Figure 4.2.)

6. Choose install to start the installation process.

206
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 206 23/01/2023 11:26:54


Computer Science
Figure 4.2: Selecting VS features to install

The steps described above are necessary for installing VS 2022. Optionally, you
can change the installed language or install additional language packs alongside the
default language. The installer chooses the default language based on the operating
system language (Figure 4.3 (a). Similarly, you can choose a different installation
location as shown in Figure 4.3 (b).

Figure 4.3: (a) Installing additional language packs/changing installation


language.

207
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 207 23/01/2023 11:26:54


Computer Science

Figure 4.3 (b): Choosing a different installation location

After VS is installed, you can launch it and explore its features. To do this, perform
Activity 4.1.

Activity 4.1: Exploring the VS 2022 IDE

Resources: A computer with VS 2022 IDE


Procedure:
1. Launch VS 2022 and carefully study the features of the start window shown.
Try to understand the different options for creating and opening projects.
2. Choose Create a New Project to create a new Windows Forms application.
Choose VB for language and Windows Forms application (.NET) for application
type. Fill in the basic details and options about the application such as project
name.
3. Create the project. You will now have a new Windows Forms project to work
with. In the next section you will learn how to work with different controls. The
final IDE window after completing these steps should look similar to the one
shown in Figure 4.4.

208
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 208 23/01/2023 11:26:54


Computer Science
Figure 4.4: A newly created Windows Forms project

Exercise 4.1

1. What do you think are the drawbacks of visual programming?


2. Contrast between VB.NET and visual programming.
3. Is visual programming suited for building every kind of software? Explain.
4. List the two elements of a Visual Basic Application.
5. What is the purpose of a GUI and what elements does a user see in a GUI?

Components of the Visual Studio 2022 IDE


This section explains the different components and tools of the Visual Studio IDE
that will allow you to create Visual Basic .NET applications.
Menu Bar
Menu Bar , shown in Figure 4.5, is the Visual Basic command to create, complete,
and execute your application.

Figure 4.5: The Menu bar in the Visual Basic IDE

209
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 209 23/01/2023 11:26:54


Visual Basic .NET Controls Control Properties
Computer Science

Controls are objects placed on a Visual Properties describe the control in terms
Basic form. A form is also a control object of appearance, layout and behaviour.
that acts as a container that hosts other For instance, each control can have a
controls of the application. Each control name, size, label, font size and font type.
has its own set of properties, methods, Control properties can be set using the
and events that can be configured by properties window or using visual basic
the programmer depending on their code. To edit the properties of the control
needs. The toolbox is a window in once it is on the form, right-click on the
Visual Studio that provides all controls. specific control and select Properties. It
To launch the toolbox, click View on will open up a properties window that
the Menu Bar and then select Toolbox. allows you to set several properties of
The Toolbox window will appear, the control.
with several tabs that contain different For example, Figure 4.6 shows the
controls. Pay special attention to the properties window when a Button
Common Controls tab. To add controls control is selected. Using this Properties
to a form, simply double-click on it or window one can set the appearance,
drag and drop it on the form. layout, behaviour, accessibility of the
Visual Basic .NET Control elements button and more. For example, you
can change the text’s font, background
Visual Basic has three control elements, colour, point size, and alignment of the
which are control properties, control Button control.
methods and control events.

Figure 4.6: Properties window in Visual Studio

210
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 210 23/01/2023 11:26:54


Control Methods

Computer Science
A method is a procedure that performs a certain task. Controls in visual basic have
methods which perform certain tasks by accessing information within the control
class. Methods direct the object to do something. All controls have built-in methods
that can just be called. However, if none of the methods performs the task needed,
new methods can be created.
For example, the control Textbox has a built-in method called Text() whose function
is to get or set the input text of the Textbox.
Control Events
Control events notify the control that an event has occurred. Examples of events are
click, double click, close, resize and load. When a certain event occurs, the specific
method that handles that event is called. For example, when a user clicks on a Button
control, the event method Button_Click() is called. All code that needs to be executed
when a button is clicked should therefore be written in this event handling method
(Button_Click()) as shown in Figure 4.7.

Figure 4. 7: A button click event that handles the click of a button.

In this example, from Figure 4.7, a button click event handles the click of a button
when Button1 is clicked; a message box appears with the text “You have clicked a
button”.

Visual Basic .Net Toolbox controls


Common/Basic Controls
Forms
Visual Basic allows us to create form-based applications. Each window on the
desktop that a Visual Basic application displays is a form. The words form and
window both refer to the same thing. Therefore, a form is a container for all the
controls that make up the graphical user interface of visual basic applications.
To create a form-based application in Visual Studio, click on File > New Project and
then select Windows Forms Application project. Once the project is created, a new
blank form will appear as in Figure 4.8.

211
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 211 23/01/2023 11:26:54


The Controls and their functions are
described in Table 4.1.
Computer Science

Table 4. 1: Controls and their description


Control Function
Button A control that
represents a button for
a user to press.
Check Box A control that provides
the user with a toggle
choice (checked or
unchecked).
Figure 4.8: A form in VB . NET
Checked A control that provides
List Box a user with a list of
Elements of the VB .NET ToolBox
options to select From.
In this book, we will discuss the common It allows the user to
controls that are frequently used. Figure select one or more
4.9 shows the common controls and a boxes.
brief description of what each component Combo Box A control that displays
does is given in Table 4.1. a drop-down list
of various items. It
combines a text box
where the user can add
the item and a drop-
down list where the
user chooses added
items.
Date Time A control that allows
Picker users to select a time
and date on a form
Label Allows adding text to
the form
Link Label This control allows you
to add links (web-based
like) to the form. You
can link to a file or a
folder webpage.
List Box A control that works to
display a list of items
on the application.
Users can select any
Figure 4.9: Toolbox showing common options from the list.
controls that can be added to forms

212
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 212 23/01/2023 11:26:54


Control Function Control Function

Computer Science
List View This control allows PictureBox A control that is used
displaying a list of to display images and
items with icons graphics. The image
Masked Text A Control that allows can be in any supported
Box for both restricted data format and size such
entry and formatted as, Bitmap (bmp),
data output. This JPEG (.jpg), icon
control provides visual (.ico), the cursor (.cur),
indications of the type run-length encoded
of data entered or (.rle), metafile (.wmf),
displayed. enhanced metafiles
Month A control that allows (.emf), and GIF (.gif)
Calendar the selection of files.
months and data from Radio A control that limits
a calendar. It also Button the user to pick just
allows the selection of one option. The
a range of dates on the programmer can set
calendar. any of the buttons as
default if needed.
Notify Icon This control display
icons for processes Rich Text A control that allows
running in the Box formatting text, e.g.,
background. The making the text bold,
NotifyIcon Control italics, underlining or
is used to show the adding colour. It also
status of background allows the displaying
applications. of formatted text.
Text Box A control that is used
Numeric Up This control consists to accept textual input
Down of a text box with a from the user. The
number and a pair of user can add strings,
arrows (upward and numerical values and a
downwards). It allows combination of those.
the user to increase Tool Tip This control enables
the numerical value by the display of text
clicking the upward when the user points at
arrow and decrease the any control. It can be
number by clicking the used with any control
downward arrow. and is commonly used
to provide users with
TreeView A control that displays
more information or
a hierarchy of nodes.
help tips.

213
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 213 23/01/2023 11:26:54


Solution Explorer
Computer Science

The solution explorer (Figure 4.10) is a special window in the Visual Basic IDE that
allows you to see all your opened projects as well as, all files and elements that your
projects contain. The solution explorer is similar to the project explorer or project
window in previous versions of Visual Basic.

Figure 4.10: The solution explorer window in Visual basic

Editing form controls


To add any of the controls described in Table 4.1, you can either drag and drop the
control from the toolbox view to the form or double-click on the control, which will
appear on the form. To edit the control from the form, right-click on the specific
control and select Properties. This will open up a properties window that allows you
to set several parameters of the control.
For example, Figure 4.11, shows the properties window when a button control
is selected. Using this Properties window one can set the appearance, layout,
behaviour, accessibility of the button and more. For example, you can change the
text’s font, background colour, point size, and alignment of the button control.

Figure 4.11: Properties window in Visual Studio


214
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 214 23/01/2023 11:26:54


Design View and Code View

Computer Science
The advantage of visual programming is that the programmer adds the controls
using a graphical user interface (by dragging and dropping) and the IDE generates
the necessary code needed to create that control. For example, adding a Button
control will generate the code needed to create and show the button. To see the code
that has been generated, right click on the control that you want to edit and select
view code. Use the solution explorer to navigate to the specific component (in this
case Button1). This will open a Designer.vb view which shows all the code that the
IDE has automatically generated as shown in Figure 4.12. Note that the code in the
Designer.vb view is not meant to be edited, instead to edit visual controls use the
properties view.

Figure 4.12: Designer view showing code generated for a button

While the Visual Studio IDE allows you to drag and drop controls to your form
applications and edit these controls using the properties window, the code view
allows you to add specific functionalities to these controls. For example, to add
code that should be called when the Button is clicked, double click on the button in
the design view as shown in Figure 4.12. This will open a Formname.vb code view
which allows you to add code that controls events of the button, for example the
onClick event as in code snippet in Figure 4.13.

Figure 4.13: Code view showing a Button click function

215
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 215 23/01/2023 11:26:55


Creating your first application in project. A window containing a new
Visual Basic .NET form will appear. Open the toolbox
Computer Science

Now that we have explored the Visual (View > Toolbox), then drag and drop
Studio IDE and covered which controls the control Label property to the new
are available, it is time to create a form. Open the properties window and
full working application using this under appearances, look for the named
knowledge. We start by creating a simple Text and type in “My first VB.NET
form that will display the text “Welcome program” (Figure 14). Click on the run
to my Visual Basic .NET application”. button to run the application. The form
should appear with the text “My first
Open your Visual Basic IDE and create VB.NET program” as shown in Figure
a new Windows Forms Application 4.15.

Figure 4.14: The design view in Visual Studio showing a form and a label control

The output of the program will be shown in Figure 4.15.

Figure 4.15: Output of the program when it is run

216
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 216 23/01/2023 11:26:55


Exploring features and basic controls view. To capture what the user enters
of Visual Basic .NET in the TextBox, use the command

Computer Science
To explore how to use more features and textboxname.getText.
controls of Visual Basic .NET to create
applications, we will use an example
of an application that will manage the
registration process of Form 5 students
to a school. The application will require
the students to fill in a registration form
with information such as first name, last
name, gender, date of birth, combination
and add their picture. The controls that
will be used to create this registration
form are explained hereafter.
Figure 4.16: Label (First Name and
Labels Last Name) and two empty TextBoxes
A label is used to display fixed text
and numbers on the form. It provides
MonthCalendar
instructions to the users and displays the
output. This control allows the user to select
TextBox year, month and date from a calendar
view (Figure 4.17). In the registration
The TextBox is a box for entering and form, we will use the MonthCalendar
displaying text (characters or values)
control to capture the date of birth
in a user interface. This tool is used
of the student. Drag and drop the
frequently in most applications. In form
applications, usually, a label shows the MonthCalendar control from the
name of the text box. toolbox and use a label to indicate that
the student should enter their birth date
Example
using the calendar. The MonthCalender
Design a registration form that allows control has many properties that can be
form 5 students to enter their firstname configured, for example you can set the
and lastname. Use the toolbox to drag
minimum and maximum date that can be
two text boxes and two labels as shown
selected. To capture the date selected by
in Figure 4.16. Change the following
properties using the property window, the student, right click on the calendar
Name, which reflects how the control and click code view. Select the calendar
will be referred to in the code and Text name and then select DateSelected, this
which will appear on the screen when will generate a block of code where you
the program is run. You do not need can capture the date selected and use
to add any value to the Text property it in the program. In our application, a
of the TextBox, this is usually left variable DoB of type String is defined,
empty for the user to fill in. Figure 4.16 and the selected date of birth is stored
shows this example on the graphical on this variable as shown in Figure 4.18.

217
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 217 23/01/2023 11:26:55


Computer Science

Figure 4.17: An example of a calendar as it appears on the form

The code snippet in Figure 4.18 captures the selected date.

Figure 4.18: Visual basic code used to capture the selected date

Listing options edit the Text property and set them to


Visual basic .NET contains four Male and Female respectively as seen
controls that can be used to list options in Figure 4.19.
to the user on a form. These are The radio button allows you to capture
RadioButton, ListBox, checkedListBox a selected option and assign it to a
and ComboBox. We discuss when it is variable for use in the program. For
appropriate to use which one using our example, in this application, we have
registration form example. created a variable named Gender of type
RadioButton String which is set to male when the user
selects the male radio button and set to
A radio button allows the user to select female when the user selects a female
one out of many available options. It radio button.
is used to display a list of mutually
exclusive choices. In this example, the
student needs to select a gender and Gender Male Female
they can either select Male or Female.
Use the toolbox to drag two radio Figure 4.19: Radio buttons for
buttons and use the property window to choosing gender
218
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 218 23/01/2023 11:26:55


The code snippet in Figure 4.20 captures the radio button selection.

Computer Science
Figure 4.20: Visual basic code to capture the radio button selection

List Box
This control allows listing of several options to the user and the user can select one
or more. For example, if we want the student to select one or more combinations
of subjects from a fixed set of choices, a ListBox is appropriate. Use the toolbox
to drag and drop a list box in the form. Select the ListBox added and go to the
properties window. In the properties window, go to the Items property and click on
the button with three dots on it. A new window will appear allowing you to list the
options that should be on the ListBox. In Figure 4.22, the list contains four choices
which are PCM, PCB, PMC and MCsE. To allow selection of multiple items on the
ListBox, set the SelectionMode property to MultiSimple.
To capture what has been selected on the list box, right click on the ListBox, and click
view code. Select the list box and in the events box select SelectedValueChanged.
This will add a block of code which allows you to capture the selectedItems on the
list (see Figure 4.21).

Figure 4.21: Visual basic code to capture the selected items.


CheckedListBox
A ChekedListBox is similar to a ListBox except that the CheckedListBox has a
check box next to each list item and this check box can be checked with a tick. The
middle box in Figure 4.22 shows an example of a CheckListBox.

219
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 219 23/01/2023 11:26:55


ComboBox
Computer Science

This control also allows selection of choices. However, the comboBox allows
the user to enter new choices that are not provided in the list. In Figure 4.22, the
comboBox shown allows the student to add a new combination that was not listed
in the choices.

(a) (b) (c)

Figure 4.22: (a)The ListBox, (b) CheckedListBox and (c) ComboBox.

Check Box
This control can be used to show one option that a user can select or deselect. The
CheckBox has a property called checked which is set to True when the checkbox is
selected and False when unselected. In Form 5 application example, a CheckBox
is used to let a student choose whether they prefer to be in day school instead of
boarding school as shown in Figure 4.23.

Figure 4.23: An example of a CheckBox


Picture Box
This is a control that is used to add images into a form. In this example, we want
the student to upload their picture and then display it on the form. To achieve this,
a PictureBox control that will hold that image is needed. Use the toolbox to add a
PictureBox into the form and a label to indicate that it will display a profile picture
as shown in Figure 4.24. A default picture can be set by using the image property
in the properties window which allows you to navigate and select a default image.

Figure 4.24: An example of a PictureBox with a default image.

220
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 220 23/01/2023 11:26:55


Button change the Name property of the Button
from Button1 to SubmitButton. Right

Computer Science
A button acts as a switch which is used to
run a specific block of code. The Button now the button exists but does not have
control is used to link and call a function any functionality. Right click on the
in a program. button and click View code. The code
editor will open with the cursor placed
In the registration form example, the where the code for controlling the button
Button control is used to capture all needs to be. Add the code below to show
information a student has filled in the a message box that captures the first
form and display it on a message box. name, last name, gender, date of birth,
Drag and drop a Button control to the selected combination of the student and
form. Change the Text property of the whether the student prefers day school
button from Button1 to Submit. Also or not as shown in Figure 4.25.

Figure 4.25: V
 isual basic code to capture input from the form and display it on a
message box.

Figure 4.26 shows the complete Form 5 registration program application that has
been developed using different features and controls available in VB. NET.

Figure 4.26: Student registration form developed using Visual Basic .NET

221
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 221 23/01/2023 11:26:55


Containers in the ToolBox. Use the properties
window to change the name of your
Computer Science

Containers are controls that have the


ability to host other controls. Forms GroupBox. To add controls to the
are the base containers since they host GroupBox, select the GroupBox then
all other controls. Apart from Forms, drag and drop controls to it. Figure 4.28
Visual Basic consists of other container shows the GroupBox
controls. These container controls can
be found in the Containers Tab of the
ToolBox. The container is referred to as
the parent and the controls it contains are
referred to as Children. In this book, we
will describe two common containers,
The GroupBox and TabControl. Figure
4.27 shows the container control

Figure 4.28: Group box titled


“Personal Information” containing
label, textbox and radiobutton controls

TabControl
The TabControl allows you to have
several Forms in one window using
tab style. Each tab on the TabControl
can contain different controls. To add a
Figure 4.27: Container controls in
TabControl to your application, double
Visual Basic
Click on TabControl from the ToolBox
as shown in Figure 4.29.
GroupBox
The GroupBox control allows you to
separate the controls on your form into
different groups depending on their
functionality. This container is useful
since it can provide good structure to
forms with many controls. A groupBox
allows you to add controls in a frame/
box which can be named, making it
easier for users to understand which task
the controls in the group cover. Figure 4.29: TabControl example
To add a GroupBox to your form containing two tabs (First tab and
application, double-click on GroupBox Second tab)

222
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 222 23/01/2023 11:26:55


The TabControl has many properties application. An example of a Toolbar
that allow you to configure it. To add is the toolbox window which provides

Computer Science
and remove a tab to the TabControl use different controls for a programmer.
the property named TabPages. This will When a menu is clicked it performs
open up a window similar to Figure a certain task such as launching
4.30, which allows you to add, name something. Menus can also be displayed
and remove tabs. You can also change by right-clicking on a control. These are
the order of your tabs using the upward referred to as context menus since they
and downward arrows. are displayed based on which control
is clicked. Visual Studio toolbox has a
Menus and Toolbars tab that provides all
possible menus and toolbar types.

Figure 4.31: Example of a Menu in a


Visual Basic form application.

Adding a menu strip


To add a menu to your form application,
Figure 4.30: Editing of the TabControl double-click on MenuStrip on the
by using properties window to set the toolbox. This will add a row where you
appearance and behaviour of each tab can type the name of each menu and
sub-menu as shown in Figure 4.32. To
provide the functionality of the menu
Activity 4.2: Explore other container (what should happen if a user clicks on
controls available in the containers it), double-click on it. This will open the
tab of the Visual Studio Toolbox and code view where you can write methods
write their uses. which will be called when the menu is
clicked.

Menus and Toolbars


Menus allow you to add button-like
controls that a user can click on to
access a certain functionality or task.
Menus typically consist of one or two
words displayed in a row on top of the
application window (see Figure 4.31).
Toolbars provide a container to add Figure 4.32: Adding Menus and
utilities (tools) that a user can use in the Sub-menus

223
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 223 23/01/2023 11:26:55


Adding a context menu
Computer Science

As previously mentioned, context menus are menus that show when a certain
control is right-clicked. They are called context menus because they are specific to
the control that is clicked. Let us assume that we want to add a context menu that
will allow a user to copy, cut or paste text in a TextBox. To achieve this, on your
form application drag and drop a TextBox. Then drag and drop a context menu and
add three menu items to it (Copy, Cut, Paste). To associate the context menu with
the appropriate control, edit the property of the TextBox called ContextMenuStrip
and select the context menu as shown in Figure 4.33. To add code to the specific
menu, double-click on it and in the code view, add the copy, cut and paste methods
as shown in Figure 4.33.

Figure 4.33: Adding a context menu with three menu items (Copy, Cut and Paste)
Figure 4.34 shows the procedure to associate as specific control with context menu
using the properties.

Figure 4.34: A
 ssociating a specific control (TextBox) with the context menu using
the properties window.

224
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 224 23/01/2023 11:26:55


The code snippet in Figure 4.35 activates the copy, cut and paste.

Computer Science
Figure 4.35: Code to enable the Copy, Cut and Paste context menus to work
accordingly.

The output will be as shown in the 3. Gender


Figure 4.36. 4. Form VI index number
5. Date of form VI completion
6. Select a degree program
7. Add a picture
On the form, add a Button control which
when clicked displays the information
entered.

Exercise 4.2
Figure 4.36: Output of the context
menu program. 1. Explain the steps used to create a
Visual Basic .NET windows forms
application project
Activity 4.3: Creating the 2. Briefly explain the steps on how
first program on VB.NET to save a new Visual Basic .NET
applying basic controls windows forms application project
Assume that you have finished Form VI 3. Explain the components found in
and want to apply to be admitted to the the Menu bar of the Visual Studio
University of Dar es Salaam. Create a IDE
program to display a registration form
that captures the following information. 4. What is the use of a Toolbox in the
Visual Studio IDE?
1. First name
5. 
Design a form which displays
2. Last name your name and class in two text

225
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 225 23/01/2023 11:26:55


boxes after clicking the buttons 11. Briefly explain the advantages and
“name” and “class” respectively. disadvantages of VB.NET.
Computer Science

Add a “clear” button which, when 12. Create a form using VB.NET that
clicked, clears the text boxes. loads a list of items into a Combo
6. Design a form with three Buttons box when the form is loaded.
labelled “red”, “green” and “blue”
respectively as shown in Figure
4.37. For each button, write the code
to change the Form background Programming in Visual Basic .NET
colour to the respective colour (red, Data types in Visual Basic
green or blue) when the button is
Data types refer to the type of data or
pressed. Add another button named
value assigned to a variable or function
“clear” which will reset the Form
to hold a specific data type. When
background colour to the default.
we declare a variable, we inform the
compiler what type of data or value
would be assigned to a declared variable
for it to allocate enough memory for a
value expected to be stored. There are
two types of data types in visual Basic
.NET: numeric data types and non-
numeric data types.
Figure 4.37: A program to set the Numeric data types
background colour of the form depending Numeric data types consist of numbers,
on the button pressed. which can be computed mathematically
7. Describe the following features of using various standard operators such
Visual Basic studio as addition, subtraction, multiplication,
(a) Menu Bar. division, and others. Numeric data types
(b) Toolbox. include Byte, Integer, Long, Single,
(c) Form design view. Double, Currency and Decimal.
(d) Solution explorer
(e) Properties window. Byte data type
(f) Code editor window. This data type requires just one byte of
8. 
Explain the steps for creating memory. Variables with the Byte data
menus and drop-down menus in type can store values from 0 to 255.
VB.NET. The default byte value is 0. Negative
values and values greater than 255 are
9. Using VB.Net, create a project that
not allowed.
populates a list of items into a list
box when the form is loaded. Example 1: Using a variable of type Byte
10. Briefly identify the difference
between List box and Combo box

226
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 226 23/01/2023 11:26:55


Integer data type

Computer Science
The integer data type accepts positive, negative and zero values. Their values range
between -32,768 to 32,767. This data type takes up four bytes of memory. One of the
most used data types is the integer.
Example 2: Using a variable of type Integer

Long data type


This is an integer data type that stores larger integer values that takes up more
memory than a four-byte integer variable. It has a range from -2,147,483,648 to
2,147,483,647 values and is assigned 8 bytes of memory.
Example 3: Using a variable of type Long

Decimal data type


This is a numeric data type with a high level of precision. A scaling factor is a difference
between the total number of digits and the number of digits to the right of the decimal
point. In Visual Basic, numbers are scaled by a power of 10. When working with
large numbers that require precision, such as financial calculations, these types are
appropriate. This takes up 16 bytes of memory. The values of this data type fall into
the following range +/-7.9228162514264337593543950335. With no decimal point,
the largest possible number is +/-79,228,162,514,264,337,593,543,950,335 and with
28 decimal points, the largest number is +/-7.9228162514264337593543950335.
The smallest non-zero value accepted is +/-0.0000000000000000000000000001.
The syntax is Dim variableName as Decimal
Example 4: Using a variable of type Decimal

Double data type


Double is used to hold double-precision floating-point numbers. It has takes up
8 bytes of memory. Negative values range from -1.79769313486231E308 to
-4.94065645841247E-324. For positive values, the range is 4.94065645841247E-
324 to 1.79769313486232E308. Just like with the single data type, the double data
type is defined using the hash (#) symbol. The syntax is Dim VariableName Aas
Double or Dim VariableName#

227
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 227 23/01/2023 11:26:55


Example 5: Using a variable of type a value of TRUE or FALSE, or 1 or 0
Double correspondingly.
Computer Science

A Boolean variable’s default value is


False. The Syntax is Dim Vname As
Boolean
Example 7: Using a variable of type
Boolean
Single data type
The Single data type stores floating-
point values that do not require the
full data width of the Double data
type. The range of Single is from String Data Type
-3.4028235E+38 to -1.401298E-45 for A string is a defined collection of
negative values and from 1.401298E-45 characters that have been defined. As a
to 3.4028235E+38 for positive values. result, the string data type can be used to
The shorthand notation for declaring hold text and digits, special characters,
Single variables is to use a variable and even spaces. Double quotation
name and an exclamation mark (!). The marks “ ” are used to enclose string
default value of Single is 0. It is also values. There are two types of string data
called single precision. types. Variable-length String and fixed-
Example 6: Using a variable of type length String. Variable-length String,
Single which occupies 10 bytes of storage size
plus the memory required for the String.
They range from 0 to approximately 2
billion characters in length. The fixed-
length String is the type of String that
occupies the memory equal to the length
Non-numeric data types of the String itself. It can range from 1
to approximately 65,400 characters. The
Non-numeric data types are those that Syntax is Dim variableName As String
cannot be manipulated mathematically. OR Dim Vname$.
Examples of non-numeric data types are
String, Date, Boolean (data types that Example 8: Using a variable of type
contain only two values; true or false), String
Object, and Variant. These are described
in next subsection.

Boolean data type


Date data type
This data type takes up to two bytes of
memory and can only store two values: The date data type is used to represent
True or False. To put it another way, dates and time. It has date range values
the Boolean variable can only have from Jan 1, 0100 to December 31, 9999,

228
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 228 23/01/2023 11:26:55


and time values from 0:00:00 to 23:59:59 enumeration constants as well. The
and occupies 8 bytes of memory. The constants are treated just like regular

Computer Science
syntax is Dim variableName As Date. variables, except that their values cannot
Example 9: Using a variable of type be modified after their definition.
Date Declaring constants
The syntax of constant is Const
ConstantName As DataType = Value
Note that in the above example, the Whereby;
word “Now” is a function that returns §  onstantName - specifies the name
C
the current date and time. of the constant.
Object data type § Datatype - specifies the datatype of
The Object data type is also referred the constant
to as a non-primitive or reference data § Value - specifies the value assigned
type. They are so called because they are to the constant; the initializer.
used to refer to objects of any data type.
The Object data type occupies 4 bytes of Example 1: Declaring constants
computer memory. The default value of
an object is a null reference indicating
that the object has no data. You are
advised to use Object when you do not The const statement is used at Module,
know the data type your variable will class, structure, procedure, or at the
point to during runtime. block level for use in place of literal
values. The constant may be declared
Example 10: Using a variable of type
using const statement as follows:
Object
Const Dim variablename As Datatype.
Example 2: Using constant
const Dim pi As Double = 3.142
The example above declares a variable
with name wsActiveForm of type
object and then assigns an object called Lvalues and Rvalues
ActiveForm to the declared variable. There are two kinds of expressions
which are Lvalues and Rvalues.
Constants
Lvalues: the expression that is lvalues,
Constants refer to fixed values that
it may appear either at the left or at right
the program will not alter during its
hand side of an assignment. Variable are
execution. These fixed values are also
lvalues, therefore, they appear on the
called literals. Constants can be of any
left hand side of an assignment.
basic data type like an integer constant,
a floating constant, a character constant, Rvalues: an rvalue expression may
or a string constant. There are also appear on the right of an assignment but
not on the left side. Numeric literals are

229
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 229 23/01/2023 11:26:55


rvalues that is why may not be assigned Table 4.2: Example of valid and invalid
and cannot appear on the left hand side variable names
Computer Science

of the assignment. Valid variable Invalid variable name


Types of constants name
Constant can be of any of basic datatype My_Name My.Name
like an integer constant, a floating VB2022 2022VB
constant, a character constant or literal Long_name_ LongName&can&be&used
constant. There are also an enumeration can_be_used
constant as well. Enumeration is nothing
but just a set of named integer constants. Declaration of variables
To declare a variable, you need to
Visual Basic .NET variables give it a name and state its data type.
Variables are usually declared in the
A variable is a named memory location general section of the code windows
where a value can be stored throughout using the Dim statement, and the syntax
the execution of a program. Each variable is Dim VariableName As DataType.
has a specific type, which determines the If you want to declare more variables,
following things: you can declare them in separate lines,
(a) 
size and layout of the allocated or you may also combine multiple
memory, variables in one line, separating each
(b) range of values that are allowed to variable with a comma, for example,
be stored in that memory location Dim VariableName1 As DataType1,
VariableName2 As DataType2,
(c) a set of operations that can be done VariableName3 As DataType3
to the variable
Example 1: The code below shows an
Rules for naming variables example of how to declare variables of
The basic rules for naming variables are different types.
listed as follows:
(a) It must be less than 255 characters.
(b) No spacing is allowed.
(c) It must not begin with a number. Variable initialization
(d) The period is not permitted. Variables are initialised (assigned a
(e) They may not include punctuation value) with an equal sign (=) followed
or other symbols, except for by a constant expression. The general
underscore. form of initialisation is
(f) They may contain any mixture of Variable_name = value;
letters and numbers. Example 2:
Table 4.2 illustrates examples of the
valid and invalid variable. Dim pi As Double
pi =3.14159

230
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 230 23/01/2023 11:26:55


Notice that you can assign a value to the compiler to conduct specified

Computer Science
a variable in one line using the = sign mathematical or logical operations.
instead of declaring the variable and Types of operators
then giving it a value in another line.
The following are commonly used types
of operators in Visual Basic:
Dim YourName As String= “Juma”
Arithmetic operators
is the same as
Arithmetic operators are used to
Dim YourName As String
perform many of the familiar arithmetic
YourName=“Juma”. operations that involve the calculation
of numeric values represented by
Visual Basic operators literals, variables, other expressions,
functions, and constants. Table 4.3
Just like other programming languages,
shows arithmetic operators and their
Visual Basic also has operators.
examples.
Operators are symbols that instruct

Table 4.3: Symbols used in arithmetic operators and their applications

Operator Description Example (a = 5, b = 3)

+ Adds two operands a+b=8

– Subtracts two operands a–b=2

* Multiplies two operands a * b = 15

Divides two numbers and


/ a / b = 1.6666
returns a floating-point result

Divides two numbers and


\ returns an integer as a result a\b=1
without a remainder.

Divides two numbers and


Mod a Mod b = 2
returns only the remainder

Raises a number to the power


^ a ^ b = 125
of another number

The following program demonstrate the use of arithmetic operators. The program
is presented in Figure 4.38. The program output is presented in Figure 4.39.

231
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 231 23/01/2023 11:26:56


Computer Science

Figure 4.38: A program code for arithmetic operators


Exercise 4.3

232
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 232 23/01/2023 11:26:56


Computer Science
Figure 4.39: Sample output for arithmetic operations

Exercise 4.3
1. Write a program that takes in any text and computes its length.
2. Write a program that adds and subtracts two integer numbers. Use two buttons,
one for add another for subtract and a message box to display the results.
3. Write a program to compute the area of a triangle. The program should allow a
user to input the height and base of the triangle.
4. Write a program to enter the name of a student and three marks, for Physics,
Mathematics and Computer Science respectively. The program should compute
the average and display the student’s name and the average of the three marks
in two different labels.
5. Write a program that receives any number, then outputs the square of that
number on the screen.
6. Write a program that lets a person enter their date of birth and then computes
and displays their age. Hint: Use the MonthCalendar control.
7. Write a program that can be used to find the roots of a quadratic expression.
ax2 + bx + c = 0.

233
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 233 23/01/2023 11:26:56


Relational operators
Computer Science

In Visual Basic, relational operators are used to determine whether the defined two
operands are equal, greater than, or less than. Table 4.4 lists the different comparison
operators available in Visual Basic.
Table 4.4: Symbols used in relational operators and their applications

Operator Description Example (a = 10, b = 5)


< It returns True if the right operand is a < b : False
greater than the left operand
<= It returns True if the right operand is a <= b : False
greater than or equal to the left operand
> It returns True if the left operand is greater a > b : True
than the right operand
>= It returns True if the left operand is greater a >= b : True
than or equal to the right operand
= It returns True if operands are equal a = b : False
<> It returns True if operands are not equal a <> b : True
Is It returns True if two object references a Is b: False
refer to the same object
IsNot It returns True if two object references A IsNot b : True
refer to different objects

Logical operators
Logical operators return a Boolean result (True or False) after evaluating one or
more boolean expressions. There are six logical operators, which are supported by
VB as demonstrated in Table 4.5.
The concept of short-circuiting
When using logical operators, short circuiting means that not all conditions in the
whole expression are evaluated. The evaluation of the expression ends when the
result is already known from only evaluating some of the conditions in the logical
expression. In Visual Basic, the AndAlso and OrElse operators perform short
circuiting.
Note that, in other object oriented programming languages such as Java and C++,
the AND and OR operators perform short circuiting.

234
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 234 23/01/2023 11:26:56


Table 4.5 shows logical operators in VB and their applications.

Computer Science
Table 4.5: Symbols used in logical operators and their applications

Operator Description Example

AND It is the logical AND operator. If If A = True and B


both the operands are true, then =True, then (A AND
the condition becomes true. This B) = True
operator does not perform short-
circuiting.
OR It is the logical OR operator. If any If A = True and B =
of the two operands is true, then False then (A OR B)
the condition becomes true. This = True
operator does not perform short-
circuiting.
NOT It is the logical NOT operator. Used If A = True and B =
to reverse the logical state of its True then NOT(A and
operand. If a condition is true, then B) =False
the Logical NOT operator will make
it false.
Xor It is the logical exclusive OR If A=True and
operator. It returns True if both B=False then (A Xor
expressions are true or both B) = False
expressions are false; otherwise, it If A = False and B =
returns False. This operator does not False
perform short-circuiting, it always
(A Xor B) = True
evaluates both expressions and there
is no short-circuiting counterpart of
this operator.
AndAlso The AndAlso operator is very If A = False and B =
similar to AND operator except that True then (A AndAlso
it exhibits short-circuiting behavior. B) = False
If the first expression evaluates
false, the second expression will
never be evaluated and the result is
false.

235
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 235 23/01/2023 11:26:56


Computer Science

OrElse The OrElse operator is very A = True and B =


similar to OR expression except False
that, it performs short circuiting then (A OrElse B)
If the first expression evaluates = True
true, the second expression will
not be checked because it cannot
change the results, and the results
will be true

IsFalse It determines whether an If A = True and B


expression is false = True then IsFalse
(A and B) = False

IsTrue It determines whether an If A = True and B =


expression is true True then IsTrue (A
and B) = True

Visual basic control structures


Exercise 4.4 In writing programs, there often arises
the need for a program to choose among
1. Evaluate the following expressions
different courses of execution or to
given the following: A = False, B =
True, repeat certain computations many times.
Consider the problem of counting odd
C = True, D= False
and even numbers in a given interval,
(a) A And (B OR C)
say [0, 1000]. A program to solve this
(b) A Or (B AND C) problem will need to test each number
(c) A AndAlso (B OR C) in the interval to decide whether it is
(d) B Xor (C AND D) not divisible by two (it is odd). Thus,
the program will need two mechanisms
2. Explain the difference between to accomplish this task: (1) to decide
expressions in question 1(a) and
whether a number is odd or even and
question 1(c)
count it appropriately (choose a different
course of action); and (2) to test each
number in the given range (repetition).

236
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 236 23/01/2023 11:26:56


Thus, control structures enable If condition Then
programmers to manage flow of their

Computer Science
programs. VB.NET offers two kinds statements to execute when condition
of control structure namely decision is true
(selection) and looping (iteration). End If

Types of controls structure


There are three types of control Example 1
structures, which are: As a school system developer of
(a) Sequence control structure Mwalimu Nyerere Secondary School,
write a VB.NET program that will help
(b) Decision /selection control the academic teacher enter students’
structures mark then the program should display
(c) Iteration/ looping control structure whether the student passed or failed the
exam. Assume the pass mark is 50 and
In this part, the last two controls will be above.
discussed. Solution
Decision /selection control structures In this program, we will need a form
with a label, a button, and a text box.
There are two types of decision control
The label will be used to hold text that
structure, which are:
will describe the purpose of the text box;
1. If . . . Then statement the text box will allow the user to type
2. Select . . . Case statement (input) the mark; and the button will
allow the user to command the program
The IF statement to evaluate the provided mark when
The if statement tests one or more clicked. Thus, we will take advantage of
boolean conditions and lets a program the button’s click to check the entered
take one alternative paths of execution value for correctness before performing
based on the condition’s truth value. the intended evaluation.
There are three forms of the If Therefore, when the button is clicked
statement: If...Then, If...Then...Else, we will do the following tasks: (1)
and If...Then...ElseIf...Else. check if the user entered a value; (2)
check if the entered value is valid (3)
The If...Then statement evaluate the value to determine whether
This statement is used to test a the student passed. All of these tasks
condition (or conditions) and allow can be accomplished through the use of
a block of statements to be executed the If statement. We create a VB.NET
if the condition evaluates to true. It Windows Forms project with a single
does not offer an alternative block form. The form will contain the three
of statements to execute in case the controls: label, text box and button. The
condition evaluates to false. This form code for the click event of the command
of the If statement has the following button is shown Figure 4.40, while the
syntax: design of the form is shown in Figure

237
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 237 23/01/2023 11:26:56


4.41 (a). Results obtained after running the program with different inputs are shown
in Figure 4.41 (b to c). Notice the different course of action the program follows
Computer Science

depending on values of the conditions on the If statements.

Figure 4.40: A program code for evaluating marks as pass or fail

Figure 4.41: Design and output of the program: (a) Form design view; (b)Result
with a pass mark; (c) Result with a fail mark; and (d) Result with an
invalid mark
238
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 238 23/01/2023 11:26:56


The If...Then...Else statement

Computer Science
Unlike the If...Else statement, the If... Then.. Else statement tests a condition and
allows a program to taken one of two courses of action based on the truth value of
the condition. That is, when the condition is false it allows an alternative block of
statements to be executed. This form of the If statement has the following syntax:

If condition Then
statements to execute when condition is true
Else
statements to execute when condition is false
End If

Example 2
In example one, two separate If statements were used to test whether the student
passed or not. Since passing and failing are mutually exclusive (a student can just
either pass or fail), let us improve the program in example one by using the If...
Then...Else statement.
Solution
The only change we need to make is to replace the two if statements which test the
value of the markVal variable with an If...Then...Else statement (Figure 4.42). This
change will not affect the behavior of the program but will make it relatively shorter
and easy to read. Output of the program is the same as in example 1(Figure 4.41)

Figure 4.42: A program code corresponding to example 2

239
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 239 23/01/2023 11:26:56


Example 3
Computer Science

Write a program that allows the user to enter a username and display the message
“Hello”. If the username entered matches one of the following names “Baraka”,
“Neema”, “Ali” or “Issa”, the program should display “Hello” followed by that
matching name. Otherwise the program should display the message “Hello, Guest”.
Solution
We create a single-form application and put one text box for inputting the user’s
name, one button for triggering the greeting, and one label for describing the text
box. We implement the functionality of the application in the click event of the
button. The code for the click event of the button is shown in Figure 4.43, and the
output of the program when run with a known and an unknown user is shown in
Figure 4.44. The program uses a dialog box to greet the user.

Figure 4.43: A program code corresponding to example 3

Figure 4.44: Output of the program corresponding to example 3

240
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 240 23/01/2023 11:26:56


Note that we convert the name to lower case before we use it in the if statement (line
with an arrow) because string comparison is case sensitive. For example, “Neema”

Computer Science
and “neema” are treated as different. Thus we convert the entered name to lower case
and use lower case comparison in the If statement. Thus, if the user enters “Neema”
we convert it to “neema” so that the comparison becomes “neema” = “neema”,
which evaluates to true, as opposed to “Neema” = “neema” which evaluates to false.

The If...Then...ElseIf...Else statement


This statement is used if there are many conditions to be tested. The conditions are
tested one by one from the first to the last and only the block of statements for the
first condition that evaluates to true are executed. If none of the conditions evaluates
to true, the block of statements in the Else part is executed. This form of the If
statement has the following syntax:

If condition1 Then
statements to execute when condition1 is true
ElseIf condition2 Then
statements to execute when condition2 is true
ElseIf condition3 Then
statements to execute if condition3 is true

Else
statements to be executed if no condition is true
End If

Nested If statement
The nested If statement is an If statement placed inside another If statement. Nested
If statements are often used when you want to test a combination of conditions before
deciding on the proper action to take. First, the condition in the outer If statement
is tested; if it evaluates to true, then the condition in the inner If statement is tested.
If the condition in the inner If statement evaluates to true, the block of statements in
the inner If statement is executed. The nested If statement has the following syntax:

241
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 241 23/01/2023 11:26:56


If outer condition Then Else part of the statement is executed.
The syntax of Case statement is:
Computer Science

If inner condition Then


statements to be executed if both Select Case test expression
conditions are true Case expression1
End If block of statements 1
End If Case expression2
Note that both the outer and inner If block of statements 2
statement can have an optional Else Case expression3
part. In this case the statement takes the block of statements 3
following form:
Case expression4 ….
If outer condition Then Case Else
If inner condition Then alternative block of statements
statements to be executed if outer End Case
and inner conditions are true
Else Example 4.
statements to be executed if Write a program that prints the name of a
outer condition is true but inner day of the week when its corresponding
condition is false number is entered.
Solution
End If
Create a new Windows Forms project
Else with a single form. Add a textbox and
command button to the form. On the
statements to be executed if outer
click event of the command button insert
condition if false
the code shown in Figure 4.45.
End If

The Case statement


If you have too many conditions to test,
the If...Then...ElseIf...Else statement
becomes hard to deal with. In this
case, the Select...Case statement is
preferable. The case statement tests a
value of an expression and executes one
of several Case blocks of statements
whose value matches the value of the
expression. If the value of the test
expression does not match any of the
expressions in the case blocks, the Figure 4.45: A program code to display
name of a day of the week
242
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 242 23/01/2023 11:26:56


Output of the program is shown in Table 4.6: BMI data and comment and
Figure 4.46.

Computer Science
obesity class
No. BMI range Comment
1. < 18 Underweight
2. 18.5 to < 25 Healthy
3. 25 to < 30 Overweight
4. > 30 Obese
No. BMI range Obesity class
Figure 4.46: Output of the program 1. 30 to < 35 Class 1
corresponding to example 4 E 2. 35 to < 40 Class 2
3. > 40 Class 3 (severe)
Exercise 4.5
3. Write a program that accepts a score
1 Write a two-player number guessing
and determines a corresponding
game (player1 and player2). The two
grade. First, use the If...Then...
players play in turns; first, player1
ElseIf...Else statement, then use the
enters a secret number (between 1 and
Case statement. Compare the two
100) then player2 tries to repeatedly
implementations. Use the following
guess the until he or she guesses it
grade table for reference. Table 4.7:
correctly. Every time player 2 enters a
guess, the game should give feedback
as to how far the guess is from the Table 4.7: Examination scores and
secret number. When the number is grades
guessed correctly, the game should
congratulate player 2. No. Range Grade

2 
The body mass index (BMI) is 1. 75–100 A
a number used to measure the 2. 65–74 B
proportionality between a person’s 3. 55–64 C
height and weight. For a given height 4. 45–54 D
and weight, the BMI tells whether
a person is healthy, underweight, 5. 40–44 E
overweight, or obese. Furthermore, if 6. 34–39 S
a person is obese it tells the severity 7. 0–35 F
of the obesity. Write a windows
application that calculates BMI of a
person and comments on their health
status. If the person is obese let the
program tell the obesity class as well.
Iteration (Looping)
Use BMI data in the tables 4.9. Use
the formula BMI = weight (kg) / In the previous section you learnt how
(height (m))^2. to control program flow using the If and
Case statements (branching). In this

243
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 243 23/01/2023 11:26:56


section, you are going to learn another condition normally contains a control
control structure known as iteration or variable that is altered in each iteration
Computer Science

looping. The iteration control structure until the condition becomes false. In
enables a program to repeat an action VB.NET the While loop is available
a number of times. Solutions to many through the While...End statement and it
programming problems involve has the following syntax:
some form of repetition, thus, need
While condition statements
to repeat actions arises quite often in
End While
programming. Looping is achieved
using control structures known as loops. Sometimes you may want to exit a While
Like the If statement, loops are driven by loop before the loop condition becomes
Boolean conditions. Some loops repeat false. You can achieve this by using the
an action until a condition becomes true Exit While statement inside the loop
while others repeat an action until a body, usually in an If statement inside
condition becomes false. the loop body. Similarly, sometimes you
may want to skip the current iteration
Uses of iteration control structure and transfer control to the next iteration
The iteration is used to repeat line of of the loop. You can achieve this by
code or statements or instruction several using the Continue While statement
times in the program. inside the loop body.
Types of iteration control structures Example 1
VB.NET offers three kinds of loop: Suppose you want to write a function
that given a positive integer returns the
1. While loop
sum of the digits of the integer raised
2. Do loop to a given power. For example, calling
3. For Each loop the function with the number 123 and a
power of 2 gives 14.
The choice of which type of loop to use
depends on several factors including Solution
whether you want to repeat some action
a fixed number of times; you want To write this function you need to split
to repeat an action until a condition the number into individual integers.
becomes true/false, and; whether you Since you do not know in advance how
want an action to be performed at least many digits the number has, you need
once or not at all. to repeat the process until a certain
The While Loop condition is met. In this example we use
The while loop repeats a block of the Mod and the integer division operator
statements (the loop body) as long as a (\) operators to successively split the
given condition is true. The condition is number. We stop when the number
tested before the loop body is entered. becomes zero. The completed function
Therefore, there is a possibility that the is shown Figure 4.47. The output of the
loop body may not be executed at all if program is shown in Figure 4.48.
the condition is initially false. The entry

244
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 244 23/01/2023 11:26:56


Computer Science
Figure 4.47: A While Loop function to find a sum of integers raised to a given power

Figure 4.48: Output a program to find a sum of integers raised to a given power

The Do Loop
The Do loop repeats a block of statements as long as a given condition is true or until
the condition becomes true. It can be tested either before entering the loop or at the
end of the loop. Similar to the While loop, if you test the condition before entering
the loop and the condition evaluates to false the loop body will not be executed
at all. If you test the condition at the end of a loop, the loop body is guaranteed to
be executed at least once. Alike to the While loop, the loop body alters a control
variable to ultimately make the loop stop. The Do loop is available through the Do...
Loop statement and has the following syntax.

245
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 245 23/01/2023 11:26:56


Do While/Until Do
Computer Science

condition statements
statements Loop While/
Loop Until condition
As with the While loop, sometimes you
may want to exit a Do loop before the
loop condition becomes false/true. You
can achieve this by using the Exit Do
statement inside the loop body, usually
in an If statement inside the loop body. Figure 4.49: A Do Loop function to find
Similarly, sometimes you may want to the first Armstrong number
skip the current iteration and transfer
control to the next iteration of the
loop. You can achieve this by using the
Continue Do statement inside the loop
body.
Example 2
An Armstrong number of order N is an
N-digit number that has the property
that the sum of its digits raised to the Figure 4.50: Output a program to find
Nth power equals the number itself. For the first Armstrong number
example, 153 is an Armstrong number
of order 3 since 153 = 1^3 + 5^3 + 3^3 The For Each Loop
= 1 + 125 + 27 = 153. Write a function The For Each loop is used with
that finds the first Armstrong number of collections where it runs a block of
order 4. statements once for each element of the
Solution collection. To use the For Each loop
you specify a loop control variable
To do this we will need to split numbers. which will be assigned a value from the
For this purpose, we can make use of collection in each iteration. The loop
the SumDigits function in example 18. exits when all elements in the collection
The completed function is shown in have been processed. The For Each loop
Figure 4.49. The output of the program is available through the For Each...Next
statement and has the following syntax.
is shown in Figure 4.50
For Each element In group
statements
Next

246
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 246 23/01/2023 11:26:56


To exit a For Each loop prematurely or to skip the current loop iteration you can
use the Exit For and Continue For statements, respectively based on evaluation of a

Computer Science
condition in an If statement.

Example 3
Write a function that return the number of order 4 Armstrong numbers.
Solution
In this case the number of iterations is known in advance (testing the numbers
between 1000 and 9999), hence we can make use of the For Each loop. Again,
we make use of the SumDigits function in example 18. The completed function is
shown in Figure 4.51. The output of the program is shown in Figure 4.52

Figure 4.51: A For Each Loop function to find the count of Armstrong numbers

Figure 4.52: Output a program to find the count of Armstrong numbers

As with the If statement, you can put one loop inside another. When you do this,
the loops are said to be nested. You can nest any type of loop inside another. When
loops are nested, for each iteration of the outer loop the inner loop runs to the end.

247
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 247 23/01/2023 11:26:56


Exercise 4.6
Computer Science

1. Write a program to find the factorial of a number.


2. Construct a program to enter n numbers (both positive and negative) and find
the average of the negative numbers only.
3. Write a program to print multiples of 6 which lie between 12 and 60, using a do
while first, then use do loop.
4. Write a program to display odd numbers which lie in a range defined by a user.
5. Write a program to find multiples of 3 that exist between 1 and 100.
6. Write a program to list all Armstrong numbers between 1 and 10000.

Visual Basic .NET procedures useful for taking one or more pieces of
and functions data, called arguments and performing
some tasks with them. Then the functions
Meaning of procedures
returns a value that indicates the results
A procedure is a block of Visual Basic of the tasks complete within the function.
statements enclosed by a declaration After the execution of a function, control
statement (function, Sub, Operator, Get, transfer to the main() method for further
and Set) and a matching end declaration. execution.
All executable statements in Visual
Syntax
Basic must be within some procedures.
A function procedure is a series of Private Function
Visual Basic statements enclosed by the procedureName([parameterList]) As
Function and End function statements. dataType
The function performs a task and then Statements
returns control to the calling function. Return expression
When it returns control to the calling End Function
function, it may also return a value. The
The statement’s syntax is Return
syntax of a function is FunctionName
expression, where expression represents
(arguments). There are two types of
the one and only value that will be
functions; Built-in functions and User
returned to the statement invoking the
defined functions as explained in the
function. The data type of the expression
following subsection.
must agree with the data type specified in
Functions the As dataType section of the function’s
Meaning of functions header.
The function is a separate group of Types of functions
codes that are used to perform a specific Built-in functions
task when the defined function is called
In this lesson, you will learn two very
in a program. Functions are like sub
basic useful internal functions of Visual
procedures, except they return a value
Basic the MsgBox ( ) and InputBox ( )
to the calling procedure. Functuions are
functions
248
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 248 23/01/2023 11:26:56


MsgBox ( ) function The first argument, Prompt, will display
the message in the message box. The

Computer Science
The objective of MsgBox is to produce
a pop-up message box that prompts Style Value will determine what type
the user to click on a command button of command buttons appear on the
before they can continue. The syntax is message box; refer to Table 4.8 for the
yourMsg=MsgBox (Prompt, Style Value, types of command buttons displayed.
Title). The Title argument will display the title
of the message board.

Table 4.8: Style Values


Style Value Named Constant Title of the message
0 vbOkOnly Ok button
1 vbOkCancel Ok and Cancel buttons
2 vbAbortRetryIgnore Abort, Retry and Ignore buttons
3 vbYesNoCancel Yes, No and Cancel buttons
4 vbYesNo Yes and No buttons
5 vbRetryCancel Retry and Cancel buttons
We can use named constants instead of integers for the second argument to make the
programs more legible. In reality, VB.NET will present you with a selection of name
constants from which you can choose one.
For example, the program code:
YourMsg=MsgBox (“Click OK to Proceed”, 1, “Startup Menu”) and yourMsg=Msg
(“Click OK to Proceed”. vbOkCancel, “Startup Menu”) are the same. YourMsg is a
variable that holds values returned by the MsgBox ( ) function. The type of buttons
the users click determines the values. It has to be set as an Integer data type in the
general declaration section procedure. Table 4.9 shows the values, the corresponding
named constant and buttons.
Table 4.9: The values, corresponding named constant and buttons

Value Named Constant Button Clicked


1 VbOk Ok button
2 vbCancel Cancel button
3 vbAbort Abort button
4 vbRetry Retry button
5 vbIgnore Ignore button
6 vbYes Yes button
7 vbNo No button

249
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 249 23/01/2023 11:26:56


InputBox ( ) function position or coordinate of the InputBox.
Computer Science

An InputBox ( ) function will display a User-defined procedures


message box where the user can enter a User-defined procedures are procedures
value or a message in the form of text. that the programmer defines. When you
The syntax is myMessage=InputBox define a procedure, you can give it a
(Prompt, Title, default text, x-position, name of your choice, but it should not
y-position). myMessage is a variant data be similar to the built-in function names.
type. Still, typically, it is declared as
String, which accepts the users’ message An argument can be passed by value or
input. The description of the arguments reference to a procedure. The mode of
is as follows: passing argument determines whether
the procedure can change the argument’s
Prompt - The message is displayed value in the calling code.
normally in the form of a question.
Passing argument by reference allows
Title - The title of the InputBox. a called function procedure to return a
Default-text - The default text that value to the calling procedure, and the
appears in the input field where users can underlying elements can be modified.
use it as their intended input, or they may On the other hand, passing an argument
change to the message the user wishes by value, the underlying elements cannot
to key in x-position and y-position - the be altered.

 ctivity 4.4: Passing parameters by value and by reference in a user


A
defined procedure
Create a new Windows Form project with a single form and add a button on the
form. Open the form’s class code and add the two subroutines shown in Figure 4.53.
Open the button’s code for the click event and add the code shown in Figure 4.54.
Run the application and study its behavior.

Figure 4.53: The subroutines for passing parameters.

250
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 250 23/01/2023 11:26:56


Computer Science
Figure 4.54: A program calling the subroutines.

 ctivity 4.5: Creating a program using a function to classify entered


A
number
Write a function to classify any entered number according to its sign and display
the phrase (negative number) when the number is negative, and the phrase (positive
number) when the number is positive, otherwise, display the phrase (neither positive
nor negative).
Program codes are as follows:

Figure 4.55: A program calling the subroutines.

251
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 251 23/01/2023 11:26:56


Exercise 4.7 Table 4.10: Core components of .NET
data providers
Computer Science

1. 
Describe the following functions
in brief, the Exp(), Round(), Asc(), No. Object Description
Right() and Sqrt(). 1. Connection Used for
2. 
Describe how parameters can be establishing a
passed. connection to
a specific data
3. In how many ways a function can source, e.g., MS
return value in VB.NET? SQL Server.
4. Describe the user-defined functions 2. Command Used for executing
with examples. commands against
5. Describe the procedure in VB.NET a data source.
3. DataReader Used for reading a
forward-only and
read-only stream
Linking Visual Basic .NET form of data from a data
to Data source source.
It is common for applications to require 4. DataAdapter Used for retrieving
persistent storage of data. This can be and saving data.
achieved through the use of files and
The .Net framework provides several
databases. The former is mostly used for
data provider for use when working
persistent storage of configuration data
with databases in VB.NET applications,
while latter is used for more elaborate
these are data providers for: SQL server,
data storage needs. This describes the Object Linking and Embedding (OLE)
how to work with databases in VB.NET. DB, Open Database Connectivity
The .NET framework provides facilities (ODBC), and Oracle. The choice of
for working with different databases. a data provider to use depends on the
These facilities are called data providers data source you are planning to use in
and are used to connect to a database your application as well as the nature
(data source), and running queries of your application (middle- or single-
(executing commands) for retrieving tier). For example, the ODBC provider
is recommended for middle- and single-
and modifying data in a data source. The
tier applications.
retrieved results can be processed by the
application or be shown to the user. Using the ODBC data provider in a
Data providers in .NET are made up VB.NET application
of four core objects as described in This section describes how to use the
Table 4.10. ODBC data provider to work with an
MS Access database. To do this we will

252
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 252 23/01/2023 11:26:57


need an existing MS Access database to work with. Complete Activity 4.6 to create
a simple Access database for this purpose.

Computer Science
Activity 4.6: Creating an employee database in MS Access

Create an Access database with one table for tracking students’ contact details (phone
number and email address). Name the table Contacts and add the following columns:
firstName, middleName, lastName, gender, phoneNumber, and emailAddress. Use
the default ID field as primary key. Save the database using the name employees.
accdb. The finished database should look similar to Figure 4.56.

Figure 4.56: Sample database

The next step after creating a test database is to create a new Windows Forms project
in Visual Studio and add connect to the database. After connecting to the database
the data will appear in the Data Sources window where we can drag the table into a
form. The following steps takes you on this process.

253
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 253 23/01/2023 11:26:57


1. Create a new Windows Forms project with a single form as shown in Figure 4.57.
Computer Science

Figure 4.57: A new Windows Forms

2. Select View > Other Windows > Data Sources to open the Data Sources
window as shown in Figure 4.58.

Figure 4.58: Accessing the Data Sources menu item

254
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 254 23/01/2023 11:26:57


3. On the Data Sources window that appears, click Add New Data Source. The

Computer Science
Data Source Configuration Wizard will open (see Figure 4.59).

Figure 4.59: Adding an new data source to the project


4. On the Choose a Data Source Type page select Database then click Next as
shown in Figure 4.52.

Figure 4.60: Choosing data source type

255
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 255 23/01/2023 11:26:57


5. On the Choose a Database Model page select Dataset then click Next
(Figure 4.61).
Computer Science

Figure 4.61: Choosing a data set model


6. On the Choose your Data Connection page, select New Connection to
configure a new data connection (Figure 4.62). The Add Connection dialog
box will open (Figure 4.63).

Figure 4.62: Creating a new connection

256
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 256 23/01/2023 11:26:57


Computer Science
Figure 4.63: A dialog box for adding connection

7. If Data source is not set to Microsoft Access Database File, select the Change
button to change it to Microsoft Access Database File (OLE DB). Select
Microsoft Access Database File then click Continue (Figure 4.64).

Figure 4. 64: Selecting a data source

257
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 257 23/01/2023 11:26:57


8. Choose Browse (Figure 4.63) to locate the employees.accdb file (Figure 4.65)
then click Open.
Computer Science

Figure 4.65: Locating a database file


9. Click Test Connection ( Figure 4.66) to test connectivity to the database.

Figure 4.66: Testing a connection to a database

258
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 258 23/01/2023 11:26:57


10. If the connection fails, recheck to make sure you performed previous steps correctly.
Click OK to close the test result dialog.

Computer Science
11. Click OK on the Add Connection dialog box.
12. Click Next on the Choose Your Data Connection page. The Save
connection String to the Application Configuration File dialog will be
displayed (Figure 4.67).

Figure 4.67: The Save Connection String to the Application Configuration File
dialog

 lick Next on the Save Connection String to the Application Configuration file
C
dialog. The Choose Your Database Objects window will be displayed (Figure
4.68).

Figure 4.68: Choosing database objects

259
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 259 23/01/2023 11:26:57


13. Expand the Tables node on the Choose your Database Objects page
Computer Science

and select the Contacts table to include it in the dataset then click Finish
(Figure 4.69). The table will appear in the Data Sources window as shown
in Figure 4.70.

Figure 4.69: An expanded form of a table Contacts

Figure 4.70: The table Contacts appearing in Data Sources window

260
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 260 23/01/2023 11:26:57


The next step after the data source is created is to add controls on the form for viewing,
adding and updating the data in the database. To do this, follow the following steps.

Computer Science
1. Drag the Contacts table from the Data Sources window and drop it on the
form (Figure 4.71).
A data grid with all the fields in the Contacts table will appear on the form
(Figure 4.72). You may need to resize the grid to make all fields visible.

Figure 4.71: Dragging table Contacts and dropping it on the form

Figure 4.72: A data grid with all the fields from the Contacts table
2. Run the application. The data in the Contacts table will be shown in the grid as
in Figure 4.73.

Figure 4.73: Data from the Contacts table displayed on the form

261
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 261 23/01/2023 11:26:57


Note that when you run the application you may get an error that the OLE DB
Computer Science

provider is not registered on the local machine. When this happens:


7. If you are using VS 2022, make sure you use a 64-bit version of MS Access. If
you are using an earlier version of VS use a 32-bit version of MS Access.
8. Make sure the current version of the MS Access database engine is installed on
your computer.
9. Make sure the “Prefer 32-bit” option in project settings (Project menu > Project
name Properties, where Project name is the name of the current project) on
the Compile tab is unchecked (Figure 4.74).

Figure 4.74: Unchecking the Prefer 32-bit setting

Exercise 4.8
1. List and describe elements that are contained in the connection string.
2. Weigh out the importance of testing a connection to a database before proceeding
to next steps in creating the connection to the database
3. State whether it is possible to use a form in Visual Basic .NET to delete or enter
data in a database. Justify your answer.
4. A database that was previously accessed from disk C was transferred to disk
E to guard against security breaches. However, following that modification,
nobody was able to access that database. Describe the steps you would take to
address the problem.

262
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 262 23/01/2023 11:26:57


Project window, which is used to show
files which are in the project.

Computer Science
Develop a program, which helps people
to purchase goods online. Draw objects, The properties window shows all
assign properties, attach code; use the controls a programmer can use
following as a guideline to your problem: to format the control to suit the
demand of the program. Moreover,
(a) Identify a problem we discussed about code editor,
(b) Analyse a problem which is used to write codes for
(c) Develop an algorithm to solve the different commands of the program
problem designed.
(d) 
Code the program using visual 4. In addition, the chapter covered on
basic and link it to the MS Access how to install the Visual Basic .NET
database or spreadsheet as your IDE, functions of tools found in the
data source ToolBox of the IDE, how to open
IDE, saving a Visual Basic .NET
(e) Test the program program in the first time where you
(f) Document the program click save and then, save the form
and write the name of the form.
Also, we learned how to create our
Chapter summary first simple program in VB.NET,
1. This chapter has covered the major “My first VB.NET program” as our
parts of Visual Basic programming, first example.
providing discussion on each 5. After introducing VB.NET, the
key concept. Our discussion was chapter discussed data types
classified into subcategories. We including numeric and non-numeric
started on the general concept of data types. Numeric data types
Visual Basic .NET by defining involve mathematical conversions
it as a programming language such as bytes and integers as well
that lets users create programs as non-numeric data types such
by manipulating program as Boolean, String and Date. We
elements graphically rather than covered decision control structures
by specifying them textually. such as branching and iteration.
Advantages and disadvantages of Under iteration control structures,
Visual programming were outlined. we learned the While, Do and For
2. Visual Basic .NET tools, their Each loops.
uses, as well as the use of forms 6. The chapter ended with working
as the main part of designing with data sources. In this section,
VB.NET programs were discussed. we learned how to connect a
Controls such as CheckBox, VB.NET program to a database by
CommandButton, and TextBox focusing on the Microsoft Access
used in VB.NET applications were database. Through a data source
described. that we created, we were able
3. We also discussed about the project to manipulate data in an Access
database.

263
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 263 23/01/2023 11:26:57


Revision exercise 9. Design a form containing a specific
title such that when we click on
Computer Science

1. Develop a Visual Basic program


that returns the integer part of the command1, the colour of the font
real value 2.67 and stores the value will change, and when command2
in variable x. is checked, the size of the font will
change.
2. Write the Visual Basic programs
that read two numbers using the 10. Design a form containing the shape
input box and display the largest. and command buttons “what is
this”, such that when you click on
3. Create a Visual Basic program the command button, the name of
that reads three numbers from text this shape appears in the message
boxes and displays the largest on box.
the form label.
11. Enter a text in label1 such that this
4. Write a VB program that displays a text is copied to label2 after clicking
Day’s name in English in MsgBox on the command button “copy” and
if the user types the number of a delete from label2 after clicking on
day in a week. the command button “delete”.
5. Write a Do loop program that will 12. Design a form containing a
write numbers between 1 and 20 on command button such that when
the screen, and then stop. Save the we click on a command, form2 will
project as sample4. appear, and form1 will disappear.
6. Examine the following formulas 13. Design a form “at run stage” the
and write programs that will solve title of form1 will be changed to
them “visual basic”, and the back color
i. E = MC2 of form1 will change too.
ii. F = 9/5*C + 32 14. Design a form with two shapes, red
7. Write a Visual Basic program to and blue, and write code to replace
display the following form. The the colour every between two
word to be displayed is “Have a shapes.
nice day”. 15. Design a form containing a list box
8. Create a program that initially and two command buttons:
displays a grey circle (that is, (a) Add: Add the element to the
without any distinctive fill color). list from the input box.
The program will include a pull- (b)  Delete: To delete the list
down menu allowing the user to elements
change the circle’s fill colour to
red, green or blue and clear the fill 16. Design a form with three menus
colour (thus restoring the original and a label with a specific title.
colour). The program will include The menus contain sub-menus as
two objects, namely a shape (the follows: colour: red, blue, green,
circle) and a command button, used style: underline, bold, italic, size:
to end the computation. 10, 20, 30, then write the code for
each command.

264
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 264 23/01/2023 11:26:57


Computer Science
Chapter
Five Computer security and privacy

Introduction
Data and information is valuable resources in digital age. If it is not well managed
and protected may results into organisations functions and its operations jeopardised.
In this chapter, you will learn the concept of computer security, measures taken
to prevent loss and authorised data access; concepts of physical security, and
troubleshooting. The competence gained will enable you to be able to used data and
information ethically and responsibly.

Think about the following: Integrity and Availability (CIA) as


shown in Figure 5.1. The organisation
In the modern world, an unauthorized must ensure the security of their
user can access an individual’s data information systems and resources.
stored in a centralized database The information system resources
management system without the include hardware, software, firmware,
consent of that specific individual or information/data, and transmission
organization. Think of three negative media. The interpretations of these
impacts of the unauthorised user three aspects (CIA Triad) vary, as do the
accessing this personal data. Suggest contexts in which they arise.
appropriate measures to prevent this
situation.

The concept of computer security


This section presents concepts and
characteristics of computer security.
Security is the state of being free from
danger or threat; whereas, computer
security is defined as measures taken
to protect computer resources from
damage or stolen. Also, Computer
security is defined as the protection of
Figure 5.1: CIA triad (Confidentiality,
an information system and it comprises
Integrity, and Availability)
three major aspects; Confidentiality,

265
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 265 23/01/2023 11:26:57


The next paragraphs present description and services are accessible to authorised
Computer Science

of CIA triad. users all the time. Availability is an


Confidentiality: This ensures that important aspect of reliability design
unauthorized user does not get access because an unavailable computer
to unauthorised computer resources. resource is at least as bad as no computer
Keeping information secret arises from resource. The aspect of availability
using computers in institutions with relevant to security is that, someone may
sensitive information such as government deliberately arrange to deny access to
and industry. You can protect computer data or service by making it unavailable
resources from unauthorised access or unusable. For example, suppose user
by using an access control mechanism A has compromised the ajira portal or
such as using cryptography to transform Zanajira portal, portals designed by the
data making it incomprehensible. A Government of Tanzania and Zanzibar,
cryptographic key controls access to respectively, to handle new employment
the untransformed data, but then the applications by blocking other users
from submitting their curriculum vitae
cryptographic key becomes another data
for the newly advertised position. If user
to be protected.
A can supply information not generated
Integrity is the ability to ensure that the by these portals, then the intended
system and its data have not suffered service has been compromised, and the
unauthorised modification. Integrity system services are unavailable. Denial
protects the operating system, hardware of Service (DoS) attacks can be used to
and applications from being altered by block the availability of the ajira portal.
unauthorised individuals in and outside The DoS attacks are difficult to detect
the organisation. It also protects against because the analyst must determine if the
modification, editing or changing unusual access patterns are attributable
confidential computer resources to to deliberate manipulation of resources
only authorised individuals. Integrity or the environment.
can be defined as the trustworthiness Furthermore, the above three security
of computer resources, usually phrased elements can be expanded to include
to prevent improper or unauthorized two more parameters: authentication and
change. Therefore, adequate access authorization. Authentication ensures
controls will generally stop the break-in that computer users are validated to
from the outside as well as inside and confirm whether the identity claim is
may track all activities performed by the correct. Authentication is the process
computer users. or action of verifying the identity of a
Availability: Availability refers to computer user or process. The external
ensuring that systems work promptly entity must provide information to

266
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 266 23/01/2023 11:26:57


enable the system to confirm its identity. 3. 
Destruction of an organisation’s

Computer Science
This information comes from one or reputation or branding
more of the following: 4. 
Phishing attacks may expose
1. What the entity knows (such as critical computer resources to
passwords or secret information) unauthorised users
2. What the entity has (such as a 5. 
Software vulnerabilities could
badge or card) allow an attacker to gain access to
3. What the entity is (such computer resources.
as fingerprints or retinal
characteristics)
4. Where the entity is (such as in Activity 5.1: Read the
front of a particular terminal) scenario about computer
5. What does the entity do (gain/ security and answer the
movements recognitions) questions that follow:
Also, the authentication process Juma lives with his parents in Dodoma.
consists of obtaining the information Juma’s father owns an Apple smartphone,
from an entity, analysing the data, and generally known as iPhone, whereas Juma’s
determining if it is associated with that mother uses an Android smartphone with
entity. This means that the computer the Android operating system.
must store some information about the
1.  ith the help of Internet, in your
W
entity.
own words, compare the security
Authorisation allows us to specify features available in Android and
whether the party should be allowed iPhone smartphones. Give at least
or denied access. Once we have two main security features in each
authenticated the party in question, of the above smartphones.
authorisation enables us to determine
precisely what they are allowed to do. 2. 
Write down the step-by-step
We typically implement authorization procedures that you will use to
using an access controls mechanism. ensure confidentiality, integrity,
availability, authentication, and
authorization for each of the above
Challenges of computer security
phone categories.
The following are some challenges of
computer security: 3. What will happen if confidentiality,
1. Damage or loss of computer integrity, availability, authentication,
resources and authorization are missing from
2. Requires high investment cost to any of the above phone categories?
achieve total computer security

267
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 267 23/01/2023 11:26:58


 ctivity 5.2: Creating a
A Data protection
user account and password
Computer Science

Fundamentals of data protection


conforming security policy
There are three fundamental components
Create a user account in the windows of data protection, which are discussed
operating system. Ensure the policy as follows.
to change the password in the login
is active, set the minimum password Data: This is one of the core components
character to be 8, and set the password of any information system. Data should
policy for a password to include be protected against unauthorized access
uppercase, lowercase, special character, to maintain confidentiality, integrity,
and numbers. availability and privacy.

 ctivity 5.4: Read the


A
scenario below and answer
 Activity 5.3: Encrypting the the questions that follow:
folder using the VeraCrypt
software tool. One day Neema got sick and decided
to go to a nearby health centre for a
Resources: general medical check-up. The health
A VeraCrypt software tool, a user centre uses a health information system
manual, a computer with Windows 10 for patient registration, consultations,
Operating system or any software tool laboratory, and pharmacy. Neema
supporting VeraCrypt functionalities provided her personal information in all
Procedure: stages, and the communication between
the doctor and laboratory technician was
1. Download VeraCrypt open-source
automated.
tool and install it on a computer
Afterwards, the doctor sent the
2. Read its user manual to learn how medication information to the
to encrypt files and folders pharmacist, and Neema was instructed
3. Create files in windows by the doctor to visit the pharmacy
4. Put the file in the newly created to take her medication. Two months
folder later, Neema found her confidential
information printed on a piece of paper
5. 
Encrypt the folder using the
used for packaging bites in her street.
VeraCrypt tool by following the
steps in the user manual 1. Identify confidential information
that requires protection from public
6. 
Write your observation on the access or unauthorized users.
encrypted folder and its contents
2.  How will data protection policy
help in protecting Neema’s personal
data?

268
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 268 23/01/2023 11:26:58


Data protection: This is a set of methods Data privacy
and skills used to secure data from

Computer Science
Data privacy deals with properly
unauthorized access. Data protection
handling data, and it is the controlling
also safeguards private and important
information from compromise, process around sharing data with a third
corruption, and loss. The demand for party so that only authorized users can
data protection is also fueled by more access it. Data privacy is a set of rules
data generated in the current digital that govern how data is acquired and
world. The data source ranges from managed based on its sensitivity and
information systems, social media, and value. Data privacy is applied to Personal
service automation. Health Information (PHI) and Personally
A data protection policy: This is vital for Identifiable Information (PII). It includes
any organization that collects, handles, financial data, medical records, social
or stores sensitive data. It provides security or ID numbers, names, birth
guidance that prevents data loss, theft, dates, and contact information.
and corruption and helps to minimize
damage caused by a breach or disaster. Concerns over data privacy apply to all
sensitive information that firms handle,
Data protection policy including customers, shareholders,
A data protection policy (DPP) is a and employees. This information
security policy dedicated to standardising is frequently critical in corporate
and controlling data use, monitoring, operations, development, and finances.
and management. The main goal of
Data privacy helps to ensure that
this policy is to protect and secure all
data consumed, managed, and stored sensitive information is only available
by the organization. It is not required to authorised users. It secures data from
by law, but it is commonly used to being used by criminals maliciously and
help organizations to comply with data assists enterprises in meeting regulatory
protection standards and regulations. requirements.
Data protection policies should cover
Computer privacy
the following aspects:
1. The scope of required data protection Computer privacy is just the safeguard
of a computer whereby it is controlled
2.  Data protection techniques and
from being used by other persons who
policies applied by relevant parties
such as individuals, departments, are not authorised. Privacy should be
devices, and the IT environment maintained when using computers
and information systems. The use of
3. Any applicable legal or compliance
requirements for data protection an information system should be kept
safe and secret, and no one should be
4.  The roles and responsibilities
allowed to engage in illegal activity
related to data protection,
including data custodians and roles while accessing that information.
specifically responsible for data
protection activities

269
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 269 23/01/2023 11:26:58


Data protection and privacy regulation services. EPOCA was established to
Computer Science

International and national data make provisions for the enactment of


protection regulation electronic and postal communications
law to keep abreast with developments
Data protection and privacy regulations in the electronic communications
vary between countries, states, and industry. Tanzania also has the
industries. For example, China created a Electronic Transactions Act of 2015
data privacy law that went into effect on (ETA) and the Cybercrime Act. The
June 1, 2017, and the European Union’s ETA provides the legal recognition of
(EU) General Data Protection Regulation electronic transactions, e-Government
(GDPR) went into effect in 2018. services and the use of Information
China’s data privacy law was designed to and Communication Technologies in
protect the personal data of individuals the collection of evidence; whereas the
and increase data security. It specifies Cybercrime Act of 2015 makes provisions
the scope of personal information; for criminalizing offences related to
clarifies the legal bases for processing computer systems and Information
personal information; lays down the Communication Technologies to
obligations and responsibilities imposed facilitate the investigation, collection,
on processors, and imposes stringent and use of electronic evidence in
requirements on data localization, Tanzania. Compliance with one set
safeguarding China’s interests in the of regulations does not guarantee
case of cross-border transfer of personal compliance with all laws. Additionally,
information. Apart from the Personal each directive contains numerous
Information Protection Law, China also clauses that may apply to one case but
has other laws such as Data Security not another, and all rules are subject to
Law and Cyber Security Law, to ensure change. This level of complexity makes
cyber security and data protection. it challenging to implement compliance
consistently and appropriately.
On the other hand, GDPR was designed
The application of these laws criminalizes
for the protection of natural persons
and penalizes several cyber activities
related to processing the personal data in
such as data espionage, publication
the European Union. Also, it enhances
of child and adult pornography. Others
how people access their information and
include publication of pornography,
limits how organisations and companies
publication of false, deceptive, and
must use personal data in an integrity
misleading information, production
friendly way.
and dissemination of racist and
Tanzania has enacted the Electronic and xenophobic material. In addition,
Postal Communications Act of 2010 initiating transmission of or re-
(EPOCA), which provides security transmission of unsolicited messages and
and protection guidance for Tanzania’s violation of intellectual property rights
electronic and postal communications and other types of cybercrimes constitute

270
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 270 23/01/2023 11:26:58


activities that can be criminalised and (b) 
It protects organizational assets

Computer Science
penalised. The cybercrimes Act 2015, from fraud cases such as hacking,
came after significant impacts such as phishing, and identity theft.
financial loss, fraud and cyberbullying to (c) It gives consumers more confidence
the public and other stakeholders. Non- to buy items or things online. As
compliance may result in reputation a result, it increases revenue for
damages and monetary fines, depending enterprises both offline and online.
on the violation as instructed by each
law and governing entity. Data protection technologies
There are various technologies
A
 ctivity 5.5: Searching for and practices to protect data in an
cybercrime Acts and related organisation. The most commonly used
regulations methods and technologies are as follows:
Resources: Data discovery: This entails determining
Library resources, internet connectivity, which data sets exist in the organisation,
the Tanzania cybercrime act and other which are essential to the organisation
related cyber-related regulations. role, and which contain sensitive
Procedures: information that may be subject to
compliance regulations.
1. Visit a library or search the current
Tanzania cybercrime act on the Data Loss Prevention (DLP): A set
Internet. of strategies and tools that you can
2. 
Study various laws that govern use to prevent data from being stolen,
information security. lost, or accidentally deleted. Data loss
prevention solutions often include
3. 
Write one section and its sub-
several mechanisms to protect against
sections of the act stating its phrase
and recover from data loss. Most
and explain how it addresses the
cyber-related activities/ offences in modern storage equipment with built-
the society in data protection provides built-in disk
clustering and redundancy.
Encryption: Changes the data content
Importance of data protection
into non-meaningful texts and uses an
Data protection has the following algorithm that can restore the original
importance: content using the correct encryption
(a) 
The essential values of data key. It protects information from being
protection are safeguarding and accessed by rendering it impossible to
making available data under all read even if the data is stolen. More
circumstances. That describes information can be found in the data
the operational backup of data encryption guide.
and Business Continuity Disaster
Recovery (BCDR).

271
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 271 23/01/2023 11:26:58


Storage with built-in data protection: (such as computers, servers, networks,
Computer Science

Modern storage equipment have disc and mobile devices.) from being
clustering and redundancy to ensure compromised or attacked. Cybersecurity
data recovery during a disaster. involves identifying the critical data,
Screenshots to backups and snapshots: where it resides, its risk exposure, and
These are complete images of a protected the technology you must implement to
system, including data and system files. protect it.
The image can restore an entire system Cybersecurity, as a subset of information
to a specific time in the past. security, is the practice of defending
your organization’s cloud, networks,
Relationship between information computers, and data from unauthorized
security, cybersecurity, system digital access, attacks, or damage
security, and network security by implementing various defence
These terms sometimes are used processes, technologies, and practices.
interchangeably, but it depends on the With the countless sophisticated
area to be the emphasis for protection. Let threat actors targeting all types of
us look at the meaning and relationship organizations, your IT infrastructure
must be secured to prevent a full-
between these terms:
scale attack on your clouds, networks,
Information security: Information or endpoints and risk exposing your
security (also known as InfoSec) company to fines, data losses, and
ensures that both physical and digital damage to reputation.
data are protected from unauthorized
Network security: It is a subset of
access, use, disclosure, disruption,
cybersecurity which consists of the
modification, inspection, recording, or
policies, processes and practices
destruction. Information security differs
adopted to prevent, detect and
from cybersecurity in that, InfoSec aims
monitor unauthorized access, misuse,
to keep data safe in any form, not only
modification, or denial of a computer
data in digital format. For example,
network and network-accessible
suppose you have a paper document. In
resources. Network security involves
that case, securing this document is an
securing data access in a network, which
information security responsibility. Still,
the network administrator controls.
if you scan this document and transfer
Figure 5.2 shows the difference between
it into a digital file, this digital file’s
information security, computer/cyber
security is a cybersecurity responsibility.
security, system security and network
Cybersecurity: It is all about protecting security.
data that are found in electronic form

272
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 272 23/01/2023 11:26:58


Computer Science
Figure 5.2: Relationship between network security, system security, computer
security/cybersecurity and information security

Identification, authentication, officers and offices like hospitals,


accountability and non-repudiation registering for treatment, registering for
Identification school, and performing various other
tasks. In many cases, identification cards
Identification is the process that verify our identity while doing these
identifies uniquely a user of a system. things.
Identification is merely a claim of
identification and does not indicate that Authentication
the claim is correct or that any benefits Authentication is the procedure for
associated with the identity are awarded determining whether or not a claim of
if proven accurate. identity is genuine. It is vital to remember
The typical examples are that you can that authentication and verification are
bring out your identity cards from jobs not the exact words and that verification
or schools, a driver’s license card in is a much weaker security test than
the Tanzania vehicle, a motor vehicle authentication. Identity verification is a
insurance card, a national ID card, birth step beyond identification, but it is still a
certificates, academic certificates, and step short of authentication. For example,
an NHIF card for health insurance. Such you are asked to show a driver’s license,
cards are routinely used to prove our NHIF card, birth certificate and National
identity, whether genuine or accurate, identity card, typically used for identity
when making purchases, dealing with verification rather than authentication.
government officials like Traffic Police You can use a variety of aspects to

273
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 273 23/01/2023 11:26:58


perform authentication. Authentication A security model’s principal goal:
is an essential part of something you Provides the necessary understanding
Computer Science

have, something you do, and where you for the successful and effective
are. When you are prompted to enter the implementation of essential protection
PIN from the ATM card associated with requirements.
the card, you complete the transaction’s Information security models: These are
authentication portion. These are some procedures used to validate security
of the identification and authentication policies. They are designed to provide
methods used in daily life. specific instructions for a computer to
Accountability perform a security program’s critical
Accountability refers to the ability of a security processes, procedures, and
system to deliver audit trails of every concepts. These models might be either
transaction. The system managers must intuitive or abstract. Security models,
be able to offer information on every for example, define the road map for
transaction that has taken place because operating system security.
they are subject to external scrutiny. These security models are vital
Hence, the action impacting security components that must be considered
may be traced back to the accountable when engineering security systems and
party. Audit trails must be stored in policies in your organization. They
selective manner and protected to ensure should define the access rules necessary
their integrity. to instantiate the said policy and define
the entities (subjects governed by an
Non-repudiation organisation’s security policy).
Non-repudiation is the ability to Five security models: Define the rules
ensure that computer/network users or and policies that govern integrity,
participants do not deny (repudiate) their confidentiality, and data protection.
actions. Hence, assurance of security Confidentiality through information
service that provides proof of service, integrity and access controls is the main
origin and delivery is done by non- focus and reason for the security model
repudiation. In real life, the sender may implementation.
deny ownership of the exchanged digital The following are examples of security
data that originated with them. This models:
service ensures that digital data cannot
be repudiated by providing difficult-to- (a) Bell-LaPadula
deny proof of origin via digital signature (b) Biba
and encryption algorithms. (c) Clark-Wilson
Models of information security (d) Chinese Wall model
A security model: It is a framework that (e) Harrison–Ruzzo–Ullman.
determines how security is implemented
Bell-LaPadula (BLP)
by implementing security policies.
Without efficient and robust security The Bell-LaPadula (BLP) security model
models, no organisation can secure is also, called the multi-level model,
sensitive information or data. was proposed by Bell and LaPadula for

274
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 274 23/01/2023 11:26:58


enforcing access control for computer which are Integrity Verification
systems. In this model, each subject Procedures (IVPs) and transaction

Computer Science
(user) and each object (resources such procedures (TPs). The IVP’s job is to
as, files) is assigned one of the security ensure that the TPs produced by CDIs
levels: top secret, secret, confidential, are in a valid state, and all TPs must be
classified and unclassified. Therefore, certified to make a proper transformation.
the unclassified user can not access Authorized TPs can only manipulate
data at the upper levels ( classified, CDIs. The Clark-Wilson model
confidential, secret and top secret), and enforces integrity goals by using access
the files tagged as top secret can not triple (subjects, software transaction
be accessed by lower levels (secret, procedure and object), separation of
confidential, classified and unclassified). duties, and auditing. It uses well-formed
This kind of access control is also transactions (through access triple) and
called mandatory access control, which separation of user duties.
restricts access to an object based on the
sensitivity of the information contained Chinese Wall model
in that object and formally authorises The Chinese Wall model’s theory is based
the subject to access information based on a conflict of interest, which states that
on its sensitivity. a single user should not have access to
The Bell-LaPadula model has two confidential information belonging to
limitations: two separate interested and participating
1. It provides confidentiality only ( no stakeholders. User behaviour influences
integrity and authentication). access control policies. In other words,
2. 
It provides no methods for the once one side’s data is accessed, the
management of classification (it other side’s data becomes inaccessible
assumes all data are assigned with or unavailable.
a classification and will never Harrison–Ruzzo–Ullman (HRU)
change).
The BLP model lacks mechanisms for
Biba model changing access rights and deleting
subjects and objects due to the results.
The Biba security model was published
The HRU model addresses these issues
to handle integrity issues which BLP
by defining an authorization system
Model did not address. The goal of the
Biba model was to prevent unauthorised to assign access rights and verify
users from making modifications to compliance with any policy, preventing
particular computer resources. unauthorized access.

Clark-Wilson Attacks
The Clark-Wilson model distinguishes An attack is an information security
between two types of objects, namely threat involving the unauthorized
Constrained Data Items (CDIs) and acquisition, modification, destruction,
Unconstrained Data Items ((UDIs). It removal, implant, or disclosure of
also addresses two types of transactions, information.

275
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 275 23/01/2023 11:26:58


Types of attack etc., between two individuals who are
communicating. It can be performed
Computer Science

You can categorise the different forms


of attacks and group them into four either when data are in motion or
categories: interception, interruption, stationary. In the interception, the attack
modification (alteration), and fabrication. occurs before the information reaches
the intended recipient. Interception
Interception attacks, when executed correctly, can
Interception is the act that occurs when always be challenging to detect. It is
an individual who is not authorised gets an attack on confidentiality. Figure 5.3
access to files, data, conversation, e-mail, shows the interception attack.

Figure 5.3: Interception

Interruption
This occurs when the individual who is not authorised to access data gains access to
information between two communicating individuals making the services unavailable
temporarily or permanently. The person interrupts the information such as, files,
conversations, E-mails, etc., by blocking communication between two individuals,
making the services unavailable, as shown in Figure 5.4. Interruption is performed
when the data are in either motion or stationary. It is an attack on availability.


Figure 5.4: Interruption

276
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 276 23/01/2023 11:26:58


Modification

Computer Science
This is editing the content of information from an individual without the person or
organisation’s consent. This is referred to as an integrity attack because the data
integrity is damaged. When the data is compromised, this can cause a severe problem
for an individual or organisation. Figure 5.5 shows the modification attack.

Figure 5.5: Modification


Fabrication
Fabrication attack refers to the act of generating incorrect data and insert it alongside
authentic data. This involves generating data, processes, communications, or other
similar activities within a system. Fabrication attacks initially affect integrity but
can also be considered availability attacks. It is also attack on authenticity. The
fabrication attack is illustrated in Figure 5.6.

Figure 5.6: Fabrication

277
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 277 23/01/2023 11:26:58


Threats Viruses
Computer Science

A threat is defined as something that A virus is a piece of code capable of


has the potential to harm a computer or replicating itself and typically has a
create negative consequences. Threats in negative impact, such as distorting the
cybersecurity are commonly specialized system or destroying data. It spreads by
to specific programs or operating inserting multiple copies of its own into
systems. A virus, for example, may pose the programs or data files that it infects.
a risk to a Windows operating system, User input usually activates viruses, such
but it is unlikely to have any effect on a as opening a file or running software.
Linux operating system.
Viruses are divided into two categories,
Man-made threats which are compiled viruses and
These are threats that can harm computer uncompiled scripting viruses.
software and hardware; resulting in a For example, an operating system
malfunction of the computer system.
executes a compiled virus. File
Man-made threats involve the following:
infector viruses attach themselves to
Malware executable programs such as, boot
Malware is a term used to describe sector viruses, which infect the master
malicious software, sometimes called boot records of hard drives or the
malicious code. boot sectors of removable media and
Malware intends to disrupt, damage, or multipartite viruses, which combine the
gain unauthorized access to a computer characteristics of file infector and boot
system. It is purposefully designed to sector viruses.
harm, disrupt, steal, or do something Scripting viruses infect scripts that
“wrong” or illegal with data, hosts, or are understood by scripting languages
networks. Examples of malware include processed by Operating System
viruses, worms, trojan horses, logic services, while macro viruses abuse
bombs, and spyware. the capabilities of applications’ macro
Malware comes in various aspects, programming language to infect
each with its method of infecting and application documents and document
spreading in computers. Malware can formats.
infect computers by being packaged Worms
with other programs or attached to files
such as macros. A worm is a self-replicating identity
program that runs without the user’s
Types of malware (malicious code) knowledge. Worms are categorised
The common types of malware are into worms that infect networks and
viruses, worms, Trojans, Bots, Logic worms that infect bulk mail. A network
bombs, Rootkit, spyware, and adware. service worm spreads by infecting other
Some descriptions of types of malware systems by exploiting the vulnerability
are as follows: of a network service.

278
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 278 23/01/2023 11:26:58


Trojan horse administrator from a remote location.
Rootkits are extremely sophisticated

Computer Science
A Trojan horse is a self-contained,
non-replicating program that serves a because they make hackers extremely
malicious intent despite its innocent difficult to locate. They are frequently
appearance. It masquerades as an used to penetrate and imprison other
authentic software or application computers as zombies, forcing them to
to capture user information such attack other machines, distribute spam,
as username, password, biometric or steal passwords. When attempting
information and passcodes. The to track down the creator of a rootkit,
information captured by hackers can the search usually ends with the first
be used to perform other malicious computer used as a zombie while the
activities. hacker remains undetected.
Logic bombs Bots
Logic bombs are malicious programs Bots, also known as Botnets, are
typically installed on a design by an automated processes interacting with
authorized user. They are composed of other network services. They are derived
some code or a program that remains from the word “robot.” Bots frequently
inactive for an extended time, waiting automate tasks and provide information
for a logical condition to be met before or services that humans would otherwise
executing its malicious payload. perform. Bots are typically used to gather
Spyware information (such as web crawlers) or to
interact with instant messaging (IM),
Spyware is a sneaky program that Internet Relay Chat (IRC), or other
attempts to steal your information such web interfaces automatically. It can
as credit card, banking information, also be used to interact with websites
web browsing data, and password to
dynamically. Bots can be used for either
various accounts. While spyware is not
good or evil purposes. A malicious bot is
intended to cause harm, it can harm
a self-propagating malware that infects
your computer’s performance over time.
a host and connects to a central server
Spyware is typically bundled with free
that serves as a Command and Control
software and installs itself alongside
(C&C) centre for an entire network of
the program you intend to use. Sudden
changes in your web browser such as, compromised devices, or “botnet.”
redirections of your search attempts Phishing attack
and the frequent display of pop-ups, are Phishing attacks use fake communication,
among the signs of spyware.
such as an email, to trick the receiver
Rootkit into opening it and carrying out the
A rootkit can be a single program or a instructions inside, such as providing a
group of programs designed to take credit card number. “The goal is to steal
complete control of a system. Hackers sensitive data like credit card and login
use this type of malware to gain access information or install malware on the
to all of the capabilities of a system victim’s machine.”

279
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 279 23/01/2023 11:26:58


The term “phishing” comes from the analogy of early internet criminals using lures
to “fish” for passwords and financial information from a large sea of unsuspecting
Computer Science

internet users. The prefix “ph” in this terminology has gradually faded. Phishing
refers to attempting to contact a victim via email or phone while impersonating
a legitimate institution to trick the individual into providing sensitive information
such as banking information, credit card details, and passwords. Nevertheless, the
individual’s data can then be used to access their account, resulting in identity theft
and financial loss. Figure 5.7 shows a phishing attack.

Figure 5.7: Phishing attack

Man in the Middle Attack messages allow the hacker’s MAC


Man in the Middle Attack (MITM) address to be successfully linked to an
attacks when a visitor uses an unsecured IP address of a genuine user or an entire
public network. Here, attackers insert server in a targeted network. Once the
themselves between the visitor and the hackers link with MAC address to a
web, and then use malware to install legitimate IP address, you will be able to
software and use data maliciously. receive all data which other users send
to the IP address. When the user/victim
A man in the middle attack can be carried communicates with another user, the
out after a hacker performs Address attacker inserts himself in the middle of
Resolution Protocol (ARP) spoofing, the conversation by sniffing packets and
which is done by sending false ARP producing MITM. This action involves
messages over the managed network utilities used to attempt MITM attacks,
to penetrate the local area network. such as SSL Strip, burp suite, and
When done correctly, the forged ARP browser exploitation framework.

280
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 280 23/01/2023 11:26:58


Figure 5.8 illustrates man in the middle attack.

Computer Science
Figure 5.8: Man in the Middle attack

Denial of Service attack


Denial of Service (DoS) is an attempt by attackers to deny service to the intended
purposes of the service. It occurs when a computer resource is overburdened with
more requests than it can handle, consuming all available bandwidth and resulting
in server overload, as illustrated in Figure 5.9.
DDoS is a malicious attempt to disrupt the normal operations of targeted computer
systems or services by overwhelming the target or its surrounding infrastructure
with a flood of requests. The affected computers will not be able to communicate as
intended.
The most popular DDoS attacks are the Ping of Death, smurfing, teardrop, and the
land. DDoS attacks can be local, causing LAN machines to fail. They can initially
come hundreds of miles away on the Internet, equating to trying to penetrate
electronic attacks.

Figure 5.9: Denial of Service

281
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 281 23/01/2023 11:26:58


SQL Injection attack Password1 = request.
Computer Science

SQL Injection is a type of cyber-attack in POST[‘password’]


which a hacker manipulates a database # SQL query vulnerable to SQLi
with SQL (Structured Query Language)
sql = “SELECT id FROM users
code to access sensitive critical data.
WHERE username=’” + username1 +
SQL statements are injected as input
“’ AND password=’” + password1 + “’”
strings. SQL injection is a severe and
vulnerable cyberattack that can lead to # Execute the SQL statement
a high level of compromise, typically
database.execute(sql)
allowing the running of any database
query. It is a web-based application attack These input fields are vulnerable to SQL
that connects to database backends and Injection. For example, attackers can
sidesteps firewalls. Consider the SQL use a trick involving a single quote and
Injection attack, for example, a login set the password1 field to:
screen with two input fields (Login and
password’ OR `1`=`1`
Password) whose values are supplied by
the user. When a user clicks the Login As a result, the database server runs the
button, a request to access the website following SQL query:
is sent to the server and the provided SELECT id FROM users WHERE
credentials. Another example is the username=’username1’ AND
HTML code display for the HTML from password=’password1’ OR `1`=`1’
the server-side Login and Password
input fields are accessed here via the Because the OR 1=1 is always evaluated
‘$fLogin’ and ‘$fPassword’ variables, to the TRUE statement, the entire
respectively. WHERE clause will be TRUE and
returns the first id from the user’s table,
This is a simple example of gaining
regardless of username and password.
access with a username and a password.
The first user id in a database is very
In this example database has a table
often the administrator. In this way, the
named users with the following
attacker bypasses the authentication and
columns: id, username and password.
gains administrator privileges. They can
# Define POST variables also comment out the rest of the SQL
Username1 = request. statement to control the execution of the
POST[‘username’] SQL query further (See Figure 5.10).

282
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 282 23/01/2023 11:26:58


Computer Science
Figure 5.10: SQL injection attack

Exercise 5.1.

Answer the following question


1. Briefly explain five security models.
2. Describe four types of attack payload.
3. Show steps by steps how to conduct SQL injection.
4. Discuss prevention measures for SQL Injection Attacks.
5. Apart from username and password, which variables are candidates for SQL
Injection?
6. I am using client-side JavaScript code for checking user input. Is that not
enough? Why?

Zero-day exploit
A zero-day attack, also known as Day Zero, is an attack that takes advantage of
a severe possible software security vulnerability that the vendor or developer is
unaware. To limit the threat to software users, the software developer must act
quickly to address the fault. One example is the Microsoft Exchange attack that
compromised hundreds of thousands of organizations. Figure 5.11 illustrates a zero-
day exploit attack.

283
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 283 23/01/2023 11:26:58


Computer Science

Figure 5.11: Zero-day exploit Attack (Kumar, V. & Sinha, D (2021)

Ransomware with and IP addresses that computers


Ransomware is malware created to stop and routers possess. DNS poisoning is
a user or organization from downloading one of several techniques attackers use
or accessing data on their computers. to redirect traffic to an individual website
Once installed on your computer, it that can be used later to steal personal
encrypts all of your files and holds your information. Here the attacker or hacker
data hostage until you pay the ransom needs to be on the same network as the
demanded by the hacker. Ransomware target. To acquire access to that network,
spreads viruses, and even if you pay the a hacker can simply search for a weak
ransom, there is no guarantee that your password on a connected machine
data will be recovered. connected to that network, which can
even be done remotely. An example of
DNS Attack a DNS attack is shown in Figure 5.12.
The Domain Name System (DNS) For example, the scenario whereby
attack redirects someone to a malicious an attacker force executing a DNS
website where a hacker can quickly poisoning attack:
harvest private information or user First, the attacker creates a phishing
credentials using a website’s IP address. website. It spoofs a bank that we will
Correspondingly, DNS is in charge of call Mwananchi Bank. The attackers
converting domain names (such as www. want to lure users there, so they can steal
morogorotc.ac.tz) that you are familiar their usernames and passwords and use

284
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 284 23/01/2023 11:26:58


them on the actual bank website. In this case, attackers create a DNS server and put
two false records in the DNS cache. The first is for the Mwananchi Bank website,

Computer Science
pointing to a fake site rather than the accurate bank site.
The hacker’s DNS server then offers to perform a zone transfer, exchanging all
data with the target server. This information includes the forged Mwananchi Bank
address. The target DNS server has an entry for Mwananchi Bank. Instead of the
actual Mwananchi Bank website, the target DNS server has access to Mwananchi
Bank, pointing to the hacker’s website. If users on that Network enter the URL for
Mwananchi Bank, their DNS server will redirect people to the hacker’s site.

Figure 5.12: DNS Attack

Natural threats
All threats that occur naturally without human intention, such as earthquakes, fire,
cyclones, and floods, pose additional threats to IT systems, data, and infrastructure.
Building and computer hardware damage can result in the loss or corruption of
customer records/transactions.

Activity 5.6: Analysing security features of Antivirus


1. Use the Internet to download any four (4) free versions of Antiviruses.
2. Install them on a computer running the Windows Operating system.
3. After installation, run them one by one and take note of their basic protection
features. When you finish, try to compare their security features and suggest
the best antivirus depending on your research.

285
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 285 23/01/2023 11:26:58


Methods to protect computer systems that can exploit. In addition to that, the
against viruses/worms/Trojan horse
Computer Science

risk is the possibility that something


(a) Scanning critical host components will go wrong or an unfavourable event
such as start-up files and boot will occur to affect the availability,
records. confidentiality, or integrity of business
(b) 
Real-time monitoring of host or personnel information. For example,
activities to detect unusual if you plan to start a fire in a wooden
behaviour; for instance, scanning structure, you have a danger (the fire) as
all email attachments for known well as a weakness (the vulnerability)
malware. (the wood structure). There is a high
(c) Antivirus software should monitor risk here that the fire will burn the wood
activity involving the applications structure. Similarly, if you face the same
most likely to be used to infect fire threat but our building is made of
hosts or spread malware. concrete, our threat seems to be no
(d) Examining files for malicious longer correct because it lacks weakness
programs. Depending on the to exploit. You can say that a sufficiently
organization’s security needs, hot flame could destroy the concrete.
antivirus software on hosts should
be configured to scan all hard Risk management
drives regularly to ensure no file Risk management is an assessment that
system infections. defines the risks in your organization,
Steps to protect computer systems against future technologies, and methods to
human intervention are as follows: ensure that controls are in place to
(a) Encrypt data protect against not only cyber threats but
also, natural and human-made disasters.
(b) 
Install antivirus and antispyware
programs Moreover, to compensate for risks in our
surroundings, a risk management process
(c) Install firewall
must be implemented and followed.
(d) Back up data periodically This program must be managed by the
(e) 
Keep the computer in a safe organization’s senior leaders and put in
environment (with good physical place by everyone.
security)
Computer risk
(f) Install security cameras like CCTV
in your computer laboratory A computer risk is anything else that has
the potential to harm a computer user’s
Risks management data. The worth of this information varies
Risk depending on the computer system. A
Risk is defined as the chance of something hacker can steal data through various
terrible happening. For the risk to happen methods such as attacking the Operating
in a given environment, there must be System by using Trojan horses or other
both a danger and a vulnerability threat malware software.

286
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 286 23/01/2023 11:26:58


Types of computer risks measures and weaknesses. During
this process, systems and applications

Computer Science
You can categorize computer risks as the
risks that happen to hardware, software, are reviewed for security measures to
network, and human errors. determine the effectiveness of deployed
security layer to withstand attacks and
Computer risks in hardware misuses. Assessing the vulnerability
Computer risks in hardware result from helps to identify the weaknesses and
unsafe computing habits such as the flaws of vulnerabilities that could be
improper shutdown of the computer or exploited; and therefore, develop the
damaging hardware part that generates countermeasures strategies against or
threats to the computer itself and provide an additional security layer.
misconfiguration. The following procedures should be
followed in risk assessment process:
Computer risk in software
(a) 
Identify threats and risks for
Computer risk in software causes damage a specific asset. The overall
to the computer internally (operative assessment results from a threat
system damage) without the permission and a vulnerability combined.
or knowledge of the user, like Viruses, Vulnerability in the absence of a
worms, ransomware, spyware, and corresponding risk, or a danger in
Trojan horses. Hence, those activities the lack of a related vulnerability,
can be done online by human error or is not a risk. For example, you may
offline by disgruntled employees. suggest items as both a potential
Computer risk in Network threat and a vulnerability.

Computer risk in networks is anything (b) Quantifications which involves


that may damage or steal data from evaluating the identified risks
your computer or allow someone else and determine their likelihood
to access your computer without your and severity. This also entails
consent. This includes online hacking validation, measurement and
activities, ransomware, rogue security the analysis of the risks using
software, the man-in-the-middle attack, mathematical techniques
data leakage and denial-of-service (c) Build a risk profile for each assess
attack. and evaluate the risk.
(d) 
Create a mitigation plan with
Risk assessment process security controls to eliminate
The risk assessment process refers or mitigate the impact of each
to assessing, investigating, setting risk, monitor risks, threats, and
priorities, and developing plans to vulnerabilities on an ongoing basis.
prevent threats to an organisation’s
assets and earnings. Figure 5.13 shows the procedures that
should be followed in the risk assessment
It examines, discovers, and identifies
process.
system and applications security

287
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 287 23/01/2023 11:26:59


Computer Science

A. Risk Identification

D. Risk Mitigation B. Risk Quantification


and monitoring

C. Risk Evaluation

Figure 5.13: Risks assessment process


Vulnerability information system’s security flaws.
A vulnerability is a flaw that It includes discovering weaknesses
cybercriminals can exploit to gain in an environment, design flaws, and
unauthorized access to a computer other security concerns that can cause
system. On the other hand, vulnerabilities an Operating System, application,
are flaws that can be exploited to cause or website to be misused. The
harm. In essence, they are security vulnerabilities are misconfigurations,
flaws that hackers could use to harm default configurations, buffer overflows,
us. A vulnerability can be a flaw in the Operating System flaws and open
operating system or application you are services. Network administrators can
using, or it can be a physical flaw in our scan a network for vulnerabilities using
office building, a data centre with an various tools such as web application
estimated population that exceeds the scanners and Nmap tools, which are
capacity of its air conditioning system, open source and free to use.
or a lack of emergency power.
Types of vulnerability assessments
Vulnerability analysis Active assessments: It is the process of
Vulnerability analysis entails identifying vulnerability assessment which includes
weaknesses in an environment, design actively sending requests to the live
flaws, and other security concerns that network and examining the responses.
may lead to the misuse of an operating Passive assessments: These include packet
system, application, or website, which sniffing to discover vulnerabilities,
may lead to exposure to the risks of running services, open ports, and other
being attacked. information.
Vulnerability assessment External Assessment: It assesses hacking’s
A vulnerability assessment involves viewpoint to find vulnerabilities and
systematically examining an exploit them from outside.

288
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 288 23/01/2023 11:26:59


Authorization and access control alerting operations based on the output
techniques of a security tool or service deployed.

Computer Science
These tools include Intrusion Detection
Incident response System (IDS), Anti-Virus, firewall
If our risk management efforts fail, logs, proxy logs, and alerting Security
incident response is available to respond Information and Event Monitoring
to such events. Incident response should (SIEM).
focus primarily on the items you believe
Containment, eradication and recovery
will cause us pain as an organization,
which we should now be aware of based Most of the work to solve the incident
on our research. Risk-management occurs during the containment,
initiatives and the possible reactions eradication, and recovery phase, at least
to such incidents should be based on in the short term.
documented incident response plans Containment: This entails ensuring
reviewed regularly, tested, and practised that the situation does not cause any
by those expected to put them into more damage than it already has or, at
action in the field. The incident response the very least, that any ongoing harm
process, at a high level, consists of the is minimized. Suppose the problem is
following phases: a malware-infected server that a remote
(a) Preparation attacker is actively controlling. In that
case, this may entail disconnecting the
(b) Detection and analysis
server from the network, putting firewall
(c) Containment rules in place to block the attacker, and
(d) Eradication updating signatures or regulations on an
(e) Recovery Intrusion Prevention System (IPS) to
stop the malware traffic.
(f) Post-incident activity
Eradication: During eradication, you
Preparation will attempt to eliminate the issues
affecting our environment. You have
The incident response preparation phase already isolated our malware-infected
includes all of the activities you can server and disconnected it from its
perform before the incident to prepare command-and-control network. Users
us better to handle it. Typically it entails must remove the malware from the server
putting incident response and operating and ensure it is not visible anywhere else
policies and procedures, conducting in our environment.
training and education for incident
handlers and those expected to report Recovery: Lastly, you must come back
incidents, performing incident response to a stable state as you were before the
exercises, developing and maintaining incident (before the issue started), if you
documentation, and other activities. did not detect the problem immediately.
The recovery includes restoring devices
Detection and analysis or data from backup media, rebuilding
In this phase, detection is done as the systems, reloading applications, or other
result of frequently monitoring or related tasks. You also need to mitigate

289
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 289 23/01/2023 11:26:59


the attack vector that was used. Again, ctivity 5.7: Analysing the
A
vulnerabilities and creating a
Computer Science

this can be a more difficult task than


it appears, owing to the potentially report on risk assessment
incomplete situation surrounding the Resources: A computer with Internet
incident and what took place. You may connectivity, networked computers, and
discover that you cannot verify that a vulnerability-scanning tool.
backup media is clean, free of infection, Procedures:
or entirely corrupted. (a) Use any web browser to search for
Post-incident activity vulnerability-scanning tools
Post-incident activity, like preparation, (b) 
Download and install into your
is an easy phase to overlook, but you all computer
must not do it. During the post-incident (c) Use the downloaded tools to scan
activity phase, also known as a post- the website and your network for
mortem (Latin for “after death”), you try vulnerabilities
to figure out precisely what happened, (d) Assess the risks and write a report
why it happened, and what you can do about your observation
to prevent it from happening. The goal (e) Choose the appropriate
of this stage is not to point fingers but vulnerability-scanning tool to
to ultimately prevent or mitigate the recommend in your computer Lab.
impact of similar incidents in the future.
Defence in depth Authorization and access control
Defence in depth is a strategy used in techniques
military operations and information Authorization is a security method that
security. In both senses, the basic idea evaluates access to the user or client
behind the defence in depth is to devise privileges for system resources such as
multi-layered defined lines or networks files, services, software programs, data,
and applications. Likewise, it is the next
that will allow us to achieve a successful
step taken after completing identification
defence. Still, if one or more of our
and authentication.
defensive measures fail, you would
want defences at the external network, Access control concepts
internal network, host, application, and
Access control is a critical element
data levels to work properly. Given well-
of data security that governs who has
implemented defences at each layer, access to and utilizes company services
users will make it extremely difficult and data. Access control policies ensure
to penetrate our network and attack our users are said to have appropriate access
assets deeply. One important concept to to company data through authentication
note when planning a defensive strategy and authorization. But access controls
using defence in-depth is that it is not a are something you deal with daily.
magic bullet. When you lock or unlock our house’s

290
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 290 23/01/2023 11:26:59


doors, you utilize a form of physical System Access: Users gain access to the
network’s systems. It can be one of the

Computer Science
access control based on your keys.
Moreover, computer system access network’s servers, printers, or shared
control can be implemented in various devices. Access to these devices should
ways depending on the situation. These be restricted, protected, and constantly
include; locking your computer room monitored.
and system, restricting system access to Data Access: Users are constantly
logins and passwords, protecting one’s accessing data from a network resource.
data with file protection or encryption, Files, documents, and databases are
encrypting communication links, or made accessible and adapted by users.
validating a digital signature before Any data that is accessed should be
limited, protected, and monitored.
accessing the data. Authentication
mechanisms have two components Access control methodologies
of access control: authentication and Access control models can implement
authorization. An example of access authorization and deny or grant access
control is when entering a server room to parties based on which resources
or data centre using a physical key or you determine they must have access to
fingerprint authentication, in which something. The term may sound highly
unauthorised users are denied access technical and oriented toward high-
to restricted resources. Essentially, security computing facilities.
the user is prompted to provide a There are five access control
username and password when accessing methodologies which are: Mandatory
computing resources. Another example Access Control (MAC), Discretionary
is when the remote user is prompted to Access Control (DAC), Role-Based
Access Control (RBAC), Attribute-
provide a username and password when
Based Access control (ABAC) and
accessing the network from outside
Multilevel Access Control.
the organization and is denied access
while accessing confidential documents Mandatory access control (MAC)
related to the company or a client. Mandatory Access Control (MAC) is
a type of access control in which the
Types of access control resource owner does not have control
There are three kinds of access control over who has access to it. Still, a group
such as system access, network access or individual determines access with
and data access an authority to set access to resources.
Access to a given resource is frequently
Network Access: Users on a network dictated by the sensitivity label (such
have access to all network resources. as secret and top-secret), the level of
Consequently, network access should be sensitive information that the individual
restricted, protected, and monitored by can access (perhaps only secret),
users who can access the, for example, and whether the individual needs to
the Human Resources (HR) and finance access the resource. Figure 5.14 shows
divisions’ LAN. Mandatory Access Control (MAC).

291
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 291 23/01/2023 11:26:59


Computer Science

Figure 5.14: Mandatory Access Control

Discretionary Access Control (DAC)


Discretionary Access Control (DAC) is a model of access control in which the
resource’s owner determines access. The owner can decide who has and does not
have access to the resource and what level of access they are granted. We can see
DAC implemented in Microsoft operating systems. If you decide to create a network
share, you can choose who has access to it. Figure 5.15 shows DAC.

Figure 5.15: Discretionary Access Control (DAC)

Role-Based Access Control (RBAC)


Role-Based Access Control (RBAC) is an access control model that, like MAC,
is based on access controls described by authority rather than the resource owner.
The distinction between RBAC and MAC is that access control in RBAC is based
on the role of the individual being granted access. When you have an employee
whose sole responsibility is to enter data into a specific application, RBAC once
would only allow the employee access to that application, regardless of the
sensitivity or lack thereof of any other resource he/she might potentially access.
Suppose you have an employee with a more complex customer service role for an

292
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 292 23/01/2023 11:26:59


online retail application. In that case, the activities. Therefore, CAPTCHA is an
employee’s position could require the acronym for Completely Automated

Computer Science
employee to have access to information Public Turing Test to Tell Computer
about customers’ payment status and and Human Apart, which is used to
information, shipping status, previous provide challenges that are difficult for
orders, and returns to assist customers. the computer to perform but relatively
easy for a human. CAPTCHAs prevent
Attribute-Based Access Control (ABAC)
automated tools from performing tasks
Attribute-Based Access Control (ABAC) such as creating new accounts or posting
is logically based on attributes. These spam comments on blogs. The attributes
can be characteristics of a specific related to a specific resource, such as
person, a resource, or an environment. an Operating System or application,
The elements of a particular individual are resource attributes. When you
are referred to as the subject attributes. encounter software that only runs on a
Humans can select from various features, particular operating system or websites
such as the classic “you must be this tall that only work with specific browsers,
to ride” access control, which exists to we frequently see this happen, though
prevent the difficulties and challenges usually for technical rather than security
of riding on amusement park rides that reasons. You could use this type of
may be hazardous to them. In theory, access control as a security measure by
such an assignment might be difficult for requiring the use of specific software or
a machine to perform since, it can not communication protocols, as shown in
differentiate between human and robot Figure 5.16.

Figure 5.16. Attribute-Based Access Control Mechanism

293
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 293 23/01/2023 11:26:59


Multilevel Access Control (MAC) Access Control List (ACL)
Computer Science

Multilevel Access Control (MAC) An Access Control List (ACL) is a


models are used when simpler access system of rules that specify which users’
control models are deemed insufficient strategies are granted to access the target
to protect the information to which device or system recourses. Access
access is being controlled. Military and control lists are also installed in routers
government organizations widely use and switches, which serve as filters,
access controls that frequently handle determining which traffic is permitted to
sensitive data. access the network.
Multilevel security models safeguard Access control is typically used to
a wide range of data, from nuclear control access in the file and operating
secrets to sensitive health information. systems and traffic flow in our systems’
For instance, suppose you have a secret networks. ACLs are most frequently
resource and a user with such an intimate discussed in firewalls and routers. When
level of clearance, which typically ACLs are created, they are typically
allows them to access the resource under tailored to a specific resource, including
the accesses permitted by MAC. identifiers of the parties permitted.
Figure 5.17 shows the access control
list configuration in various control
equipment.

Figure 5.17: Access Control list configurations

294
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 294 23/01/2023 11:26:59


Functions of ACL File System Access Control Lists

Computer Science
1. Provide traffic flow control File system ACLs filter access to files
2. Provide a basic level of security for or directories and tell operating systems
network access which users can access the system and
3. Decide which types of traffic are what privileges are allowed. When
forwarded or blocked at the router looking at the ACLs in most file systems,
interfaces you will notice three permissions in use,
4. Allow an administrator to control read, write, and execute, which will
what areas a client can access on a enable us to access the contents of a file
network or directory, write to a file or directory,
and execute the file, presuming the file
5. Limit network traffic and increase
contains either a program or a script that
network performance
can run on the system after execution.
6. Screen specific hosts to either allow A file or directory in a file system may
or deny access to part of a network
also be assigned multiple ACLs. For
7. 
Deny user permission to access example, in UNIX-like Operating
only certain types of files, such as Systems, separate access lists for a
FTP or HTTP given file can be seen in user, group, and
Importance of access control other ACLs. You can grant an individual
user or a group of different users read,
(a) It ensures that security technology
and access control policies are write, and execute permissions. These
in place to protect confidential three permission sets will be represented
information such as customer as rwxrwxrwx, with the first rwx
secrets and employee data. permission set representing the user, the
(b) Nevertheless, reduce the possibility second the group, and the third the other.
of unauthorized access to physical Furthermore, access permission for
and logical systems. Most businesses each file and directory in UNIX (and
have infrastructure and procedures many other operating systems) is
to limit access to networks, controlled by two identifiers: the User
computer systems, applications, Identification Number (UID) and the
files, and sensitive data such as Group Identification number (GID).
personally identifiable information Every user has a different username and
and intellectual property.
belongs to at least one group. This data
(c) It monitors the system and regulates is retrieved from a password file. Only
by checking each person when the administrator has the authority to
entering and exiting the premises. implement or change a user’s name and
Types of Access Control Lists (ACLs) permissions. From the Linux or Ubuntu
operating system, the ls command is one
The Access Control List involves two
of the essential tools that lists files and
main types: File system ACLs and
Networking ACLs. directories with or without various

295
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 295 23/01/2023 11:26:59


additional information, as illustrated in Figure 5.18.
Computer Science

Figure 5.18: An example of the output that is produced by the ‘ls –l’ command

Networking ACLs allowed. One of the most fundamental


Networking ACLs filter access to the network-oriented ACLs you may
network file Access Control Lists. encounter is MAC address filtering.
Once users look at various activities In theory, MAC addresses are unique
on networks, both private and public, identifiers for every network interface
they will notice that ACLs are again in a given system. When a network
regulating such activity. Access is interface is created, it is assigned a hard-
typically controlled by the identifiers coded MAC address.
which humans use for authentication Classifications of network access
such as Internet protocol (IP) addresses, control list
Media Access Control (MAC) Network access control lists can be
addresses, other network transactions, classified as standard control lists and
and ports. ACLs can be seen in action extended access control lists
in a network equipment/devices like
Routers, switches, and firewalls, as Standard ACLs: Standard Control
well as applications such as, Facebook, List filters traffic based on the source
Google, email, and other software. ACLs IP address and performs in sequence.
for network permissions are typically Moreover, if placed closest to the source,
binary, composed of permit and deny. it may deny or permit the host to access
Finally, after configuring the ACL, you other resources in network. Example
use your chosen identifier to specify of the standard Access Control List
which traffic you are referring to and configuration are illustrated in Figure
simply state whether or not the traffic is 5.19(a) and (b).

Figure 5.19(a): Standard ACLs configuration to filter IP packets based on the


source address only

296
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 296 23/01/2023 11:26:59


Computer Science
Figure 5.19(b): Standard Access Control List (ACL)

Figure 5.19(b) shows standard ACL configuration in which R2 is set to block all
trafic from R1 in site A [192.168.10.0/24] which is intended to go to destination
router 3 in site B [192.168.30.0/24]. Router 2 is also configured to filter traffic
from R1 in site A to all destinations reachable through R3. Further, router R3 is
configured to filter traffic from router R1 [192.168.10.0/24] intended for destination
R3 [192.168.30.0/24] .

Extended ACLs
Resembles the gatekeeper of the network that permits or denies traffic originating
from any address on the given/ specified range. For example to permit traffic
originating from any address on range 192. 168.30.0/24, network to any destination
host port 80(HTTP) can be configured through the following command:
access-list 103 permit tcp 192.168.30.0 0.0.0.255 any eq 80

Extended ACLs filter IP packets based on several attributes, including the following:
(a) Source and destination IP address
(b) Source and destination TCP and UDP ports
(c) Protocol type/ protocol number (example: IP, ICP, UDP, TCP)
Figures 5.19 (c) shows the extended access control lists configuration.

297
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 297 23/01/2023 11:26:59


Computer Science

Figure 5.19(c): Extended Access Control List configuration

Figure 5.19(c) demonstrate the Network access control tools


configuration of ACL in which router There are several network access control
R2 insert filter traffic from all networks
tools as described in the next paragraph:
going out of R1. Further, R1 is also
configured examine traffic coming Firewall
from network 192.168.11.0/24. R2 is
also configured to block FTP and telnet Firewalls are devices or programs
traffic which are coming from network that regulate network traffic flow
192.168.11.0/24 destined to network between networks or hosts with varying
192.168.30.0/24. security postures. While firewalls are
ACLs operations frequently discussed in terms of Internet
Application of inbound and outbound connectivity, they may also be helpful
access control list in packet filtering. in other network environments. For
An Access Control List operation is example, many enterprise networks use
always an implicit deny. Ignoring the firewalls to restrict connectivity to and
fact that it is not physically present, this from internal networks that serve more
statement is automatically inserted at the sensitive functions, such as accounting or
end of each ACL. The implicit denial personnel. An organization can prevent
shuts down all traffic. An ACL that lacks
unauthorized access to its systems and
at least one permit statement will block
all traffic due to this implicit denial. resources by using firewalls to control
connectivity to these areas. The addition
of an appropriate firewall adds an added
level of security.
Activity 5.8: Download Cisco
packet tracer tools (Network simulator) In particular, firewalls are needed to
from the internet and draw the sketch prevent intruders from entering and
map of any topology in your school lab. interfacing with the operations of an
After that, configure and test ACLs as organization’s network system, deleting
per topology. or modifying information stored or

298
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 298 23/01/2023 11:26:59


in motion within the organization’s network system and acquiring proprietary
information. Figure 5.20 illustrates Firewalls.

Computer Science
Internal network External network
Figure 5.20: Firewalls

Types of firewalls
There are two types of firewalls: packet the data link, network, and transport
filtering and proxy firewall. layers. The firewall compares data in
each datagram at each layer, such as the
Apart from that, there are variations of
source and destination addresses (The
two types of firewalls, commonly called
type of service requested and the type of
gateway or bastion.
data delivered). A data packet is denied,
accepted, or delayed based on one or
Packet filtering firewall more conditions: source address, a
A packet filter firewall is a multilevel destination address, TCP or UTP source
firewall that compares and filters all and destination port, ICMP message
inbound and sometimes outgoing type, Payload data type, Connection
network traffic passing through it. It initialization, and datagrams using TCP
contrasts those packets to a predefined ACK bit.
set of rules. The firewall accepts the Moreover, a packet filter firewall is itself
packet that matches a rule. A package divided into two configurations. One is
is rejected or logged for further a straight packet filter firewall, which
investigation if it does not match a rule. allows full-duplex communication.
Additional data packet screening may This two-way communication is made
be required for further investigation, possible by following specific rules
in which case the firewall directs the for communication application proxy.
datagram to the screening device. Travel traffic in each direction for each
Following further screening, the datagram is examined for the particular
datagram may be allowed through criteria given above, and if conformity
or denied. Many filter firewalls use to direction-specific rules is established,
protocol-specific filtering criteria at the firewall lets the datagram through.

299
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 299 23/01/2023 11:26:59


The second configuration is the stateful used by a straight packet filter firewall.
inspection packet filter firewall, a full- These harsh restrictions form a group of
Computer Science

duplex filter firewall; however, it filters one-way rules for the stateful inspection
using a more complex set of criteria that filter firewall. Figure 5.21 shows the
involve more restrictions than those packet filter firewall.

Figure 5.21: A Packet Filter Firewall

Proxy firewalls
A proxy firewall is a network security system that safeguards network resources by
filtering messages at the application layer. A proxy firewall is also referred to as an
application firewall or a gateway firewall. Figure 5.22 illustrates the proxy firewall.

Figure 5.22: Proxy firewall

300
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 300 23/01/2023 11:26:59


Proxy firewalls are divided into two types: the Application-level proxy firewall and
the Circuit-level proxy firewall.

Computer Science
Application-level proxy firewalls
A firewall generates a proxy for each application developed by a communicating
element. The proxy firewall inspects and forwards each application-generated traffic.
The presence of an application proxy makes logs and controls incoming and outgoing
traffic, offering a higher degree of security such as, user-level authentication, end-
to-end encryption, intelligent logging, information hiding, and access restrictions
based on service types. A proxy filter firewall is shown in Figure 5.23.
Internal networks like LANs usually have multiple application proxy firewalls,
including telnet, WWW, FTP, and SMTP (email). Although application proxy
firewalls are great as high-level filtering devices; they are more expensive to
install because they may require installing a proxy firewall for each application an
organization has, and that can be expensive to acquire, install, and maintain.

Figure 5.23: Application Proxy Firewall

Circuit-level proxy firewall (with low-level general protocol proposals)


This type of proxy firewall treats all network packets as if they are a slew of black
boxes to be routed through a filter or a bastion or not. It only filters based on
the information in the packet header. As a result, it is faster than its cousin, the
application-level proxy.

301
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 301 23/01/2023 11:26:59


A gateway is commonly known as a Every user who access the network,
bastion gateway for a combination of the will go through the firewall which
Computer Science

filter and proxy firewalls, which gives it a record it as a log file to be used later
medieval castle flavour. Packets from the for statistics on network usage.
local network and outside the Network (iv) Prevention of modification of
can only reach their destinations through valuable information.
a firewall by passing through the filter
router and proxy by the station. Each Intrusion detection and prevention
application gateway combines a general- system
purpose router that acts as a traffic filter Intrusion detection
with an application-specific server that This refers to software or device
all application data must pass through. which monitors the network traffic for
Function of firewall malicious activity or policy violations.
Detecting intrusions is based on models
The following are the functions of and patterns of what something good
firewall: looks like (typically built by normal
(i)  
As a network security guard. baseline behaviour) and looking for
It filter all traffic that enter and deviations/anomalies. These systems
leave the network according to the learn primarily by observing our
predefined roles, mechanisms and networks and systems in use and then
policies. simply having a much higher knowledge
(ii) Prevention of information leaking about the traffic. From this point of
without knowledge. Through a set view, IDS can reclaim attention when
of protocols, such as, FTP it can combined with a policy enforcement
detects and prevent users from system such as MAC to take action
sending valuable data to other against wrong sources of malicious
parties. traffic. Figure 5.24 depicts the intrusion
detection system and possible locations.
(iii) Keeping records of user activities.

Figure 5.24: Intrusion Detection System (IDS)

302
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 302 23/01/2023 11:26:59


Types of intrusion detection systems activity is detected, HIDS can alert the
user, block the action, or create any other

Computer Science
Typically, there are two types of IDS
which are Host-based IDS and Network- decision based on the system’s policy.
based IDS/IPS It should be capable of detecting both
Host-based IDS known and unknown attacks. The
majority of HIDS products can also
Host-based Intrusion Detection System is prevent attacks.
typically a software-based deployment
IDS in which an agent is installed on Nevertheless, it is initially deployed in
the local host to monitor and report the monitor mode, and once the system
on application activity, as depicted activity is understood, a baseline is
in Figure 5.25, HIDS monitors the created, and HIDS is deployed in the
system and access privileges and prevention mode. The functionality of
sends alerts for any unusual activity. HIDS depends on the records and the
It continuously monitors event logs, fact that attackers leave indications of
system logs, application logs, user their activities.
policy enforcement, rootkit detection, In general, hackers seek to gain access
file integrity, and other computer system to the system and install malicious tools
intrusions. to facilitate future access. If these tools
It continuously monitors these logs alter the operating system configurations
and establishes a baseline. If any new or registry entries, it is logged in the
log entries appear, HIDS compares the systems/event log, triggering an alert by
data to the baseline, and if any entries the HIDS system. Figure 5.25 shows a
are found outside of the baseline, HIDS host-based intrusion detection system.
generates an alert. If any unauthorized

Figure 5.25: Host-Based Intrusion Detection System

303
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 303 23/01/2023 11:26:59


Network-based IDS and Intrusion Prevention System (IPS)
Computer Science

Network intrusion detection systems (IDS) and intrusion prevention systems (IPS)
protect the network and its resources from a network malicious activity standpoint.
For example, network intrusion detection systems (IDS) can detect reconnaissance
and denial-of-service attacks at the network level. As soon as these threats are
detected, NIDS generates alerts. NIDS is a hardware/software solution that operates
as an independent device (sensor) near the firewall and has a network operating
system (TCP/IP stack). Sensors have interfaces for monitoring the network
(monitoring interfaces), controlling and receiving alerts, and sending these alerts
to the central management console. Figure 5.26 depicts network-based intrusion
detection and prevention system.
IDS/IPS is another network-based intrusion detection which employs signature-
based and anomaly-based detection techniques.

Figure 5.26: Network-Based Intrusion Detection and Prevention System

Intrusion detection systems employ two detection methods: Signature-based


detection and behaviour-based detection.
Signature-based detection compares data activity to a signature or pattern in a
signature database. For example, signature-based detection has a constraint that
ignores new malicious activity that is not in the database.
Behaviour-based detection is the one which detects any anomaly and provides
alerts, implying that it can see new types of attacks. It is known as an expert system
because it learns what normal behaviour in your system appears equivalent to a
network.
An Intrusion Prevention System (IPS) is crucial for network security. It is based on
IDS (Intrusion Detection System) as the extra step of taking action, often in real-time,
to prevent an intrusion once detected by the IDS. So, Protection = Prevention plus

304
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 304 23/01/2023 11:27:00


Detection. Detecting attacks is a fundamentally different problem from preventing
intrusions. Figure 5.27 shows Intrusion Prevention System (IPS).

Computer Science
Figure 5.27: Intrusion Prevention System (IPS)

Intrusion Prevention System (IPS) Virtual Private Network (VPN)


The Intrusion Prevention System (IPS) is The ability to encrypt and decrypt
used to prevent intrusion. Advancement specific network traffic flows between
to IDS. IDS only detect whereas IPS the protected network and external
protects the network from intrusion by networks is a common requirement for
these firewalls. Virtual Private Networks
dropping packets, denying message
(VPNs) are almost always used, which
entry, or blocking the link. IPS and IDS
use additional protocols to encrypt
work together to monitor network traffic traffic and provide user authentication
for threat actors, and IPS is simply a and integrity checking. VPNs are most
part of IDS. The main difference is commonly used to secure network
that the IPS is placed in-line to prevent communications across untrusted
intrusions. The IPS can make decisions, networks. VPN technology, for example,
including dropping packets or resetting is widely used to extend the protected
interconnection and sending alarms to network of a multi-site network. Apart
the management console. An Intrusion from that, it is a private network that
Prevention System (IPS) can detect connects to remote sites via the public
and correct fragmented packets, Cyclic network.
Redundancy Check (CRC) errors, and VPN sets up a “virtual” tunnel
TCP sequencing issues. connection via the Internet from the
company’s trusted network to a remote
IDS operation on system and network
office or mobile workforce. VPN allows
(how it operate on the system and
you to send data over a public network
Network) while simulating a private link between
two parties of the Network.

305
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 305 23/01/2023 11:27:00


Types of VPN Intranet-based VPN: When several
Computer Science

Virtual Private Network (VPN) is offices of the same company are


divided into two types: Remote Access connected using a Site-to-Site VPN, it
VPN and Site to Site VPN (Intranet and is called an Intranet-based VPN. On the
Extranet); however, there is another type other hand.
called Host-to-Host VPN. Extranet based VPN: is when companies
use a Site-to-Site VPN type to connect
Remote Access VPN to the office of another company.
Remote Access VPN allows users
to connect to a private network and Host-to-Host VPN
remotely access most of their resources With one minor exception, some people
and services. The user’s connection to refer to host-to-host VPNs as remote
the private network is established via access. A VPN tunnel that connects
the Internet, and the link is safe and two hosts is a host-to-host VPN. The
confidential. Remote Access VPN can tunnel is established directly between
be used for various purposes, at home two hosts for secure data transfer.
and office users. Second, the company The user is authenticated before the
employee uses a VPN to connect to data transmission, and the encrypted
their company’s private network and credentials are exchanged between the
remotely access files and resources on two parties before data transmission.
the private network. VPN users who The VPN tunnel protects data by
are remote or at home use VPN services ensuring its authenticity, integrity, and
to bypass regional Internet restrictions confidentiality. This type of connection
and access restricted websites. Internet is permitted when an employee or a
security-conscious users use VPN partner wishes to securely connect to
services to improve their online security a specific network resource (server/
and privacy. database). An individual person may not
be allowed to access any other network
The Site to Site VPN (Intranet and resources.
Extranet)
A Site-to-Site VPN: Site-to-Site VPN is Classifications of VPN
also called a Router-to-Router VPN and
Two common choices for secure VPNs
is commonly used in large companies.
are classified as IPsec and Secure
Companies or organizations with branch
Sockets Layer (SSL)/Transport Layer
offices in different locations use a Site-
Security (TLS).
to-Site VPN to connect the Network of
one office location to the network at Internet Protocol Security (IPsec)
another office location. Internet Protocol Security, known
as IPsec, is used to secure Internet
communication across an IP network.

306
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 306 23/01/2023 11:27:00


Secure Sockets Layer (SSL) and Transport Layer Security (TLS):

Computer Science
Secure Sockets Layer (SSL) and Transport Layer Security (TLS) generate a VPN
connection where the web browser acts as the client. User access is prohibited
to specific applications instead of the entire network. Online shopping websites
commonly use SSL and TLS protocols. It is easy to switch to SSL by web browsers
and with almost no action required from the user as web browsers are integrated
with SSL and TLS. SSL connections have “https” in the initial of the URL instead
of “http”.
Secure Shell (SSH)
Secure Shell generates the VPN tunnel through which the data transfer occurs and
ensures that the tunnel is encrypted. An SSH client causes SSH connections, and
data is transferred from a local port to the remote server through the encrypted
tunnel. Figure 5.28 shows Secure Shell (SSH).

Figure 5.28: Secure Shell (SSH)


VPN protocols (IPsec, L2TP, PPTP, GRE)
VPN protocols include IPsec, PPTP, L2TP and GRE. IPsec protects Internet Protocol
communication by validating the session and encrypting each data packet sent during
the connection. Furthermore, IPsec’s goal is to provide security services for the IP
layer in both IPv4 and IPv6 protocols. IPsec is a cryptographically designed security
protocol for the IPv4 and IPv6 protocols. IPsec security services protect network
traffic by ensuring data confidentiality, integrity, authenticity, and anti-replay.
IPsec is a complex framework of numerous protocols that provide various security
features. To accomplish this, IPsec employs two major security protocols: the
Authentication Header (AH) and the Encapsulating Security Protocol (ESP).

307
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 307 23/01/2023 11:27:00


The IPsec framework has two modes, namely:
Computer Science

(a) Transport mode


(b) Tunnelling mode
Transport mode
The transport mode encrypts the message within the data packet, while the tunnelling
mode encrypts the entire data packet. IPsec can also be used in conjunction with
other security protocols to boost the security system.
Tunnelling mode (L2TP, or Layer 2 Tunnelling Protocol)
Layer 2 Tunnelling Protocol is a tunnelling protocol frequently used in conjunction
with another VPN security protocol, such as IPsec, to create a highly secure VPN
connection. L2TP creates a tunnel between two L2TP connection points, and the
IPsec protocol encrypts the data and helps ensure encrypted communications across
the tunnel. Figure 5.29 shows the Layer 2 Tunnelling protocol.

Figure 5.29: Layer 2 Tunnelling Protocol

Point–to–Point Tunnelling Protocol (PPTP)


The Point-to-Point Tunnelling Protocol creates a tunnel and confines the data packet.
The Point-to-Point Tunnelling Protocol (PPTP) is used to encrypt data between
connections. It is a popular Hosting protocol that has been in use since the early days
of Windows. Figure 5.30 shows the Point-to-Point Tunnelling protocol.

308
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 308 23/01/2023 11:27:00


Computer Science
Figure 5.30: Point–to–Point Tunnelling Protocol

Generic Routing Encapsulation (GRE)


The tunnelling protocol Generic Routing Encapsulation (GRE) encapsulates one IP
datagram within another IP datagram and transports the encapsulated IP datagram.
GRE, in other words, encapsulates one network layer protocol inside another
network layer protocol. RFC 2890.6 describes the general specification of the GRE.
Figure 5.31 depicts a typical GRE diagram. A network layer packet, known as the
“payload” packet, is encapsulated in a GRE packet, which may include all the
network payload packet’s routing information. The resulting GRE packet is then
encapsulated in another network layer protocol called the “delivery protocol.

Figure 5.31: Format of a GRE encapsulated packet

Activity 5.9: Confirmation of access control list


You want to apply an access list of 198 to an interface to filter traffic into the interface.
Write a command that you will achieve in this confirmation of access control list.

309
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 309 23/01/2023 11:27:00


Exercise 5.2. brand image? DLP solutions that
use context-based classification,
Computer Science

1. Discuss with vivid examples two


such as Digital Guardian, can
types of access control.
classify intellectual property in
2. 
Distinguish between Extended structured and unstructured forms.
ACL and Standard ACL. You can prevent unwanted data loss
3. Write brief notes on firewalls with or theft by implementing policies
vivid examples. and controls.
(d) 
Data Visibility: Does your
4. 
Differentiate between layer 2
organization want to gain more
tunnelling protocol from point to insight into data movement? A
point tunnelling protocol. cohesive business DLP solution can
assist you in seeing and tracking
your data across endpoints,
Data loss prevention networks, and the cloud.
Data loss prevention (DLP) involves a (e) 
It gives you insight into how your
collection of tools and processes used organisation’s users interact with
to keep sensitive data from being lost, data. While these are the three most
misused, or accessed by unauthorized popular use cases, DLP can also
users. DLP software categorizes help with insider threats, Office
regulated, confidential, and business- 2019 data security, user and entity
critical data and detects violations of behaviour analysis, and advanced
policies defined by organizations or acts threats.
as a check pack, which are typically
driven by regulatory compliance such as (f) 
DLP software scans incoming
HIPAA, PCI-DSS, or GDPR. emails for malware or suspect
connections. These tools enable
Importance of data loss prevention you to flag inconsistent content
(a) 
DLP helps to prevent the so that employees can manually
involuntary disclosure of sensitive process, assess it or stop it in its
information across all devices. DLP tracks once it is detected.
can monitor data wherever it is,
whether in transit on the network, Drawbacks of data loss prevention
at rest in backups, or in use, and Encrypting network traffic has
reduce the danger of data loss. two significant drawbacks. For
(b) 
DLP can identify, classify, and beginners, network encryption has
tag sensitive data and monitor the been challenging to implement in past
activities and events that occur in centuries. Using IPsec encryption, for
the context of that data. example, usually requires the setup of
an enterprise certificate authority. An
(c) 
It produces a report of the administrator must still understand the
information required for essential management process and how
compliance audits. IP Protection: to set group policies requiring network
Does your organization have computers to use IPsec encryption.
valuable intellectual property and Furthermore, IPsec encryption will
trade or state secrets that, if lost or fail unless network clients use IPsec-
stolen, affect financial health and compatible operating systems.

310
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 310 23/01/2023 11:27:00


Another significant drawback of network space, resulting in faster access. On site
traffic encryption is that it can degrade and off site storage is critical to a fire-

Computer Science
performance. Every time a client needs proof safe where in case of any damage
to communicate over the network, a copy can be taken from on-site or
the client must establish a session and off-site to restore. A benefit is that files
encrypt the data to be sent. The recipient that have become fragmented can be
must decrypt the data. This process
reorganised to occupy contiguous space
increases the amount of network traffic
and requires network client machines when restored, resulting in quicker
to spend more time and CPU resources access.
encrypting and decrypting data. There
should be network cards that can take Types of data backups technologies
the encryption and decryption process
Digital linear tape (DLT) or Linear tape-
away from the CPU. Hence, it prevents
network clients from undergoing poor open (LTO) systems: These are rock solid
performance. which helps to address storage capacity
and access time. They also, increase the
total capacity and speed of the tape and
Exercise 5.3
disk when information is backed up into
1. What is Data Loss Prevention (DLP)? the tape.
2. 
Type an E-mail message to your Robotic auto-changers are available for
teacher asking for test two (2) results. DLT, and LTO drives with plenty of
Apply the skill you have mastered headroom and can hold five tapes up to
in the session to encrypt email and large libraries that hold tens or hundreds
show how a message you sent was of videos.
encrypted. DLT S4 (800GB per tape) and LTO – 6
(2,500GB per tape): These are very fast
3. 
When someone tries to send an and reliable with high per tape capacities.
encrypted message to your E-mail, Examples: Tape Vaulting, Remote Tape
what does an encrypted message Backup, and Offsite Backup.
look like for the external user?
Cloud Storage: Cloud storage involve
storing data to online servers located
and hosted somewhere else. This
Data backups and disaster recovery backup solution is unique because you
Data backup is the periodic storing of can back up all your local files and
copies of copied files regularly and securely store them in your chosen cloud
keeping them in a safe place or a safe provider. Caution on security should be
storage device. considered because the data are stored in
a third party.
Importance of data backup and
disaster recovery Even if your data centre experiences a
catastrophic event, your hosted data and
When files have been restored, they can territories will be preserved when using
be reorganized to occupy contiguous this type of backup.

311
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 311 23/01/2023 11:27:00


Data backup requirements of an outage. A collection of servers is
linked to a single system that acts as a
Computer Science

(a) 
Keeping backups safe; backup
copies need to be held in a fireproof stand-by when it fails.
safe or preferably offsite Clustered servers are typically used
for applications that require frequent
(b) Data backups restorations strategies
data updates, with file, print, database,
(c) Keep the daily backups for a week and messaging servers being the most
(d) Keep Fridays back up for a month common clusters. Overall, clustering
(e) Keep one backup each month for a servers provide clients with higher
year availability, reliability, and scalability
than any single server could. In a
(f) To prevent mix-ups, give each tape clustered hosting environment, each
or disk a serial number and keep a server is responsible for the owners and
logbook control of its own devices and for getting
a copy of the operating system (along
Data recovery mechanism with any applications or services) used
Testing recovery procedures and the to run the other servers in the cluster.
effectiveness of backup systems need to Electronic Vaulting means that data are
be done regularly. It helps to ensure that backed-up. The output is electronically
a business can recover from a disaster. transmitted to a secured offsite storage
An additional contingency plan must location. Examples of server clusters are
be developed to consider alternative Tape Vaulting, Remote Tape Backup,
compatible equipment and security and Offsite Backup.
facilities, including temporary
office space provision of alternative Remote journaling
communications links. Remote journaling and electronic
vaulting are mainly used in systems
Fault tolerance mechanisms where data is a priority, ensuring that not
even a tiny section of the information
Fault tolerance is the ability of a system is changed or lost. It is the process
like a computer, network, cloud or of recording transactions at remote
cluster to continue operating without locations as a backup strategy. It allows
interruption when one or more of its the user to capture the occurrence of
components stop working. It includes changes and then copy them to a different
a server cluster, remote journaling, and location. It also keeps changes in data
server mirroring to secure situations. since the previous save. Recovering
Server clustering data requires replaying the changes and
A server cluster is a group of servers cleaning up any changes.
that work collaboratively on a single
system to provide users with increased Server mirroring
availability. These clusters mitigate Server mirroring is a network control
downtime and outages by allowing process that continuously creates an
some other server to take over in case exact copy of a server. Server mirroring

312
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 312 23/01/2023 11:27:00


is a method for ensuring business Vulnerability analysis and
continuity, disaster recovery, and backup. penetration testing

Computer Science
Furthermore, it is primarily used to build A vulnerability analysis is a review that
a fault-tolerant and redundant server focuses on threat protection issues that
computing infrastructure. This process have a moderate effect on the system’s
is carried out by using specialized security.
backup software installed on the backup
server and the server to be mirrored. The
software routinely synchronizes and Penetration testing through hacking
backs up data from the primary server to Penetration testing is a method of
the backup server via a secure Internet testing the security of a network and the
connection or VPN. vulnerability of a company’s systems
and infrastructure by employing
 ctivity 5.10: Creating
A various tools and techniques used by
backups attackers. The approach is similar to an
Resources: Sample files, a computer, attacker: enumerate the network, assess
external storage devices such as HDD, vulnerabilities, research vulnerabilities
memory sticks, internet connectivity and for known exploits, and then use
an active yahoo or Gmail email address, methods available to penetrate the
a computer and a smartphone. network. The attackers list a grid to
decide which machines are connected
Procedures:
and operationally useful for both an
1. Open your computer and access the
intruder and a system administrator. The
internet
data obtained from a network scan aids
2. Create an e-mail account if you
in determining the actual current layout.
don’t have one
3. Install and configure any cloud A few tools and techniques are available
storage tools such as Dropbox for both the Windows and Linux
4. Create a folder on your computer platforms to perform these tests. After
and link it to your cloud storage identifying the devices and their open
5. Save your file in the folder on your ports, a vulnerability scanner can be used.
computer and then The scanner will use its vulnerability
6. Use the smartphone to see if you database to see if the system has any
can access the file from such a vulnerabilities. These vulnerabilities
computer. are then researched further online, and
7. Make several copies of your file utilities that can be used to breach the
into the storage devices you have network are downloaded and executed.
A good penetration test should produce
8. Try to think about what will happen
if your flash is lost or corrupted a report explaining the weaknesses
discovered, ranking them from most
9. Share with your colleague and then
to the class and suggest the best critical to least critical, and offering
option for your class. suggestions for improving network
security.

313
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 313 23/01/2023 11:27:00


Importance of penetration testing sponsored hackers, black hat hackers,
white hat hackers, grey hat hackers,
Computer Science

Penetration tests are essential for an


organization’s security because they Script Kiddies, red hat hackers,
teach employees how to deal with any hacktivists, and malicious insiders or
malicious entity break-in. Penetration whistle-blowers.
tests are used to determine whether Cyber terrorism
or not a company’s security policies
are effective. Penetration testing and Cyberterrorism (also known as digital
vulnerability analysis are critical terrorism) is a disruptive attack on
network security components, serving computer systems by recognized
different purposes. Penetration testing terrorist organizations with the intent
simulates a real-world attack on a of causing alarm, panic, or physical
network’s defences. On the other hand, disruption of the information system.
a vulnerability is a non-intrusive scan Examples are the disorder of major
that searches the web for potential websites, the attack on water treatment
vulnerabilities. information systems, the interruption of
an oil pipeline, (cyber espionage), and
One of the most important things to the disruption of systems and networks.
consider when starting a new business is
regulatory compliance. The regulatory Black hat hackers
aspect is one of the most important
considerations for any business’s These individuals, also known as
success. Every industry has its own set criminal hackers or crackers, maliciously
of regulations and rules. gain access to another person’s system
It helps in identifying vulnerabilities for personal gain. They commonly hack
in target applications. Businesses and electronic devices and modify, steal, or
organizations commonly use it to delete critical files for personal growth.
ensure compliance with government
regulations. White hat hackers
White hat hackers, also known as ethical
hackers, discover ways to exploit a
Hacking
device’s system to learn how people
Hacking compromises digital devices can defend themselves against potential
and networks by gaining unauthorised attacks. These ethical hackers also ensure
access to any account or computer
that the security services are up to date.
system. Exploiting vulnerabilities
They actively search for the most recent
in a system, compromising security,
and gaining unauthorized control and exploits and system vulnerabilities.
authority over the system’s resources are Ethical hackers also learn new ways
all examples of hacking. to tamper with electronic devices to
maximize efficiency. As a result, they
Types of hackers
create communities where they can
There are many types of hackers, such crowdsource their knowledge and
as cyber terrorists, state or nation-
develop how people use their devices.

314
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 314 23/01/2023 11:27:00


Grey hat hackers The data collected from accessed
government files are used for personal,

Computer Science
As the name implies, they are motivated
by white and black hat hacking political, or social gain.
motivations. They are the ones who State/Nation Sponsored Hackers
use both illegal and legal techniques to The government hires hackers to
exploit or improve a system. Moreover, gather information on other countries.
if a grey hat hacker exploits another These hackers are referred to as State/
person’s plan, they usually notify the Nation sponsored hackers. They use
owner of the exploits and then offer their knowledge to obtain confidential
suggestions on improving system information from other states to prepare
security. well for any potential threats to their
Script Kiddies country. The sensitive information
The Script Kiddies are a type of hacker aids in being on top of every situation
who is an amateur in hacking. They are and avoiding impending danger. They
trying to hack the system using scripts only document to their respective
written by other hackers. They are trying governments.
to compromise systems, networks, or Malicious insiders or Whistle-blowers
websites. The goal of hacking is to These types of hackers include
gain attention from their peers. Script individuals working in an organization
Kids are people who are unaware of the who can expose confidential information.
hacking process. The intent behind the exposure might
Red Hat Hackers be a personal grudge against the
Red Hat Hackers, sometimes called organization, or the individual might
Eagle-Eyed Hackers, are the same types have encountered illegal activities
of hackers as white hackers. The red within the organisation. The reason for
hat hackers intend to thwart the black disclosure defines the intent behind the
hat hackers’ attack. The distinction exposure.
between red hat and white hat hackers Hacking process
is in the process of hacking through The hackers always perform penetration
intention. Red hat hackers are ruthless testing processes. The process involves
when dealing with black hat hackers or a functional examination of the target
combating malware. The red hat hackers system for potential vulnerabilities from
continue to attack, and the entire system poor or incorrect system configuration,
setup may be changed. known and unknown hardware or
Hacktivist software flaws, and operational flaws in
These hackers intend to compromise process or technical countermeasures.
government websites. They pose as The hacking process has five phases. These
activists, which would be known as are:
a hacktivist. A hacktivist can be a (a) Reconnaissance
single person or a group of anonymous (b) Scanning
hackers whose goal is to gain access
to government websites and networks. (c) Access (gaining access)

315
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 315 23/01/2023 11:27:00


(d) Maintaining access creating a network diagram of available
data by locating routers, network
Computer Science

(e) Clearing tracks


topology, firewall servers, and host
Reconnaissance information. This map may be helpful
Reconnaissance is the first step, during the hacking process.
also known as data collection and Gain access
footprinting. This stage takes a long
time. During this phase, you observe It obtains sensitive data by utilising
and collect all of an organisation’s knowledge from the previous phase.
network and server information. You The hackers use this information and
will learn everything there so as to know the network to launch attacks on other
about the organisation. The methods targets. The attackers have some control
used for reconnaissance include internet over other devices during this phase. An
searching, social engineering and attacker can gain access to the system
non-intrusive network scanning. The by employing various techniques such
reconnaissance phase can last days, as brute force attacks.
weeks, or months depending on the Maintaining access
target. The main aim of this phase is Hackers have many choices for retaining
to learn as much as possible about the device access, including creating a
possible enemy. Typically, collecting backdoor. The hacker can use the
data on the system user, involves the backdoor to maintain a continuous attack
host and network system. on the network. The hacker can attack
Scanning the device over which they have gained
Scanning: After gathering all the target control without fear of losing access.
organization’s information in this Creating a backdoor is sometimes
phase, the hacker scans the system for inconvenient since it increases the
security flaws. The hacker will look for possibility of a hacker being discovered.
defects such as outdated applications, The backdoor extends the scope of the
open services, open ports, and network IDS (intrusion detection system). Using
equipment types using scanning tools the backdoor, a hacker can gain access
such as Nmap and web scanners. In the to the system at any time in the future.
scanning process, typically, they use Clearing tracks
three stages as follows: Ethical hackers will never leave a trail
Port scanning: Scan the target for of their hacking activities. As a result,
information such as live systems, open they must delete all documents and logs
ports, and system software running on information relevant to the attack. The
the host during this phase. primary goal of the clearing tracks phase
Vulnerability scanning: During this is to remove all traces that nobody can
phase, hackers look for weaknesses in find.
the target that can be exploited. This Hacking tools (hardware and software)
scan can be performed automatically. Both ethical and criminal hackers have
Network Mapping: This consists of access to an abundance of hacking

316
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 316 23/01/2023 11:27:00


tools that can be used to either attack or on a website, Burp Suite is one of the
protect a particular system. These tools essential tools you can use. This tool

Computer Science
can be crowd-sourced from the internet allows you to examine every cookie on
through forums and other online hubs a website and initiate connections within
dedicated to hackers. Below are popular website applications.
hacking tools used today. Ettercap
Angry IP Scanner (ipscan) This tool helps launch man-in-the-
This tool commonly referred to as middle attacks, designed to make two
ipscan by experienced hackers, tracks different systems believe they are
computers using their IP addresses and communicating. At the same time, a
snoop for port numbers to look for hacker secretly relies on a different
gateways that will lead them directly message from the other. It helps to
into a targeted computer system. This manipulate or steal transactions or data
tool is also commonly used by system transfers between systems and listen in
engineers and administrators to scan on conversations.
for potential vulnerabilities in their Metasploit
authorised infrastructures. These are
examples of open-source software that Metasploit is well-known among
seems to be freely available. hackers because it is an effective tool
for identifying potential security issues
Kali Linux and validating system vulnerability
This Linux Operating System is one of mitigations. It has been one of the best
the favourites of hackers launched in cryptography tools for hackers since
2015 due to its abundance of features. it effectively masks the identities and
This security-centred toolkit allows you locations of an attack.
to run it right from a CD or through Wireshark and Aircraft-ng
a USB without any installation. It
contains most of the interfaces you need These tools detect wireless connections
for hacking, including creating fake and hack user IDs and passwords on a
networks, spoofing messages, and even Wi-Fi network. Wireshark is a packet
cracking Wi-Fi passwords. sniffer, and Aircraft-ng is a packet
capturing suite that allows monitoring of
Cain & Abel Wi-Fi security with various other tools.
Cain & Abel is one of the most effective Note: Brute force is one of the most
hacking toolkits for Microsoft operating effective techniques the attacker and
systems. This tool allows you to recover crackers use to crack login details such
wireless network passwords, and user as passwords and utilises the dictionary
account passwords, and crack passwords attack. While most hackers genuinely
using a few brute force methods. It think that brute force tactics take too
could also be used to record VoIP long to crack a password, John the
conversations. Ripper is one of the more efficient tools
Burp Suite for recovering encrypted passwords.
When mapping out vulnerabilities

317
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 317 23/01/2023 11:27:00


Penetration testing (b) 
Avoid downloads from unknown
sources, install up-to-date security
Computer Science

Penetration testing entails simulating an


attack on an organization’s information software and antiviruses, and
security arrangements by employing scan removable media before
various manual and automated completing the integrity, enabling
techniques. It should be carried out by auditing, and installing intrusion
a qualified and independent penetration detection software.
testing expert, a security tester with ARP poisoning attacks
integrity. Penetration testing focuses on countermeasures
exploiting known vulnerabilities, but To eliminate ARP poisoning attach, the
it should also use the tester’s expertise following methods should be done:
to identify unknown weaknesses in an
organization’s security arrangements. (a) Using dynamic ARP inspection in
conjunction with DHCP snooping,
A penetration test is typically an ARP-to-MAC bindings can be used
examination of IT infrastructure, to track DHCP transactions
networks, and business applications to
identify attack vectors, vulnerabilities, (b) 
Using dynamic ARP inspection
and control weak points. There are two to defend against MAC spoofing
common forms of penetration testing as attacks
follows: Wireless network attacks
Application penetration testing (web countermeasures
applications): This identifies technical To secure wireless networks from ARP
weak points in a network or in the web attacks, the following measures should
application. be taken:
Infrastructure penetration testing: This (a) scanning access points;
looks for security flaws in servers, (b) changing default parameters;
firewalls, and other hardware. (c) deploying wireless IPS, and
Penetration testing countermeasures (d) selecting solid passwords.
Penetration test countermeasures should All the measures above can be done by
be done. It depends on the threats that disabling remote wireless device login
harm the computer’s system or the and configuring WPA2 with AES for data
surrounding area of the network, like security, scanning RF, filtering MAC,
Trojan horse attacks, ARP poisoning disabling SSID broadcast, blocking
attacks, wireless network attacks, and rogue access points, and implementing
footprinting attacks. strong authentication.
Trojan countermeasures Footprinting Countermeasures
To eliminate attacks from Trojans, The different countermeasures that
different rules should be followed such as: should be used against footprinting
operations are:
(a) Refraining from opening suspicious
email attachments, blocking unused (a) 
Providing training and
ports, and monitoring network awareness of footprinting,
traffic.

318
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 318 23/01/2023 11:27:00


impact, methodologies, and From this scenario, consider the
countermeasures to an organization following questions:

Computer Science
and its employees.
1. 
What reasonable steps could the
(b) 
Employees in an organization company have taken to prevent
should be restricted from using the Angela from finding out about
corporate network to access social company hardware, like router
networking sites. models?
(c) Devices and servers should be set 2. 
What steps should the company
up to prevent data leakage. take to prevent or reduce the
efficacy of port scans?
3. Hashimu is a network administrator
Activity 5.10: for the ATCL Company. Hashim
Carry out the penetration test using the has been passed over for promotion
following procedure and produce a test three times. He is pretty vocal
report. in his dissatisfaction with this
situation. He begins to express
1. Footprinting and reconnaissance negative opinions about the
2. Scanning (and vulnerability organization in general. Eventually,
assessment) Hashimu quits and starts his own
3. Enumeration consulting business. Six months
after Hashimu’s departure, it was
4. Attacks or hacks
discovered that a competitor had
5. Security measures suddenly duplicated a good deal
6. Reporting of the ATCL Company’s research.
Executives at ATCL suspect that
Hashimu has done some consulting
work for this competitor and may
Exercise 5.4 have passed on sensitive data.
However, since Hashimu left, his
Scenario: Angela is a hacker committed to
computer has been formatted and
breaking into the TTCL Company. Eliza
reassigned to another person in
uses various passive reconnaissance
the interim. ATCL has no evidence
techniques and gathers extensive
that Hashimu did anything wrong.
information about the company. Angela
What steps might have been
discovers what model routers are used
taken to detect Hashimu’s alleged
from network administrator questions/
industrial espionage? What steps
comments in user groups. Again, she
might have been taken to prevent
finds a complete list of the IT staff and
his perpetrating such an offence?
their phone numbers from a personnel
directory on the company website. Also, 4. 
Discuss the countermeasure of
she could find out what services were hacking via footprint attack.
running using a port scan.

319
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 319 23/01/2023 11:27:00


Security in cloud computing and The difficulties of cloud scomputing
the Internet of things (IoT) in terms of data security pave cloud
Computer Science

computing to emphasise multiple


Security in cloud computing
technologies such as networks,
Cloud computing is a network access databases, operating systems,
model that allows for convenient, on- virtualization, resource scheduling,
demand network access to a shared pool transaction management, load balancing,
of configurable resources; for example, concurrency control, and memory
networks, servers, storage, applications, management. The result of any company
and services. Cloud computing service using cloud computing is increasing
models are detailed and described in threats in clouding. For example,
chapter seven. adapting the network that connects the
Historically, data centre computing plans in a cloud must be secure.
models were based on a client-server Furthermore, the cloud computing
model architecture. The design or virtual machine paradigm increases
model relies heavily on a three-tier the number of security concerns.
design process that includes access, For instance, the mapping of virtual
distribution, and core switches, machines to physical machines must
connecting relatively few clients and be done securely. Data security also
meeting few clients’ needs compared to entails encrypting and ensuring that
today’s cloud services models. In most proper data sharing policies are in place.
cases, each server was dedicated to a Furthermore, resource allocation and
single or limited set of applications and memory management algorithms must
was assigned IP addresses and media be secure. Finally, data mining methods
access control addresses. could help detect malware in the cloud.
Today’s data centre, which provides Then, areas of cloud computing
cloud services, is anything but involving the security of data at rest,
respectable, as it is overflowing with security of data in transit, authentication
activities and services that distinguish of users/applications/processes, robust
it from its traditional cousin. For separation of information belonging to
example, its benefits are now available different customers, and cloud legal and
on-demand, by the minute or the hour; regulatory issues should be considered.
it is elastic in the manner that users can
Encryption is also the best option for
have as much or as little of a service as
protecting data in transit. Furthermore,
they want at any given time. The service
authentication and integrity protection
is fully managed by the provider, so the
mechanisms ensure that data only travels
consumer requires nothing other than a
where the customer wants it and is not
personal computer and Internet access.
altered in transit. Strong authentication
The mechanism for addressing security is a must-have for any cloud deployment.
and privacy concerns in cloud computing The primary basis for access control is

320
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 320 23/01/2023 11:27:00


user authentication. Because the cloud Security in the Internet of Things (IoT)

Computer Science
and its data are accessible to anyone The Internet of Things (IoT) is defined
via the Internet, authentication and as sophisticated interaction between
encryption are more critical than ever in the physical and digital world using
the public cloud.
sensors and actuators that support
Separation of a cloud provider’s users computation and network capabilities
(who may be competing companies or in any conceivable object located
even hackers) is one of the more obvious anywhere. Security in the IoT requires
cloud concerns to avoid accidental access special treatment because most Internet
to classified data. A cloud provider security measures need high-processing
typically uses virtual machines (VMs) machines amid the limited-processing
and hypervisors to separate customers. capabilities of sensors and actuators used
Currently, technologies available can in most IoT systems. Due to the limited
significantly improve the security of
resource capability, the security of IoT
VMs and virtual network separation.
considers three layering perspectives of
Furthermore, the trusted platform
sensing, network, and application that
module (TPM) can perform hardware-
map functions in support of IoT systems.
based confirmation of hypervisor and
VM integrity, helping to ensure good Security threats in IoT
network separation and security.
As depicted in Figure 5.32, IoT systems
Finally, legal and regulatory issues are have different security threats that
critical in cloud computing because they need different measures depending on
have security implications. To ensure the threatened function. For instance,
that a cloud provider has solid policies the common security threat to the
and practices to address legal and
sensing layer of IoT systems includes
regulatory issues, each customer must
the unavailability of devices, network
have its legal and regulatory experts
access, and seamless integration of
inspect its policies and procedures to
the device. Common network layer
ensure their sufficiency. Information
threats include routing modification,
security and transmission, compliance,
congestion that leads to denial of
auditing, data retention and destruction,
and legal discovery are all issues to service, unauthorized access to the
consider. Trusted storage and trusted network link, and data leakage. The
platform module access techniques can common threats to the application layer
play a crucial role in limiting access to include unauthorized use of collected
sensitive and vital data in data retention data, information leakage
and deletion.

321
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 321 23/01/2023 11:27:00


Unauthorized Unauthorized
Computer Science

use access Data


leakage

Information
leakage Routing

Lay ation

Ne ayer
modification

tw
L
er
plic

ork
IoT

Ap
Privacy Denial of
leakage service
Sensing
Layer
Seamless
intergration
Availability
Network
access

Figure 5.32: Common security threats of IoT

Security requirements of IoT network access, guarantee a longer


lifespan from ambient temperature/
In addressing measures for IoT security,
humidity/dust, and availability of the
one needs to consider a wide range
sensing device.
of requirements for sensing devices,
communication between the devices Security requirements of IoT network
and services, and applications of the layer
services. The following subsections The security requirements for the IoT
discuss the IoT security requirements of network layer must be robust and
the three layers of the IoT system. self-healing to ensure communication
channels support mobility/dynamic
Security requirements of IoT sensing without allowing route modification
layer and/or data leakage. The security
The main security requirements for the must also fortify strong authorization
IoT sensing layer should set a secure across the network and federation of
environment for IoT sensing devices. administration domains for managing
Security measures in this layer must be networks in different authorities and
scalable to guarantee easy integration of multiple domains to reduce denial
sensing devices. It should offer strong of service attacks as well as support
authorization measures against malicious decentralized service management.

322
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 322 23/01/2023 11:27:01


Security requirements of IoT who have misplaced or neglected their
application layer badge installation of locks and a camera

Computer Science
The security requirements for the IoT system. Therefore, an organisation
application layer must guarantee end- has to employ security personnel; this
authentication method may include
to-end security, incremental deployment
electronic images for the guard to
and privacy to ensure privacy and
examine or a call to another employee
information leakage as well as authorise
to vouch for the individual. Some
the usage of information analyzed from businesses solely rely on the employee’s
collected data. signature in the appropriate register.

Physical security
Concepts of physical security Activity 5.11:
Physical security protects personnel, Search from libraries and the Internet
hardware, software, networks, and data specifically on the concept of physical
from physical actions and events that access control. Write a brief description
could cause profound loss or damage to
of physical access controls using the
an organization or institution. To enhance
following heading:
physical security the organisation
they use one or more options such as Meaning, types, importance and
installing camera, locks and deploying methods of enforcing physical access
security guards. control in security.
Categories of physical threats
When someone attempts to steal Physical security controls
someone else’s computer resources Physical access controls are an essential
or information, this is referred to as layer of preventive or detective controls
theft. For example, when a fire occurs that supplement or complement other
or there is heavy rainfall leading to
forms of control in mitigating the risk
flooding causes damage to computer
of inappropriate or improper access and
resources. This lead to losing personal
information modification.
or organisation’s important information.
Physical access control systems Types of physical security controls
Physical control involves security There are various types of physical
devices such as installation (CCTV control such as deterrent, detective, and
camera), and biometric fingerprint. preventive.
Employees with cameras watching their Deterrent
restroom trips or who must wear badges
to enter a facility will need time to adjust Deterrent controls are intended to avoid
to the new circumstances. Suppose anyone attempting to sidestep security
badges are to be provided to employees; controls, whether the intruder is from
in that case, the organization must also either external or internal. A variety of
implement a system for tracking the measures could be considered deterrents,
procedure for dealing with employees including several overlapping measures.

323
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 323 23/01/2023 11:27:01


Examples of deterrent measures include Importance of protecting people
the installation of CCTV cameras,
Computer Science

The primary goal of physical security


biometric fingerprint locks and sensors. is to protect the individual’s business
Detective and those close to us. At the same time,
Detective controls are used to detect you put security measures and backup
and report on potentially harmful systems in place to ensure that our
events. Burglar alarms and physical facilities, equipment, and data remain in
intrusion detection systems are classic functional condition. If someone loses
examples of detective controls. Systems the people when depending on working
are used to monitor for indicators of with the equipment and data, you have a
unauthorized activity, such as doors rather complex problem.
opening, glass being broken, movement,
and temperature changes. They are Physical concerns for people
often set up to watch for undesirable Any adverse physical conditions may be
environmental circumstances, such as problematic or harmful to the integrity
flooding, smoke and fire, and power of our data, regardless of the type of
outages.
digital downloads on which it is stored.
Preventive
Safety
Preventive controls are used to keep Protection of people falls above any other
unapproved entities from trying to
concern and must be prioritized above
enter our physical security. A primary
mechanical lock is a good demonstration saving equipment or data, even when
of preventative protection. Locks are such actions will directly cause such
nearly ubiquitous for preventing illegal items to be damaged. You might find an
access to available facilities, such as example of this in the fire suppression
enterprises, houses, and other places. systems in use in some data centres. In
many cases, the chemicals, gases, or
Corrective controls liquids used to extinguish fires in such
This includes any measures taken to environments are very harmful to people
repair damage or restore resources and and, in some cases, can kill them if used
capabilities to their prior state following in such an environment, as halogen-
an unauthorized or unwanted activity. based fire suppression systems. For this
Examples of technical corrective controls reason, fire suppression systems are often
include patching a system, quarantining equipped with a safety override that can
a virus, terminating a process, or
prevent them from being deployed if
rebooting a system. Implementing an
incident response plan is an example of there are people in the area. If we were
an administrative corrective control. to avoid the suppression system from
extinguishing the fire because we knew
Protecting people a person was still in the data centre, we
People are the most important resource might lose all the equipment in the data
in any organisation that means to be centre and potentially data that we could
protected because they have some not replace. It would still be the correct
information in their brain or in mind. choice to make with human life at stake.

324
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 324 23/01/2023 11:27:01


Evacuation Practice

Computer Science
Evacuation is one of the best methods Particularly in extensive facilities,
to keep our people safe. In almost a complete evacuation can be a
any dangerous situation, an orderly complicated prospect. If you do not
evacuation away from the source of evacuate quickly and correctly, many
danger is the best thing you can do. lives may be lost in a genuine emergency.
When you make a thorough plan for an As an unfortunate attestation to this, you
evacuation, you ask yourself four basic can look at an example of attacking the
principle questions of where, how, who, 1998 US embassy in Dar es salaam.
and practice.
Where Administrative control
Where we will be evacuating is an Administrative systems are typically
essential piece of information to consider based on a set of rules. They can
in advance, whether we are evacuating be policies, procedures, guidelines,
a commercial building or a residence. regulations, laws, or other similar
We need to get everyone to a rallying bodies, and they can be implemented
point to ensure a safe distance and that at any level, from informal company
you can account for everyone. If we policies to legal provisions.
do not do this orderly and in consistent
fashion, you may have various issues. Businesses put several standard practices
In commercial buildings, evacuation to protect our people and our interests in
meeting places are often marked with general. The background check is one
signs and on evacuation maps. of the most common. When candidates
have progressed far enough through
How the hiring process, they are likely to be
When planning such routes, you should hired. Often, the hiring company will
consider where the nearest exit from a conduct a background check. Accu
given area can be reached and alternate Screen and LexisNexis are significant
routes if some courses are impassable firms that work such background checks
in an emergency. Also, avoid using worldwide. Depending on the location,
dangerous sites or unusable exits in such investigations will typically
emergencies, such as elevators or areas include criminal history statements,
that might be blocked by automatically past employment verification, proof of
closing fire doors. schooling, credit checks, drug testing,
Who and other items.
The most vital portion of the evacuation Examples entail drug tests administrated
is to ensure that you get everyone out by certain employers. Also, visit
of the building and that we can account any checks expected at the start of
for everyone at the evacuation meeting employment and are repeated similarly.
place. This process typically requires at Whether or not such verification is
least two people to be responsible for performed frequently depends on the
any given group of people: one person to specific employer in question, and some
ensure that everyone is liable to be safe. companies may not conduct them at all.

325
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 325 23/01/2023 11:27:01


A
 ctivity 5.12: Creating and companies. Software companies are
designing authentication threatened with very high losses caused
Computer Science

credentials by software piracy.


Suppose you have been hired by one of Fundamentals of software piracy and
the organisations dealing with national copyright
security issues which keeps top secret
Software piracy
and classified information, it dedicates
every employee with their own room Software piracy is the illegal copy and
and shares one; how can you design and use of software in a way other than that
create authentication and credentials that is formally documented by exclusive
ensure unauthorised users when enters rights of the developer in the form of an
their dedicated room with sensitive data individual or organization as described
is denied. in the relevant sale agreement, the
license.
Moreover, software piracy is the illegal
Exercises: 5.5 copying, installation, use, distribution,
1. Mention and describe three main or sale of software in any way other
than that is expressed in the license
categories in which we are typically
agreement. Piracy of software, hard-
concerned with physical security.
disk loading, soft lifting, counterfeit
2. 
Give three examples of physical goods, rental software, and bulletin
control that constitute a deterrent. board piracy can be performed by the
3. Describe the categories of physical end users as well as dealers.
threats.
Legal issues concerning software piracy
4. 
By using the internet facility or
other resources, write about the Types of software piracy
various IoT applications and then, Software may get rid of different
describe how you can help your computer users in several ways. Some
community address various social of these ways are as follows:
and economic problems while Internet piracy
engaging in their daily activities. Internet piracy is now one of the most
5. 
What is residual data, and why straightforward techniques to achieve
is it a concern when protecting pirated software. In some ways, several
security? websites make software available for
free download. Many computer users
Software piracy and copyright download software from the Internet,
which simplifies their lives by trying
Software theft and piracy are rapidly to eliminate the need to visit stores or
ever-increasing problems in the present- send out CD-ROM or floppy disc copies
day software industry. Due to the of software. These techniques have
evolution of software development and made our lives easier, but they have
the Internet, software piracy has become also increased internet piracy, which
the main worry for numerous software takes multiple kinds, like downloading

326
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 326 23/01/2023 11:27:01


or uploading illegal copies of software type of piracy, the software is rented to
over the World Wide Web. individual computers and then returned

Computer Science
Hard-disk loading to the renter. Because of the nature of
its distribution, this method of piracy is
Hard-disk loading occurs when the not as standard as other forms of piracy,
individual or business sells computer but it still occurs. Renting unauthorised
systems preinstalled with illegal access copies of software has always
software updates on hard discs to entice been illegal.
customers to purchase their products
because this type of activity is intended. Ways to reduce software piracy
Software counterfeiting Enforcing strong laws, introducing
penalties, creating awareness and
The illegal duplication and sale of selling software at affordable prices can
copyrighted software to appear authentic minimise software piracy.
are known as software counterfeiting.
Counterfeit software includes the original Software companies are required
legitimate computer’s accompanying to implement anti-piracy protection
manuals and is typically sold below the mechanisms on their software-based
legitimate software’s retail price. It is a products.
type of software piracy, and numerous Enforcing strong laws: The government
organizations are working hard to and software associations should
stop it. Though counterfeit software enforce strong laws/ acts and creates
is inexpensive and widely available, awareness among users. The users
it is dangerous because it may contain should understand that, using pirated
ransomware. software carries high penalties under
Unauthorized use of academic software copyright law for users caught in the act.
They can be penalised and sentenced to
Many software companies sell jail or both punishments.
academic versions of their products to
public schools, universities, and other Product key: The anti-piracy system
educational institutions. The software of using the product key is the most
labelled only for academic or educational reliable. It uses a unique combination
purposes cannot be used for commercial of letters and numbers to differentiate
or other for-profit purposes. Using copies of the software. A product key
educational software for individual ensures that only one user can use the
use in violation of the software licence software per licence or purchase.
creates software piracy. It harms both Legal protection: Companies should
the software publisher and the institution ensure that their software is legally
entitled to receive the software. protected by implementing user
Renting agreements. This practice will inform
consumers that making unauthorized
Renting comprises someone renting copies is against the law. The user
out a copy of the software for business agreement will help prevent people from
or for short-term use, without the unknowingly breaking piracy laws.
copyright holder’s permission. In this

327
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 327 23/01/2023 11:27:01


Watermarking: Watermarks and Types of software copyright
company logos, or names placed and
Computer Science

Copyright Software Licensing: This


stamped on software interfaces, indicate
type of user agreement protects the
that products are legitimately obtained
and are not illegal copies by the end user. intellectual property of a software
developer who created an application,
Crack-proofing: Some software
its source code, and its object code.
programs have built-in protocols that
cause the program to shut down and Copyright law: This area of law covers
stop working if the source code is intellectual property – when the idea is
attempted with, modified, or cracked. the product. For example, the copyright
Crack-proofing, called Tamper-proofing, for a book is about the words, not the
prevents people from pirating the software paper, ink, and binding.
by manipulating the program’s code.
Legal implications upon abuse of a
Software copyright
copyrighted material
Copyright
Various schools of thought have
The sole right that an intellectual property addressed the challenges facing the
owner has is called copyright. Copyright
copyright protection of works in digital
is used to protect various originals
works such as paintings, photographs, form (Mwim & Pistorius 2017:1029–
computer programs, video games, and 1030). Legal scholars’ philosophical
actual databases for the programmer approaches highlight the essential
and software vendors. These rights were characteristics of the digital copyright
initially established by courts drawing a paradigm. These schools of thought range
parallel comparison between the source from abolishing copyright protection
code and the executable program itself of works to a moderate approach that
and blueprints for architectural structures embraces the public-private balance of
and the structure itself. Examples of rights. Extreme minimalists argue that
copyright are novel poems, movies,
lyrics to a song, musical compositions in copyright law is dead.
the form of sheet music, sound recording
and painting. Exercise 5.6
Importance of software copyright
Copyright protection enables businesses 1. 
Rose Joseph gave Juma Hassan
to prevent copying, limit competition, some software to copy onto his
and charge licensing fees and monopoly computer, and now he realizes he is
prices for the produced products. Apart guilty of piracy. What would he do?
from that, software copyright increases
national per capita income as an 2. Mwanampaka schools purchased a
individual and nation. single license of a piece of Windows
Nevertheless, every person’s intellectual 10 Operating system software.
skill is protected and built-up ownership They gave an IT technician the task
of property legally without interfering, of evaluating whether it could be
hence, generating individual money loaded onto several machines. As a
when selling their work. For example, computer science student, advise the
the author produces many books and IT technician to perform the task.
sells them in various schools.

328
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 328 23/01/2023 11:27:01


3. Many companies use resellers and Moreover, institutions’ quality also
third-party distribution channels. depends on intellectual property,

Computer Science
How can you tell if a vendor has which strongly bears competitiveness
the legitimate right to sell another and growth. It influences investment
company’s software? decisions and the organization of
4. What are the risks associated with production. It plays a central role in how
using pirated software? societies distribute the benefits and bear
the costs of development strategies and
policies. For example, owners of the
Intellectual property land, corporate shares, or intellectual
Intellectual property refers to any property are unwilling to invest in the
creation of human mind that is protected improvement and keep up their property
by the law from unauthorised use. if their rights as owners are insecure.
Intellectual property is of the several Finally, intellectual property promotes
distinct types of legal monopolies over innovation. The different forms of
creations of the mind, both artistic and intellectual property, such as patents,
commercial, and the corresponding copyright and trademark, were similar
fields of law. Under intellectual property to traditional legal rights viewed as
law, owners are granted certain exclusive state favours of moral rights. However,
rights to a variety of intangible assets, IP rights are an essential economic
such as musical, literary, and artistic mechanism, an ‘intellectual currency’ of
works; discoveries and inventions; and sorts.
words, phrases, symbols, and designs. Legal issues on intellectual properties
Copyright, patent, and trademark, and They are focused on the use and
trade secrets are protected by both
ownership of computer software which
national and international laws.
is essentially a question of power
Importance of intellectual properties relations between persons today and for
Intellectual properties usually generate many years into the future;
economic activity and jobs in other 1. the forms of legal protection provided
sectors. Domestic companies in are both contingent and far from
developing countries also rely on the coherent in many dimensions; in other
trademark system to protect their brands words, such forms of protection are
at home and abroad. As with patents, not inevitable and could be changed,
trademarks are on the rise in developing indeed quite dramatically changed,
countries. Domestic companies
through reforming the structures and
constitute a substantial part of the users
content of legal regulation;
of these trademark systems. Compared
to developed countries, there is a high 2. the granting of intellectual property
rate of use of the trademark system in to computer software is a form of
developing countries relative to the legal subsidization to a particular
Gross Domestic Product (GDP). industry and technology; and

329
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 329 23/01/2023 11:27:01


3. 
the intellectual property regimes Difference between open source and
that protect computer software have proprietary software
Computer Science

directly impacted the ownership The main feature that makes proprietary
and user regimes that have been software different from open source is
established; the alternatives to that, in open source, the user has the
proprietary, open-source, and free freedom to use the software, own it free
software have been a philosophical and redistribute it to other users rather
and practical response to the current than proprietary software which is
legal issue. intended for selling for earning money.

Categories of software licenses Exercise 5.7


There are two main categories of
1. 
Identify and distinguish between
software licenses: Open source and
open and proprietary software
proprietary (non-open-source) software.
2. 
Operating system software like
Proprietary software
Linux is perhaps the most widely
Proprietary software is owned as private known example of open-source
property by a company (or occasionally software. What are some others
by an individual software developer). that people may not be aware of?
Various intellectual property laws and
3. Kisiwa Ndui Secondary purchased
regimes protect its ‘private proprieties’.
a brand-new computer, but they
Free Software/Open Source: These are did not have an operating system
highly tolerant pacts that allow users software system, and they had no
to freely modify, use, share, and reuse extra money to buy Windows OS.
a software product’s source code. Free From this scenario, as an expert
Software/Open Source (FOSS) licences in IT, what is the solution to help
give users a great deal of control over Kisiwa Ndui without breaching the
using the software. According to this copyright laws and proprietary on
alternative approach, all users have free of charge?
“the right to use the software they
Ethical and Legal Issues
want, for whatever they want, on as
many computers as they want, in any
technically appropriate situation.”. Ethical and legal issues
Nowadays, software are available to meet Ethics
their standards. Of course, this includes Ethics is a branch of philosophy
improving it, fixing bugs, expanding its that deals with right and wrong. It is
functionality, and researching how it a system of principles and rules of
works. conduct recognized and accepted by a
Software allows users to distribute the specific group or culture. Ethics is a field
same software to other users so that they of study concerned with distinguishing
can use it as needed. This redistribution right from wrong and sound from bad in
can be done for free or at an expense that computing.
is not predetermined.

330
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 330 23/01/2023 11:27:01


Legal issue a substitute for the signature and a
means to prevent, avoid, or minimize

Computer Science
The legal issue in a computer system is
the area of an individual’s right to privacy the chance that the electronic document
versus the greater good of a larger entity has been altered must be developed.
such as a company or a society. Moreover, the protection of privacy
For example, tracking how employees in data and international policies pave
use computers, crowd surveillance, the way for the rapid development of
managing customer profiles, and networks and information processing.
monitoring a person’s travel with a Today, the computer allows large
passport. The legal issue is ensuring quantities of personal information to
the security of stored and transmitted be quickly acquired, exchanged, stored
information. and coordinated. As a result, the market
for computer-matched personal data has
The laws currently governing expanded rapidly, and the private-sector
commercial transactions, data privacy, information industry has grown around
and intellectual property were primarily the demand for such data.
developed for a time when telegraphs,
typewriters, and mimeographs were the Lastly, intellectual property is protected
commonly used office technologies, in the administration of digital libraries.
and business was conducted with paper The availability of protected intellectual
documents sent by mail. Computers, property in networked information
electronic networks, and information collections, such as digital libraries
systems are now used to process, and other digital information banks,
store, and transmit digital data in most is straining the traditional methods of
commercial fields. As the spread and protection and payment for the use
use of information technologies in the of intellectual property. Technologies
business world have quickened, the developed for securing information hold
failure of current laws to meet the needs promises to monitor the use of protected
of a digital, information-based society information and provide a means for
has become apparent. collecting and compensating intellectual
property owners.

Importance of ethical and legal issues


Ethical issues and their legal
Firstly, electronic businesses replace implications
conventional paper documents with
standardized computer forms. The Social media raises legal and ethical
need arises to secure the transactions issues that must be carefully assessed
and establish means to authenticate and considered for their risks before
and provide nonrepudiation services creating and disseminating information.
for electronic commerce to verify The legal challenges faced involving
the authenticity and certify that the social media user rights and copyright
transaction was made. The absence of laws. In contrast, activities conducted by
a signed paper document on which any social media such as the Jamii Forum,
unauthorised changes could be detected, Facebook, WhatsApp, and Twitter in

331
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 331 23/01/2023 11:27:01


our countries threaten individual life Exercise 5.8
through interactions made by social
Computer Science

media. Current laws fail to address 1. 


Mention and describe types of
social media directly, and discussions Software Piracy
and conflicts regarding their legal 2. 
Distinguish between ethical and
standing are ongoing in the courts. As legal issues.
legal battles over social media continue,
3. 
Consider the following Scenario:
laws and legal implications are subject to
Fatuma has been employed by TBC
change. (See Tanzania Cyber Crime Act
company working as an accountant
2015). In addition, intellectual property
in the Accounting Department. She
rights pervade the discussion on legal
used to change figures, or double
dilemmas that researchers, archivists,
amount of salary of some workers,
librarians, and others confront when
to make her own profit. From
harvesting social media data. Digital
this scenario, which section and
platforms have become increasingly
subsection of the Tanzania Cyber
complex, and social media use has
Crime Act 2015 were violated?
escalated, creating new avenues of
research data. Organizations must keep
pace with research demand “in a rapidly
changing environment characterized Chapter summary
by new distribution mechanisms, 1. 
This chapter discusses computer
expanding copyright monopolies, ever- security as the protection of
greater technology dependencies, and computerized information
changing user expectations.” Hence systems to prevent illegal access,
current intellectual property regulations use, transmission, disruption,
are not easily applied since much of tampering, or destruction of
copyright law remains unchanged and information system resources.
outdated in an increasingly digital age. Such protection enables users to
safeguard access to information
system resources like hardware,
software, data, and mobile phones.
2. 
Moreover, the techniques ensure
Activity 5.13 Consider the
assurance of communication
Tanzania Cybercrime Act 2015. Discuss
both to users and devices. Access
the following cases regarding the act,
control was established by the tools
the offence and the consequences
used to prevent a network, such as
1. 
Someone pirates the CD and firewalls, IPS/IDS and VPN, from
distributes it by selling it without being installed and checking if an
copyright. attacker was hacking the system or
2. 
Someone publishes someone’s not by using Kali Linux software
photo on social media without his/ tools for advanced Penetration
her consent. tests. Kali Linux is an open-source,

332
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 332 23/01/2023 11:27:01


Debian-based Linux distribution 3. 
The mouse on your computer
geared toward various information screen starts to move around and

Computer Science
security tasks, such as Penetration click on things on your desktop.
Testing, Security Research, What should you do?
Computer Forensics and Reverse 4. 
Distinguish between a Copyright
Engineering. and a Trademark.
3. 
Lastly, the advancement of 5. What is the defining difference
technology brought ethical between computer security and
hacking into a business in society; information security?
consequently, cybercrimes,
terrorism crimes and money fraud 6. How informed do you keep yourself
robbery activities give a chance on network security-related news,
to nourish. Increasing crimes in and how often do you check out
society lead to existing software these stories? Where do you get
piracy and copyright that make your security news?
all misbehaviours and criminal 7. Do you think, for security reasons,
offences should be dealt with everything that happens on the
according to its laws. internet should be analysed by
public security services?
8. Elaborate on the following five
cybersecurity risks in the banking
Revision exercise industry: (a) Unencrypted data, (b)
1. Discuss in detail the risk assessment Malware, (c) Third-party services
process. that are not secure, (d) Data that
2. 
A friend sends an electronic has been manipulated (e) Spoofing.
e-greeting card to your work email. 9. Define the term hijacking as it
You need to click on the attachment relates to cybersecurity.
to see the card. A while back, the 10. 
Evaluate the weakness and
IT help desk received several the strengths of the Tanzania
complaints that one employee’s Cybercrime Act 2015
computer sent out Viagra spam.
They checked it out, and the 11. You discover an active problem in
reports were accurate. A hacker your organization’s network, but
had installed a program on the it’s out of your sphere of influence.
computer that automatically sent There’s no doubt that you can fix it,
out tons of spam emails without though, so what do you do?
the computer owner’s knowledge. 12. 
What type of physical access
How do you think the hacker got control might you put in place to
into the computer to set this up? block access to a vehicle?

333
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 333 23/01/2023 11:27:01


Information technology
Computer Science

Chapter
Six
career and environment

Introduction
Advances in Information Technology (IT) can never be discussed without associating
them with users (people) and their environments. Users’ knowledge of the benefits of
IT and their ability to apply that knowledge can lead to a successful personal career.
IT facilitates organisations to achieve their objectives and helps society to acquire a
superior quality of life. Hence, communities, businesses, and industries worldwide
reap huge benefits from IT if it is deployed intelligently and carefully. Therefore,
information systems must also be developed to be accepted and work well and safely
within their environments based on the intended business and country’s goals and
strategies. In this chapter, you will learn more about IT career opportunities and
the IT environment. The competence gained will enable you to effectively manage
businesses or guide you in making the right IT career choice.

and software engineering are some of


Think about the following:
such competitive IT occupations. Since
Which IT professional and personal most companies and organisations have
competencies are you interested in, and automated their core functions, IT skills
how are you expecting to develop them? have become inevitable in the different
dimensions of our life. Regardless of
How can you use the career perspective what industry you anticipate joining,
as a mirror to reflect on your future IT knowledge of information technology can
career? help someone stand out as a competitive
What is the future of IT careers in the candidate. As information technology
jobs market, and how IT helps and becomes increasingly integrated into
provides support to other professionals? daily life, the opportunities available for
Imagine how the world of work could be those with IT skills and competence to
without Information Technologies. operate such IT systems have expanded.
Therefore, studying IT may be an
excellent choice if a person is interested
IT career opportunities in being an IT professional.
Information Technology is one of the
most competitive professions in the Roles of various IT career opportunities
market. Professions like IT Security, There are several career opportunities in
Artificial Intelligence (AI), Cybercrime, the IT industry. Today, the demand for

334
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 334 23/01/2023 11:27:02


IT experts is rising because companies, (f) 
Performing data processing
institutions, and governments are operations according to a business

Computer Science
revolutionising how they undertake their production schedule
daily activities. In that regard, there are (g) 
Maintaining computer equipment
many areas where a person can work as and inventory and organise repairs
an IT professional. For example, when as needed
you anticipate working as a system
administrator, there are several roles, (h) 
Creating and managing users
that you are required to perform. The credentials to ensure the security of
most common career opportunities the organization.
are such as, Computer operator,
Computer technician
Computer technician, computer system
analyst (CSA), System administrator, A computer technician regularly
Computer programmer, Network maintains, upgrades, and repairs
architect/or Network administrator, computers and their accessories. The
Cloud computing engineer, Database computer technician is on the front lines
administrator, IT project manager, Web of IT and performs the following duties:
developer, Information security officer, (a) 
Troubleshooting and solving
Business Intelligence Analyst, and problems related to hardware and
Mobile application developer. software
(b) 
Assembling, upgrading computers
Computer operator
and installing software patches and
According to standardised operating upgrades
instructions, the computer operator
(c) Monitoring servers and networks
monitors and manages computers and
electronic data-processing equipment. (d) 
Maintaining computers and
Depending on the employer or peripherals, and managing data
employing institutions, key roles of the security
computer operator might include: (e) 
Ensuring that computer systems
(a) 
Managing and improving a are all optimised and run efficiently
company’s network performance (f) 
Addressing users’ explanations of
by troubleshooting hardware and computer problems and evaluate
software problems their needs
(b) 
Entering batch data into the (g) 
Guiding users through the steps
computer for processing necessary to resolve their problems
(c) Logging all information processing and train them to use computer
activities and exceptions hardware and software properly.
(d) Performing backup to reduce the
Computer Systems Analyst
risk of data loss
A Computer Systems Analyst (CSA) is
(e) Identifying and correcting file and
responsible for analysing and designing
system errors
hardware and software tools to improve

335
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 335 23/01/2023 11:27:02


overall IT function in the organisation. (c) 
Set up users’ accounts and ensure
The CSA is also responsible for security through access controls
Computer Science

identifying the organization’s needs and (d) 


Upgrade the systems with new
problems and then designing a solution updates and releases
for the problem. The roles of CSA
include the following: (e) 
Maintain records of organisational
IT assets usage
(a) 
Managing the installation, deploying,
and testing of new computer (f) 
Train end-users on new emerging
systems technologies
(b) 
Training end-users and preparing (g) 
Build internal technical
instruction manuals and other documentation, manuals, and IT
essential documentation policies
(c) 
Developing new and upgraded Computer programmer
functionality for existing computer A computer programmer, also known
systems as a software engineer, is responsible
(d) 
Collaborating with managers for designing and creating systems
and other experts to assess an and software programs. Some
organisation’s IT needs key responsibilities of a computer
(e) 
Researching and analysing the programmer include the following:
possible advantages and drawbacks (a) 
Systems integration and software
of emerging technologies development
(f) 
Selecting and configuring the new (b) 
Examine users’ needs and create
hardware and software to meet the computer programs that address
organisation’s needs. those needs
(c) Train end-users on newly deployed
System administrator software and systems
A system administrator is essential in (d) Manage database systems
organisations that have computerised
their organisational functions. A system (e) 
Analyse algorithms, write computer
administrator is responsible for system code, and modify source code
maintenance, data management, crisis (f) 
Design and test computer structures
management, and profile management. and programs
The following are some responsibilities (g) 
Write system instructions, debug,
of a system administrator: and maintain operating systems
(a) 
Install, configure, and troubleshoot (h) Planning and modelling software
software and hardware issues and
outages (i) 
Upgrade the existing programs and
repair program errors
(b) 
Manage the network servers
and monitor their performance
according to requirements

336
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 336 23/01/2023 11:27:02


Network architect/ Network Solutions architects, Cloud developers,
administrator and System operations engineers. The

Computer Science
A Network administrator is responsible key responsibilities of a cloud computing
for analysing, defining, designing, engineer may vary depending upon
building, and maintaining various data the vertical position. Cloud computing
communication systems and networks, engineer may have many other
including LANs, WANs, and the subcategories of career, including;
Internet. The central roles of a Network (a) Cloud security engineer
administrator include the following: (b) Systems engineer
(a) Analyse the workflow and network (c) Cloud developer
security needs and establish the
network (d) Cloud architect
(b) 
Assess network performance (e) Network engineer
problems and provide solutions
A Cloud computing engineer
(c) 
Network installation and testing is responsible for the following
of equipment, connections, and responsibilities:
firewalls
(a) Developing and maintaining cloud
(d) Define the policies and procedures solutions following best practices
related to the network
(b) Designing and developing modular
(e) Monitor and analyse the network cloud-based systems
and troubleshoot related problems
(c) Ensuring efficient functions of data
(f) Fine-tune the network to enhance storage and processing functions in
the performance for users the cloud infrastructure
(g) Implement, monitor, and evaluate (d) 
Responsible for securing cloud
security protocols infrastructure and its components
(h) Train the end-users on the safe and (e) 
Conducting and managing data
secure use of the network analytics in the cloud environment
(i) 
Test, evaluate, install network (f) 
Providing technical support for
enhancements periodically and cloud clients and users in the
update the network organization
(j) 
Maintain accurate documentation
and records of the network Database administrator
Nowadays, organisations and businesses
Cloud computing engineer produce and collect large amounts
A cloud computing engineer is of data to run their daily operations.
responsible for defining, designing, Therefore, the database administrator
implementing, and maintaining systems is needed to store, secure, and organise
and solutions that rely on cloud systems, the company’s or organisation’s
platforms, and infrastructure. The three massive data. The roles of a database
major types of cloud Engineers are administrator are as follows:

337
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 337 23/01/2023 11:27:02


(a) 
To perform administration (f) 
develop and implement the ICT
of systems, databases, server policy of the organisation.
Computer Science

virtualisation and server


infrastructure Web developer
(b) 
To manage security aspects to A web developer is responsible for
the assigned systems, database, designing, creating, and maintaining
integrity controls, related records web applications. An individual can
and documents choose to work as: a back-end developer
(c) To install, upgrade, and maintain (working mainly with the technical
software applications and databases development of the website), a front-end
developer (responsible for the look and
(d) 
To undertake daily maintenance, design of a website), and a webmaster
testing, backups, and recovery (maintain and update websites). It is
of systems and databases per the also possible to perform all these roles
organisation’s policy and standards depending on the arrangement. A web
(e) 
To ensure high availability of developer is responsible for:
systems is working efficiently and (a) 
conducting meetings with clients
services and evaluating their website
(f) To monitor standards, procedures, development needs;
and access methods for the database (b) 
building and testing the web
management system applications and integration with
IT project manager respective databases;
The IT project manager is responsible (c) code writing for the website;
for planning, initiating, and executing (d) 
cooperating with the website
complex IT projects and initiatives. IT stakeholders’ team;
project manager is accountable to: (e) creating user-friendly, operational,
(a) 
meet with the organisations’ and accessible layouts;
stakeholders to help determine the (f) 
cracking and monitoring the site
scope and timing of IT projects; traffic or other key performance
(b) 
work with technical teams to measure or analysis.
identify barriers or issues and
determine options for how to Information security officer
address them; An Information security officer
(c) conduct regular checks to monitor protects and manages the organisation’s
project progress and address network and systems against security
unexpected issues; vulnerabilities and potential fallout.
Information Security Officer manages
(d) 
create overall IT project work and creates disaster recovery plans,
rolling out institutional plans; conducts assessments of security threats,
(e) consult technical teams to identify develops procedures for resolving
what resources are needed for a potential threats, and keeps an eye on the
project; and new threats in the industry. The roles of

338
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 338 23/01/2023 11:27:02


IT security officer include the following: Mobile application developer

Computer Science
(a) 
Monitor the systems for security A mobile application developer is a
risks or possible vulnerabilities software developer specialising in
(b) 
Supervise the organisation-wide mobile technology, such as developing
implementation and management various applications (or apps) for Google’s
of safeguard measures such as Android, Apple’s iOS, and Microsoft’s
firewalls and antivirus software Windows Phone platforms. The typical
(c) Prepare reports related to security roles of a mobile application developer
risks and guide on the prevention include the following:
measures (a) 
To prepare the entire application
(d) 
Ensure timely systems testing to lifecycle (concept, design, test,
identify potential weaknesses and release, and support)
implement solutions
(b) To generate fully functional mobile
(e) Monitor network usage to ensure applications by writing clean code
compliance with security policies (i.e., coding, testing, debugging,
documenting, and monitoring)
Business intelligence analyst
A Business Intelligence (BI) analyst is (c) 
To work together with various
responsible for retrieving and analysing departments in the organisation
data within a company or organisation. regarding new deployments
The roles of BI Analyst are as follows: (d) To contribute to the development
(a) 
To make consultations with of project schedules and workflows
management and the essential (e) 
To propose changes and
stakeholders to define goals enhancements to software
(b) To conduct research, develop, and applications
implement data-gathering methods
(f) 
To prepare the unit and user
(c) To provide analysis/analytics and interface (UI) tests for identifying
synthesis of data (descriptive, malfunctions
diagnostic, predictive, and
prescriptive data analytics) (g) To conduct research and propose
new mobile products, applications,
(d) To report on research findings and
and protocols
recommend solutions
(e) 
To collaborate with co-workers (h) 
To stay up to date with new
and management in implementing technology trends
various strategies
(f) 
To evaluate the effectiveness of
implemented strategies
(g) To develop and manage BI solutions

339
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 339 23/01/2023 11:27:02


Activity 6.1: Identifying Activity 6.2: Exploring
IT opportunities and their IT careers around your
Computer Science

respective responsibilities community


Resources: Computer, Internet Resources: Computer, Internet
connectivity, IT career roles checklist, connectivity, IT career roles checklist,
notebook and pen. notebook, and pen.
Procedures: Procedures:
1. Visit various organisations’ 1. Visit at least two websites or
websites in Tanzania. institutions of your choice.
2. 
Navigate through the job 2. Record all business operations
advertisements pages and identify or functions performed using
the IT-related jobs and the roles/ computerised systems.
responsibilities. 3. Identify the roles of each person in
the business operations identified
3. For the job opportunity identified
in (number 2).
in part 6.1 (2), write down the
responsibilities assigned. 4. Meet with responsible persons in
each IT-related department, ask for
4. 
Compare each IT career role their roles, and document them.
and responsibilities assigned to
5. Compare the roles/responsibilities
each identified job opportunity
with those you have learnt and
and compare them across the
those summarised from activity 6.1.
organisation
5. 
Write all similar job roles and
responsibilities assigned among all Exercise 6.1
institutions or the organisation you 1. What are the key responsibilities of
have visited. the following IT specialists?
6. What do you conclude from part (a) Computer technician
6.1(1-5)?
(b) Web developer
7. Prepare a list of IT career roles and
(c) Database administrator
their responsibilities in your report.
(d) Information security specialist
Note: A list of IT careers’ roles and 2. Assume you have been employed as
responsibilities will be used as a resource a Business intelligence analyst. What
in the next activity you need to carry out would be your key responsibilities?
outside the school.
3. 
Describe the emerging IT
opportunities with their job roles.
4. Suppose you have been allowed to
work with the financial firm in the
IT department. What IT profession
would fit you? State the expected key
responsibilities.

340
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 340 23/01/2023 11:27:02


Relationship of various roles of IT 2. 
Identify various roles of IT
career opportunities professionals and explain how they

Computer Science
Principally, most of the roles of the relate to or interact with each other.
IT profession depend on each other. 3. 
Use your report and experiences
There are various IT careers within the from activity 6.1 to ascertain how
organisation, each having its specific these IT carriers roles are related to
roles to be undertaken by involving each other.
various IT experts such as web 4. Share your finding with your fellow
developers working together with IT in the group to make a relationship
security specialists. Nevertheless, each among IT careers.
role is essential to the company’s overall
performance and operations. The IT 5. Present your findings to the whole
professional responsibilities do relate to class for discussion.
each other in some contexts. Similarly, 6. 
Summarise the class discussion
a web developer sometimes needs an IT critical points on the relationship
security specialist to assess the website’s and interaction among the identified
vulnerability before launching. In other careers.
words, the two experts can interchange
or undertake some responsibilities
together.
IT and environment
It can be said that, within the IT industry, Technological advancement has had
the experts depend on each other based a tremendous impact to our natural
on their professional skills. Remember environment and on peoples’ daily lives.
that “you cannot be an expert on Technology carries both advantages and
everything.” You can only do the work disadvantages for human beings and the
related to your skills, and the rest will be environment. In other words, technology
done by others whose skills fit into that is a two-edged sword, capable of both
aspect. causing and repairing environmental and
people’s lives damage. The following
A
 ctivity 6.3. The relationship are some positive and negative impacts
between various roles of technology on the environment.
and responsibilities of IT Air and water pollution: When dangerous
professionals or excessive amounts of gases such as,
Resources: carbon dioxide, carbon monoxide, sulfur
Computer or smartphone with Internet dioxide, nitric oxide, and methane, are
connectivity, library resources, IT roles produced during manufacturing and use
reports, piece of paper and pen. of IT device/equipment, into the earth’s
Procedures: atmosphere, they will damage or pollute
the air. Air pollution has damaging
1. 
Visit multiple sources such as the
health effects on people and animals and
Internet, library, and employers.
contributes to global warming. It may

341
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 341 23/01/2023 11:27:02


cause rising levels of greenhouse gases (c) IT has facilitated several
services such as building or road
Computer Science

in the atmosphere, thus trapping the


thermal energy in the earth’s atmosphere, construction, weather forecasting,
causing the rising of global temperature. and simulation.
If not managed properly, the ‘end-of- (d) IT is used to maintain and manage
life’ of IT products may contaminate financial and business documents
water bodies such as the sea, lakes, and in business, such as Mobile and
rivers, destroying aquatic ecosystems. Simbanking.
Resource depletion: This is another (e) 
Information technology plays a
negative impact of IT on the environment. pivotal role in various countries’
Resources (e.g., fossil fuels and political landscapes, especially
minerals) might be consumed quickly in electoral campaigns. In this
to feed the information technology context, technology influences
industries before replenishing them. public opinion and mostly increases
young people’s involvement in
Impact of IT on people’s daily lives
political life.
IT has made life easier, particularly for
(f) 
IT has improved the timely
those who embrace it. People can now
distribution of information through
utilise the Internet and social media
different media and communication
for various purposes, including online
in homes and workplaces through
trading or business. However, IT has a
social networks and emails.
detrimental impact on peoples’ lives.
Environmental pollution, for example, (g) It contributes to the national Gross
can cause human and animal deaths. Domestic Product (GDP) growth
Countries are currently witnessing the through increasing revenues due to
improper management of electronic IT-based economic activities.
wastes; thus, putting more risks on the
ecosystem. Disadvantages of information technology
The disadvantages of information
Advantages of information technology
technology to people’s life are as
The advantages of information technology follows:
to people’s lives include the following:
(a) Prolonged use of computers,
(a) It has made the education process
tablets, and cellphones can lead
more efficient and productive in
to digital eyes strain, dry eyes,
teaching and learning.
blurred vision, headaches, and
(b) In the health system, information shoulder and neck pain. The
technology has improved the screen glare, lousy lighting, and
production and supply of medicine, improper viewing distance or
medical devices, and e-consultation. angle contribute to all these.
The available digital devices in the (b) Health-related problems due
health sector facilitate medical- to the improper dumping of
related activities such as surgery. IT ‘end-of-life’ materials or
electronic wastes (e-wastes).

342
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 342 23/01/2023 11:27:02


(c) Reduced face-to-face interaction: Exercise 6.2
Nowadays, people mostly prefer

Computer Science
1. Discuss the disadvantages of
online communication rather technology to human lives.
than face-to-face conversations,
so they tend to become more 2. Explain how youth can make use of
individualistic and introverted. technology to employ themselves.
(d) Job placement and replacement. 3. Explain any five advantages of being
The use of IT simplify work; the an IT expert in the 21st century.
work which can be performed 4. 
What do you understand by the
manually by many people can statement “improper dumping of IT
be done by one person using a ‘end-of-life’ materials”?
computer-aided device.
5. Discuss any five impacts of IT
A
 ctivity 6.4: Identify advancement on the environment.
information technology’s
impact on the environment Methods for safe disposal of computer
and provide ways to reduce and related hardware
its effects. The IT devices keep a lot of information;
Resources: therefore, when you dispose of, recycle, or
donate such devices to others, be careful
The computer with Internet connectivity
because you might unintentionally
and notebook.
disclose sensitive information, which
Procedures: cyber criminals could exploit. These IT
(a)  Open the computer and the web devices may include but are not limited to:
browser of your preference. (a) Electronic gadgets (e.g., computers,
(b) Write the URL of the search engine tablets, smartphones) which can
like google, Aster vista, or dogpile automatically store and process
and press enter to open it data.
(c) Write the search terms in the search (b) Digital media such as digital
field to search for “the impact of cameras and media players which
information technology on the can create, store, and play digital
environment”. Read and document content.
the impacts. (c) External hardware and peripheral
(d) Search for, and document the ways devices (such as printers, monitors,
to reduce adverse effects and external hard drives) that
(e) Then, write your report about the contain permanently stored digital
findings using the following guided characters.
questions: (d) Electronic gaming consoles,
(i) What are the identified impacts computers, or digital devices that
of information technology on the output visual images or video
environment? signals or display a video game.
(ii) What have you determined as There is a variety of methods for the
ways to reduce adverse effects safe disposal of IT-related materials.
on the environment? Nevertheless, before disposing of IT

343
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 343 23/01/2023 11:27:02


devices, consider backing up the data or (d) Carpal Tunnel Syndrome (CTS)
cleaning a gadget.
Computer Science

(e) Wrist pain


The disposal of electronic waste (or
(f) Psychological illness such as
e-waste), which are electronic materials
that have reached the end of their useful arthritis, internet addiction, and
lives and have to be discarded; can be cybersex addiction
done in the following ways: (g) Reduced physical activities
(a) Donation to a nonprofit organisation
Precautions on IT-related health
(b) Recycling electronic gadgets, a
hazards
strategy that may save natural
resources The IT user must understand all health
(c) Choosing a reliable and certified risks associated with using IT devices.
vendor or company responsible for As part of the recommendation, first,
disposing of outdated electronic you should learn how to use these
materials technologies without experiencing any
problems rather than avoid them. Some
(d) Selling your older hardware is
IT users are unaware of the health-related
another safe method of disposal
issues they may face due to operating
(e) Refurbishment of IT devices, IT devices. Second, users of computer
an action that may extend their technologies should immediately
lifetime receive education on the healthy use of
Therefore, before disposing of computers these technologies.
and related devices, make sure that you;
Individuals may suffer serious health
(a) 
backup significant files and problems if the necessary precautions
information, are not taken. Consequently, institutions
(b) erase all data in your hard drive, and may suffer a significant decrease in the
(c) dispose of your IT devices. workforce and financial losses if the
required precautions are not accepted.
Health hazards associated with the Precautions must be taken to reduce
use of IT users’ IT-use-related health problems.
IT-related hazards are potential health The following are some of the precautions
problems caused by the prolonged use for IT-related health hazards:
of IT tools. The prolonged use of IT (a) The use of ergonomic chairs to help
tools, such as playing games, browsing avoid pain
the Internet, and instant messaging, can
contribute to prolonged health problems (b) Take a brief break to stretch and
for users. Some examples of health walk around
hazards associated with the use of IT (c) Use of low-intensity light fixtures
devices include: or the use of LCD or plasma screen
(a) Back and neck pain (d) The use of screen contrast that can
(b) Eye strain not harm your eyes and a moderate
lighting environment
(c) Pain in the hands and arms

344
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 344 23/01/2023 11:27:03


A
 ctivity 6.5: Identify health have automated their core
hazards associated with using functions, IT skills have become

Computer Science
IT devices. inevitable in offices.
Search from the Internet and identify 2. Studying IT may be an excellent
any five health hazards associated with choice if you are interested in
using IT devices. From your search, becoming a computer operator,
assess the uses of IT devices among the IT manager, System analyst,
community members and the impact System administrator, Computer
associated with their use. programmer, IT trainer, Data
clerk, Webmaster, IT laboratory
Exercise 6.3 technician, and Maintenance
engineer.
1. List down six (6) IT devises you 3. IT has made life easier, particularly
know. for those who can interact with
2. Outline five IT-related hazards opportunities like utilising the
due to the prolonged use of the Internet and social media.
computer. 4. 
Advancement in IT has brought
3. Explain with examples the impact about a tremendous impact on
of improper disposal of ‘end-of- the environment, particularly
life’ computer hardware on the the negative impacts on our
environment. environment and people’s daily
lives.
4. 
Discuss the precautions to avoid
the impact of prolonged use of IT- 5. 
Prolonged use of computers,
related devices in your groups. tablets, and cellphones can lead to
digital eye strain, which can easily
5. Describe safe methods of disposing be realised with symptoms such as;
of the computer hardware. dry eyes, blurred vision, headaches,
6. What precautions should be taken and shoulder and neck pain.
before disposing of the computer 6. 
Technology has a detrimental
hardware? impact on peoples’ lives,
particularly the youths trying to
cope with a changing world and
Chapter summary culture.
1. Information Technology is one of 7. For several reasons, it is essential to
the most competitive professions decide on the proper ways of safely
in the market. Professions like IT disposing of electronic devices.
Security, Artificial intelligence, 8. 
Disposing of computers and
Cybercrime, and software IT-related devices should be
engineering are some of the considered for all unused ones.
competitive IT occupations. Since During disposal, proper procedures
most companies and organisations need to be followed.

345
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 345 23/01/2023 11:27:03


Revision exercise
Computer Science

1. Search from the Internet and identify the career opportunity of your choice.
Explain the roles and necessary skills required for that career.
2. Using different sources, identify IT career opportunities that are currently
highly demanded.
3. The advancements in IT are associated with both advantages and disadvantages.
Explain them with vivid examples.
4. With examples, describe how one IT profession relates to each other.
5. List down the health-related problems linked to the use of IT devices.
6. Improper disposal of electronic waste may damage the environment and pose
various challenges to human health. Examine five of these challenges.
7. Addiction to IT devices like computers and mobile phones is an emerging
challenge for youths. Explain any four measures that can be taken to address
these challenges.
8. Study various technologies in Tanzanian society and point out any four adverse
effects they bring to peoples’ healthy and environments.
9. 
Unemployment has been a serious global issue for youth, particularly in
developing countries like Tanzania. It adversely affects their economic growth.
So most youths seek limited office jobs. As an IT expert, how would you advise
the unemployed youth to take advantage of IT end-of-life disposed of materials
to address the issue of unemployment?
10. As a student in IT subject combination, how can you advise people to realise
the role of IT in 21st-century socio-economic advancements?
11. 
End-of-life IT technological materials litter badly colour our surrounding
environments. Suppose one of the Community based organisations dealing
with environment and youth affairs requested you to give detailed advice on
how these end-of-life technological materials disposed of illegally can be an
opportunity to address youths’ unemployment; what would be your advice?

346
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 346 23/01/2023 11:27:03


Chapter Emerging technologies

Computer Science
Seven
and trends

Introduction

Since the end of the 18th century, the world has gone through four industrial
revolutions. In the first, second, and third industrial revolutions, production was
based on steam, electricity, and Information Technology respectively while the
fourth industrial revolution is derived by cyberphysical systems, which connect
intelligent machine, smart gadget, processes and customers. In this chapter,
you will learn about emerging digital technologies that drive the 4IR and their
relevance, application, and impact. The competencies developed will enable you
to understand and apply emerging technologies and trends driving 4IR in your
community and industry.

Think about the following: Meaning of emerging technologies


and trends
1. Using a smartphone’s camera to view
Emerging technology is defined as new
buildings along a street and then be
technologies that advance the interaction
notified about houses or rooms that
between computers and humans.
are available for rent.
Emerging technology results from
2. 
An intelligent application that can
advancing collective knowledge
talk with humans and respond to
and application related to methods,
their questions.
techniques, skills, and procedures
3. Using a computer to print a physical that address current and future
item such as a cup or a model of a industry challenges and opportunities.
building. Emerging technology has applications
in many industries such as agriculture,
Concept of emerging technologies health, education, transport, tourism,
and trends entertainment, communication, media,
This section describes emerging and energy. In most cases, technology
technologies that drive Fourth Industrial continues to evolve due to further
Revolution (4IR) and their trends. It improvements necessitated by inventions
also presents examples of emerging and developments. The world is
technologies. The section finally changing quickly, resulting in emerging
highlights the significance of these modern data inputs, processing, storage,
technologies for present and future and output technologies. In the IT
socio-economic development. industry, technological advancements

347
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 347 23/01/2023 11:27:03


are happening at light’s speed, from allows police, to discover criminals
stand-alone computer applications to and determine their true identities by
Computer Science

web and mobile applications. Also, it scanning fingerprints. It is also used by


advances from centralised applications immigration officials to track people
to distributed systems to cloud-based crossing the border.
applications. In terms of emerging Blockchain: Emphasises building
technologies, the trend is changing from distributed and decentralised databases
various spheres, including artificial whose records are hard to change. For
intelligence and machine learning, to example, achieving unchallengeable
the Blockchain, autonomous vehicles, records in a land registry guarantees the
virtual reality, augmented reality, impossibility of illegally transferring a
unmanned aerial vehicles, big data, and title deed.
the Internet of things. Technological
trends can also be viewed in generations Autonomous vehicles: Autonomous
such as the 1st, 2nd, 3rd, 4th, and 5th. vehicles are self-driving vehicles
operating independently without a
Typically, emerging technologies have human driver. For instance, the use of
a trend. The trend is a general shift or autonomous vehicles which promises to
change in the direction of something reduce accidents.
new or different. In the context of
digital advancements, a trend refers to a Virtual Reality (VR): This is an entirely
general direction of digital technologies, immersive experience created in a
including an impact they currently make computer-simulated environment to
or expect to make in the future. replace a real-life environment. It is
applied in entertainment to provide near
Examples of emerging digital feelings simulated by computers.
technologies that drive 4IR Augmented Reality (AR): AR is a
Emerging digital technologies are technologically enhanced representation
cropping up in various industries and of the actual world created by supplying
individual life. These technologies are additional digital information.
artificial intelligence, machine learning, An Unmanned Aerial Vehicle (UAV):
Blockchain, autonomous cars, and virtual This is an aircraft that does not have a
and augmented reality. The following human pilot or passengers on board and
outlines give a quick overview of some is operated entirely or partially remotely
of the emerging digital technologies: by a human. For example, some small
Artificial Intelligence (AI): Enables drones are used to take aerial pictures in
computers to mimic the thinking and a city or crowded areas.
actions of human beings. For example, Emerging digital technologies play a
map-based location services can guide crucial role in the modern world by
you along a route to your destination. making it a better place to live. Their
Machine learning: Computers learn significance is invaluable to count,
from existing data and can perform but fewer of them may be highlighted.
new tasks based on experience gained Emerging technologies help us to do the
already. For example, machine learning following:

348
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 348 23/01/2023 11:27:03


Automate jobs that humans previously action before colliding.
performed: Automated devices

Computer Science
nowadays, perform various jobs both
with high risk and with a risk free to
humans. Robots, for example, carry
out various repetitive tasks in advanced
manufacturing industries, such as
painting a car or welding metals. Figure 7.1
shows a robot welding metal in a factory.
They relieve humans from dangerous
environments, for example, excessively
hot temperatures, dangerous rays, and
toxic environments.

Figure 7.2: Vehicle-to-vehicle


communication
Diagnose and monitor patients’ health:
Wearable devices, as shown in Figure
7.3, communicate sensed health
information to cloud servers to help
medical doctors predict a disease state
Figure 7.1: A robot doing its task of and appropriate treatment.
welding metals (Source: http://www.
automate.org)
Increase efficiency in productivity: Once
programmed, machines may accomplish
tasks faster and more accurately than
humans. For example, extensive data Figure 7.3: Wearable respiratory
taken from social media messages devices.
(posts) may be analysed in less than an Features of emerging technologies
hour using machine learning algorithms
to identify subjects and the main issues The following are some of the features
mentioned. This task might take many of emerging technologies:
days for humans to complete. 1. High processing power compared
Improve safety in vehicles: Vehicle-to- to traditional technologies
vehicle communication, shown in Figure 2. Capability to store and analyse a
7.2, is expected to improve safety by large volume of data within a short
allowing almost colliding automobiles time
to detect each other and take prompt 3. 
Advanced analytics model to
generate useful information
349
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 349 23/01/2023 11:27:03


4. Radical novelty leads to disruptive trend emerged: hardworking individuals
transformation were replaced by steam engines that use
Computer Science

5. Automated decision-making heat as a crucial technology. Remember,


steam is created when water is heated.
Following the invention of the steam
Exercise 7.1 engine, the first industrial revolution
Answer the following questions: began with this shift, whereby, steam
was used to power everything from
1. Matinde, a form five student, doubts
agriculture to the textile industry.
whether the Short Message Service
(SMS) is an emerging digital This revolution was characterised by
technology or not. How can you mechanisation, where mechanical
help Matinde to clear these doubts? machines replaced handcraft activities
Explain your answer by exploring in production. Examples of machines
various sources. invented in the first industrial revolution
powered by steam include the
2. Explain how Blockchain technology
mechanised spinning jenny shown in
can be used in agriculture.
Figure 7.4, the power loom in Figure 7.5,
3. 
How do emerging technologies the steam locomotive shown in Figure
that drive 4IR differ from other 7.6, and the steamship in the transport
technologies? industry. Also, steam power was used
to pump water out of coal mines, and
Industrial revolutions that steam pump was known as the
“atmospheric engine”. It was generally
The modern world has changed an the age of mechanical production
agrarian and handicraft economy to one
dominated by industry and machine
manufacturing. These technological
changes introduced novel ways of
working and living and transformed
societies on how they interact.
The world has experienced four
industrial revolutions. These revolutions .
are the first industrial revolution, second
industrial revolution, third industrial Figure 7.4: Spinning jenny machine
revolution and fourth industrial
revolution.
First industrial revolution
Before the first industrial revolution,
hardworking people used their hands
to power machines (muscle power).
Production took place in people’s homes.
From the end of the 18th century, a new Figure 7.5: Power loom machine

350
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 350 23/01/2023 11:27:03


Second industrial revolution

Computer Science
The second industrial revolution was
sparked by discovering new energy
sources in about 1870, mainly electricity
and oil. Internal combustion engines
made this discovery possible, which
eventually succeeded steam engines.
During this time, telephones and vehicles
were also invented. Steel supplanted
iron in construction because it was more
durable and less costly, allowing train
lines to be built for less money. With
the invention of the telegraph and the
telephone, communication techniques
changed considerably, and transportation
systems evolved dramatically from
Figure 7.6: A steam-powered locomotive using steam to petroleum oil as crucial
fuel.
 ctivity 7.1: Watching
A Before electricity, people used wood,
animation or videos of steam candles and gas lamps for lighthouses
powered engines. and factories. Therefore, the invention
of electricity brought a new era of high-
Resources: voltage alternating current. Besides the
Computer with internet connection, telephone invention, electricity led to
video playing software, pen and piece of other inventions such as light bulbs.
paper. Early automobiles built on combustion
Procedures: engines started to be sold to the public in
1. Open the YouTube channel (https:// this period. Also, this period witnessed
www.youtube.com/) the creation of the first aeroplane flights,
as shown in Figure 7.7. Furthermore,
2. Use the following phrase to search
the typewriter that computers have now
the animation or video: “steam
replaced constituted the inventions of
powered engine”
the second industrial revolution.
3. 
Play and watch the video or
animation.
4. 
After watching the video or
animation, answer the following
questions:
(a) 
What was the source of energy
used to convert water into steam?
(b) How was mechanical energy
produced?

351
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 351 23/01/2023 11:27:04


Computer Science

Figure 7.7: An aeroplane in the second industrial revolution

Third industrial revolution Fourth industrial revolution


In the 1970s, the third industrial The fourth industrial revolution (4IR)
revolution began. The widespread use appears to have started in 2010. The
of electronics and computers and the 4IR is characterised by Cyber-Physical
introduction of the Internet characterised Systems (CPS). The CPS are systems in
this revolution. Such a revolution is which computer components are tightly
also known as the digital revolution. linked to physical world processes
Semiconductors, mainframe computers, while offering and using internet-based
personal computers, mobile phones and data services. Figure 7.9 shows an
the Internet were all part of the digital overview of CPS’s basic architecture
revolution. It was a period when world- in the 4IR. It is composed of real and
wide-web and the use of email featured. cyber-space, characterised by increased
Some manufacturing industries started connectedness and a high degree of
to use computers to manage and control coupling between the two spaces. The
production, as shown in Figure 7.8. high connectedness and coupling of
Many administrative tasks were now real space (physical) and cyber-space
handled using electronic management (computation) in CPS are facilitated by
information systems for organisations. the sophisticated process of gathering,
These systems are still used today, sending and actuation of information
although they have been improved. between the two spaces.

Figure 7.8: Digital manufacturing


during the third industrial revolution

352
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 352 23/01/2023 11:27:04


Information processing and storage

Computer Science
Cyber World
Cyber Space
Servers
Gather and Information
send on effecting
information Internet physical
process

Physical World
Real Space

Figure 7.9: An overview of CPS basic architecture in 4IR


The CPS application may be seen in Figure 7.10, which depicts a road journey. The
incoming driver has three options for getting to the destination: road “P,” “Q,” or
“R.” Every motorist on the road has a smartphone that is linked to a cloud server that
provides access to map-based location services.
Cloud Server

P Incoming
driver

Q
Destination R

Figure 7.10: An application of cyber-physical systems in transport logistics

353
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 353 23/01/2023 11:27:04


In Figure 7.10, the first part, which is based on GPS data gathered from drivers’
a physical process, is the movement of smartphones. Slow or no speed indicates
Computer Science

vehicles. The second part is the cyber that there is a lot of traffic. Based on the
system, which consists of internet and remaining options and distance cost,
cloud services containing algorithms the cloud service algorithms will then
that advise incoming drivers on which suggest to the drivers which road to
path to take. The optimal route is take to reach their destination. In this
recommended based on the distance to situation, route “P” would be selected.
the destination and the amount of traffic To summarise, Figure 7.11 depicts the
expected ahead. Road “R” is longer than development of industries from the
“P,” and road “P” is longer than “Q” late eighteenth century to the present
in this case. Algorithms on the cloud day. It lays forth the path between one
server for an application, such as Google revolution and the next using textural
Maps, decide which road is congested descriptions and images.
by analysing vehicle movement speeds
• Cyber-Physical Systems
(CPS)
• IoT connected devices,
• Computerization network, process
• Use of embedded automation and data
Programmable Logic analytics
• Mass production based on Controllers
engines powered by • Automation of production
electricity processes
• Engines powered by water • Invention of assembly • Internet
and steam lines powered by
• Mechanisation of electricity
handcraft activities

1st Industrial Revolution 2nd Industrial Revolution 3rd Industrial Revolution 4th Industrial Revolution
End of 18th century 1870 1970 2010 Onwards

Figure 7.11: The summary of key features of the Industrial revolutions

 Activity 7.2: Creating a cyber- you that there are sensors that can be
physical system use case in connected to a physical thing and record
fourth industrial revolution the motion and location of the object to
which they are attached. These sensors
Ms. Halima is a pastoralist who lives
have the capacity to communicate the
in Tanga but keeps livestock in Kilosa
information they collect. Based on this
Morogoro. She employed staff to look
scenario:
after her cattle. Her issue is determining
when cows are going for grazing and 1. Identify infrastructure needed to
returning back home so that she can pay solve this problem;
her staff based on the worked hours. Ms. 2. Use a diagram to create a design of
Halima approaches you for assistance your solution to solve this problem;
to develop a solution to that dilemma. 3. Devise, using a diagram, how Ms.
Meanwhile, your relative who works Halima will get information related to
for a large IT firm previously informed what is going on in her farm in Kilosa
in real time.

354
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 354 23/01/2023 11:27:05


Exercise 7.2: the simulation of human intelligence
in computers to perform tasks similar

Computer Science
Answer the following questions:
to those carried out by humans. Under
1. 
How did the availability of AI, machines are programmed to mimic
fossil fuels like coal enable the thoughts and actions of humans,
industrialisation? which means that those machines are
2. Identify the impact each industrial enabled to reason and respond by taking
revolution had on society. actions as a response. AI systems must
3. 
What is the main difference be able to collect information (sensing/
between the first and second perceiving), manipulate facts from
industrial revolutions? newly sensed information and previous
experience (reasoning) and make actions
4. 
Compare the third and fourth
(responses) mainly on their own.
industrial revolutions and outline
features that distinguish them. On the other hand, machine learning
is a branch of computer science that
focuses on using algorithms and existing
Emerging technologies and their data to build a model that can predict
applications an outcome of something. In creating
In this section, you will learn about the model, the algorithm has to learn
emerging digital technologies that from historical data. In that learning,
drive 4IR and their importance. Next, the algorithm is calibrated several
you will learn about the application of times until its accuracy or prediction
each technology in daily life. Digital level is confidently sufficient. Once the
technologies described in this section algorithm is ready and accurate, it may
are Artificial Intelligence, Blockchain, be subjected to a related problem with
cloud computing, 3D/4D/5D printing, a new data set to provide the desired
Big data, and the Internet of things. prediction.
Other technologies are drones, virtual Importance of artificial intelligence
and augmented reality, autonomous and machine learning
vehicles, robotics, and 5G.
AI systems have a critical relevance in
Artificial intelligence and machine our daily lives in various ways. First,
learning an intelligent machine can function in
John McCarthy first coined the term a risky environment without harming
Artificial Intelligence (AI) in 1956 itself; thus, relieving many of the
at the Dartmouth conference. John constraints placed on humans. Second,
McCarthy defined Artificial Intelligence humans are prone to errors, mainly while
(AI) as the science and engineering of doing repetitive tasks. Unlike humans,
making intelligent machines. AI is a intelligent machines are unique in that
technique for getting machines to work they seldom make errors.
and behave like humans. AI applies AI systems can make better judgments
contrived produced intelligence to solve faster because they can examine and
problems in the real world. AI comprises analyse all available options before

355
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 355 23/01/2023 11:27:05


arriving at a final decision. The situation is different when humans are involved in
deciding with many choices. When given more than seven alternatives to choose
Computer Science

from, most people find it challenging to go through them all and make an informed
decision. Additionally, AI systems do not require vacations or pay, and they do not
become ill or get tired.
Application of artificial intelligence and machine learning
AI has applications in many areas, including:
1. Health: To support diagnose illnesses and provide professional guidance
(expert systems)
2. Travel and transportation: Supplying pedestrians, car drivers and airlines
with map-based location and navigation services. Figure 7.12 shows AI-based
google location service in a selected route.

Figure 7.12: A Google location service in a selected route


3. Business: For offering online client conversation, for example, through Chatbots.
4. Facial recognition: Facial recognition is used to recognise people’s faces at
places like immigration offices and airports and for individual use like logging
into laptops and accessing other facilities.
5. Audiobooks: To listen to a book read aloud by the author. Instead of reading text
from a book (visual), the intelligent system will read the book to you in audio

356
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 356 23/01/2023 11:27:05


format, allowing you to hear the control over records. It’s used to record
voice. You can read a book while and keep track of transactions and

Computer Science
riding a bicycle, just as you can manage assets in a corporate network,
listen to music while driving a car. including real estate, money, and
It can also benefit visually impaired machinery equipment.
people to access such material Consider Village Community Banks
services for learning, working, and (VICOBA), where community members
any other purpose in their lives. join together to save money and obtain
credit. There are already mobile
Blockchain platforms where members may submit
Blockchain technology is a distributed their monthly savings using mobile
electronic ledger of digital records, events phones. Financial savings are centralised
or transactions that are cryptographically and administered by a governing body,
secure, extremely hard to forge, usually a member selected from a
and updatable through a consensus group. Other members may access the
protocol agreeable to all connected information, but only with restricted
nodes. A Blockchain is a decentralised, access. A client-server network with a
secure digital record of time-stamped, central database characterises this type
unchangeable transactions in several of record-keeping.
copies on internet-connected computers. In a Blockchain, however, each network
That copy is constantly accessible member has an equal ability to govern
to everybody at any time, and users records. That Blockchain consists of
modify it via distributed agreement. a distributed peer-to-peer network in
Blockchain technology focuses on which each member maintains their
creating distributed and decentralised records (ledger). Figure 7.13 shows the
databases with immutable records. network members of the VICOBA who
It does not allow for the deletion or are Fatuma, Simoni, Daudi, Upendo, and
updating of data; instead, new data is Wisebe. All these members must agree
added to the preceding to create a block to record a transaction in block zero (0).
of data connected in a chain. Instead If they agree, that successful transaction
of depending on a central authority will be time-stamped. If a transaction has
to handle everything, Blockchain to be updated, a new block of data, say
technology allows everyone to keep block one (1), is created and connected
records maintained in a ledger. As a to block zero instead of altering it.
result, each network member has equal

357
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 357 23/01/2023 11:27:05


Agree/reject
Computer Science

0 1 2
Daudi
Agree/reject
0 1 2
Fatuma Agree/reject
Agreement 0 1 2
Upendo

0 1 2
Simoni Agree/reject

0 1 2
Wisebe Agree/reject

Figure 7.13: An example of a distributed peer-to-peer network for VICOBA savings

All members of the peer-to-peer network fail because other nodes will deny a
must agree to commit to the transaction to request to publish transactions to the
be successful. Each member is in charge network only because each node has a
of their record (ledger). No data block copy of all transactions completed.
may be erased, resulting in immutable
Increased transparency: Transactions
records. In Figure 7.13, subsequent data
and data are recorded instantly and
blocks are linked, producing a chain of
identically in many locations because of
data blocks, hence the term Blockchain.
distributed ledgers, allowing all network
Importance of Blockchain members with permission access to see
the same information simultaneously.
Blockchain is useful because it helps
guarantee trust in business networks, Reliability: The possibility of failure
which traditional business-to-business is scarce because multiple copies exist
systems cannot provide. For example, across the network.
with a shared database, there is no
Challenges of Blockchain
guarantee that an administrator has
not transpired with the transaction. Some challenges with Blockchain
Blockchain gives the participants of the technology need attention before being
transaction non-repudiation, which is a used for transactions. The following are
piece of evidence that the transaction some challenges of Blockchain:
was agreed upon. Other importance of Privacy: There is a possibility that
Blockchain are as follows: someone could track down a person’s
Improved security: Blockchain helps identity in the network through
prevent fraud and unlawful behaviour transactional data, just as web trackers
by producing a record that cannot be and cookies are generally used by
changed and is encrypted end-to-end. businesses. This proves that Blockchain
Any effort to change a transaction will is not 100 percent secure.

358
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 358 23/01/2023 11:27:05


Scalability: The practical use of form of central bank money
Blockchain becomes a bit hard to widely used by the public.

Computer Science
imagine with the issue of scalability in Unlike cryptocurrencies, they are
view. Each participant node must verify based on a country’s agreement
and approve a transaction, so one Bitcoin currency value and are developed
exchange can take up to several hours. in many nations. The CBDC
promotes safety, robustness and
Security: The attack can be implemented efficiency of payment, reduces
if the nodes in a network lie; the lie will cost, and increases transaction
be accepted as truth. Therefore, everyone convenience.
in the network will have to continually 3. Smart contracts: Smart contracts
have a lookout for it to perceive any refer to the computer code
unwanted influence. shared between participants of
Storage: Since Blockchain databases are the business network, and these
stored indefinitely on all network nodes, implement the business rules
the issue of storage surfaces. With the associated with each transaction.
increasing number of transactions, the As the code is shared, it can be
size of the database will only expand, executed by all relevant, and
and there is no way personal computers they can agree on the output.
can store unlimited data that just gets Contracts are maintained
appended. digitally on the Blockchain and
are automatically executed when
Regulations: Regulatory organisations particular criteria are met.
in the financial field are a challenge for 4. Property registry: In a property
Blockchain implementation. Blockchain registry, unchangeable records
applications will have to lay down are kept to determine how
the process of locating the offender future ownership transfers were
in case fraud occurs, which is a bit completed from the initial owner
challenging. Blockchain technology’s to subsequent owners.
other regulatory aspects will need to
be introduced first to facilitate its broad The characteristics of Blockchain
implementation. Secure: each transaction recorded
Application of Blockchain in the database is digitally signed
and mathematically guaranteed to be
Blockchain has many applications, authentic and impervious to fraud.
including:
Shared: The database’s primary value
1. Cryptocurrency: People and is shared between separate entities. The
organisations can send and more entities shared, the greater their
receive money without central value.
intermediation or banks.
Examples include Bitcoin and Distributed: Many copies of the
Ethereum. database exist, replicating each other in
2. Central Bank Digital Currency relative time.
(CBDC): The CBDC is a digital

359
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 359 23/01/2023 11:27:05


Ledger: A write-once, thus immutable it anywhere on demand? Your data is
ledger that records every transaction. The held in the cloud, being a storage service
Computer Science

entire history of the whole transitions is provided by cloud computing. Cloud


available mathematics does not lie, and computing is the term that describes
there is nowhere to hide. any service delivered over the Internet.
A motivation behind cloud computing
To illustrate how shared ledgers and is to provide computing services
smart contracts work, imagine the outside a locally installed computer or
scenario of a Blockchain that tracks computer network, generally outside
a car’s ownership a local premise. These computing
The Blockchain itself would be an services, typically hardware and
ordered data structure that contains software, are usually delivered through
the details of every ownership the Internet by third-party companies.
change agreed upon. For example, Services like remote storage of files,
one transaction could state, “the car’s online application software, and virtual
ownership with identification number websites and databases are all happening
T576 CKY has changed from Pendo under the facilitation of cloud computing
to Asha. The smart contract associated technology. However, the challenge
with this transaction describes to remote storage is a lack of security,
the computer logic that makes the since the stored data is in the third part
transaction happen. For example, check and cannot be controlled.
that the seller is equal to the current There are three types of services offered
owner, and if the owner is set to be in cloud computing; categorised as,
the buyer, decrement the buyer’s cash infrastructure as service, software as
balance and increment the seller’s cash service and platform as service.
balance. Each interested participant,
Pendo and Asha, would run that smart Infrastructure as a Service (IaaS): This
contract code and agree on the output, sort of cloud computing is concerned
and if everything is acceptable, then with providing hardware services such
updates the ledger accordingly. The as real and virtual servers on demand for
updated ledger might be made visible various applications such as, hosting and
to Pendo and Asha but all interested storage. IaaS is commonly used to host
parties, such as vehicle regulators or a website or a mobile application. In the
insurers, pending the agreed rules of case of non-free IaaS, the membership
the network. price is usually paid monthly or
according to any other arrangement
negotiated.

Cloud computing Software as a Service (SaaS): This type


We live in a digital age where one of the of cloud computing is concerned with
most critical issues is accessing service providing software as a service. Instead
from seamless nodes. Have you ever of installing software on your computer,
anticipated keeping files in a remote you access it over the Internet and utilise
storage facility such that you can access it in your daily activities on demand.

360
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 360 23/01/2023 11:27:05


SaaS includes web-based email (such Disadvantages of cloud computing
as Yahoo and Gmail), collaboration

Computer Science
software such as Google documents Despite the benefits of cloud computing
(Google docs) and file storage such as usage, it is undeniable that this system
Dropbox and Google drive. also has some disadvantages such as:
Platform as a Service (PaaS): This type Internet connection dependent: The
of cloud computing service provides Internet is the only way to cloud
tools for developing and deploying computing. When there is no Internet
applications that run on a remote connection in your place or the Internet
server. An example of PaaS is writing, path to the cloud, the provider is in
compiling, and running computer trouble, then, the cloud computing
programs using online compilers (such machine is disconnected. The big
as C++ compiler). challenge in developing countries and
Importance of cloud computing remote areas is that they do not have
reliable internet access. The weakness
Cloud computing services are helpful in of the public cloud is that everyone
a variety of circumstances. Some of the accesses the same server, which will
benefits are: increase the risk of attack and put down
Backup and restoration: It is easy to the server.
back up your data offsite and restore it if
something goes wrong. Data confidentiality: There is always a
risk that other people can access user
Low cost: It allows you to save a lot of data. So, data and cloud protection must
money because it doesn’t require any be good because it will not be dangerous
hardware.
for data confidentiality.
Security: Cloud security covers the
set of controls, policies, technologies, The level of security: Secrecy and
procedures, and services that ensure security are among the most suspicious
the safety of the hosted services over things in cloud computing. Using a
the Internet and protect cloud data and cloud computing system means we are
infrastructure. The benefits of the rapid entirely entrusted with data security
operation, flexibility, and scalability and confidentiality to companies that
have made cloud computing famous provide cloud computing servers. When
among many business organisations. you experience a problem, you cannot
Cloud computing offers state-of-the-art sue the server for errors in the data.
security mechanisms that guarantee data
is stored and handled safely. Data mobility: It refers to the possibility
of sharing data between cloud services
Easiness in deploying an application:
It is easy to deploy an application you and how to retrieve data if one day
developed because you do not need to the user terminates cloud-computing
buy your server, manage and maintain it. services, and there is local storage
where the data can be used at any time
Convenience: Access to cloud-based as needed. If cloud-computing services
services may be done anywhere, is unavailable, the users will suffer if no
provided you have access to the Internet. other local storage is available.

361
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 361 23/01/2023 11:27:05


Vulnerable to attacks: Each component 4. Social media: You keep
of cloud computing can be exposed to connected with your friends
Computer Science

a wide range of attacks. This is a wide- through social media. For


open opportunity for attacks on data or example, Facebook, WhatsApp
activities stored on the cloud server. and Telegram.
5. Electronic meetings: It is
Technical problem: Cloud computing common now to see people
makes you unable to manage technical holding video conferencing
issues on yourself. When you face a meetings. You communicate
problem, you must contact customer with a friend through video
support, who is not always ready. This is calls, even at an individual level.
a problem because some cloud support An example of an electronic
services are not free. forum is Zoom in teaching and
Application of cloud computing business meetings. Also, people
use WhatsApp video calls and
There are many applications of cloud Zoom to talk to each other on
computing services in different sectors. individual levels.
These applications are such as:
 Activity 7.4: Converting
1. Online learning in education,
format of a document online
where information portals and
platforms are easily deployed. Resources:
Then, students can attend virtual
A computer connected to the Internet,
classes, online examinations,
note book and pen
and even scholarly discussions.
Moodle platform is one of Procedures:
the examples of an e-learning 1. 
Open a search engine such as
platform that is commonly Google (https://www.google.com/).
operated on the cloud.
2. Use the following phrase to search:
2. Online tools are available across
“online conversion of a file”.
various fields, like in graphics,
tools such as, image editing, 3. Open a link to an online file
for example, by removing the converter that you prefer.
image’s background. Examples 4. 
Follow instructions provided in
of online image editing tools that specific online file converter to
include photopea, adobe online change a file format, for example
photo editor, pixlr X, pixlr E, etc. from Pdf to word.
3. Converting documents format:
You can convert a document 5. 
List down any four document
from one format to another, converters from your search.
for example, from Pdf to word. 6. Try one after another converter to
Examples of this software are convert a document to a format of
such as PDF converter, and your choice.
Nitro.

362
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 362 23/01/2023 11:27:05


7. After changing the file format, 3D printing
answer the following questions:

Computer Science
Consider a scenario where your computer
(a) Assess the performance and connected to a printer can create tangible
quality of each document things such as a cup. 3D printing is a
converter. method of turning a computer-generated
(b) Did a layout of your document design into a three-dimensional object.
remain intact or was slightly Typically, printers that are used to print
changed? material things are not the same as the
(c) What are your opinions on ordinary printers we know and use in
this online service? our workplaces and homes. Unlike the
(d) Is this service a SaaS, IaaS, or regular printer that type-sets characters
PaaS? and images on paper, the 3D printer
works by layering (adding) new layers
 ctivity 7.5: Removing
A on top of the old ones. Figure 7.14 shows
background of an image an example of a 3D printer.
Resources: Initially, an object to be printed is
A computer connected to the Internet, designed on a computer using computer-
notebook and pen aided design (CAD) software. Next,
Procedures: that logical design is commanded for
printing. Printing is done using materials
1. 
Open a search engine such as
heated to a particular temperature to be
Google (https://www.google.
flexibly used to build an item in the form
com/).
of layers. As technology continues to
2. Use the following phrase to search: grow, other generations of 3D printing
“remove background from image are emerging. Although small things can
online”. now be printed, this technology is still
3. Open a link to an application of your growing. The world is now considering
choice that removes background of advancements in 4D and 5D printing.
an image.
4. 
Follow instructions provided in
that specific application
5. 
After removing background of
the image, answer the following
questions:
(a) Did the quality of your image
maintained or was slightly
changed? Figure 7.14: An example of a 3D printer
(b) 
What are your opinions on 4D printing is an extension of 3D
this online service? printing. In 4D printing, an item is given
(c) Is this service a SaaS, IaaS or the ability to change its form or structure
PaaS? predictably over time after it has been

363
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 363 23/01/2023 11:27:05


printed. Such structure changes after (a) 3D printing can be used to produce
exposure to various influential stimuli water pipes in a plumbing system.
Computer Science

such as temperature, light or other Future water pipes will be able to


environmental triggers. Moreover, 5D modify their structure in response to
printing uncovers the limitations of 3D changes in water flow or temperature,
printing by printing physical objects preventing them from bursting.
with curved surfaces instead of flat (b) In the medical field, 3D is used to
layers in 3D printing. Usually, in 3D create prosthetics and tooth implants
printing, a print head moves while the and may be used to print human
printed object is stationary. Instead, organs in the future.
with 5D printing, the print head is fixed
while the printable thing is moving.
Turning the printable object at different
 Activity 7.6: Watching videos
inclination angles enables it to yield
about 3D printing
curved surfaces.
Importance of 3D printing Resources:
3D printing is relevant in many areas, A computer connected to the Internet,
including: pen, and notebook
Rapid prototyping: You can design your Procedures:
product and print it in a shape that is 1. Open the YouTube channel (https://
easy to see what it looks like in physical www.youtube.com/)
shape. Then you can continue to improve 2. Use the following phrase to search
the design and print again until a viable video: “3D printing”
product design is obtained.
3. Watch more than three (3) videos
Creation of personalised items: Due to 4. After watching the videos, answer
consumer preferences, the same product the following questions:
may have minor differences, which is a
one-of-a-kind item. A simple example (a) Explain how layers are laid
is a cup with your name and photo on down to one another
it. Producing 100 customised items (b) In each video, what product
will simply require you to know the was printed out?
preferences of each buyer, and printing (c) Demonstrate by describing
will be simple. procedures on how 3D
printing work
Enables waste elimination: Waste
elimination becomes possible because (d) Evaluate the benefits of
an item is printed according to a shape 3D printing compared to
designed, thus no need to cut out excess traditional approach?
parts and throw them away.
Application of 3D printing In the future, 3D could print local and
on-demand medicines according to
The 3D printing has many applications specific patients’ needs.
in industry, including:

364
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 364 23/01/2023 11:27:06


 ctivity 7.7: Watching videos
A Internet of Things (IoT)

Computer Science
about 4D printing The Internet evolved from a network of
Resources: computers to a network of computers and
A computer connected to the internet, people. We are now entering the world of
pen, and a notebook the Internet of things beyond computing
Procedures: and network devices, including animals,
1. Open the YouTube channel (https:// household appliances, and cars, to name
www.youtube.com/). a few. As a result, such typical Internet
2. Use the following phrase to search has earned the name “Internet of
video: “4D printing”. Things.” The Internet of Things (IoT) is
3. Watch more than three (3) videos. a network of linked devices that includes
4. After watching the videos, answer machines, goods, animals, and people
the following questions: that can exchange data without human
(a) What is the difference between interaction. Instead of having the
3D printing and 4D printing? Internet only for people and computers,
(b)  In each video, what stimuli other things like smart refrigerators,
caused a material to change its television, car and microwave are
structure? equipped with small devices that can
(c) Reflecting back to our sense information and communicate it
individual lives and in
industries in Tanzania, identify to other devices or computers, hence,
at least four (4) things we can the Internet of things and the Internet
employ structures that change of everything. Figure 7.15 shows an
shape after being exposed to illustration of the Internet of Things.
external influences.

Figure 7.15: An illustration of the Internet of Things

365
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 365 23/01/2023 11:27:06


Imagine the following scenario development of many applications. IoT
includes industrial control systems,
Computer Science

A person going to work while wear-


ing an automatic blood pressure the retailing industry, innovative shelf
machine that measures blood pres- operations, healthcare, food or restaurant
sure periodically and send results industry, the logistics industry, the
to a medical doctor. Being late at tourism industry, and academic libraries
work, that person uses a smartphone applications.
to switch on light at home. After a Nonetheless, it is expected that the
while, the person receives alerts from
motion sensors installed in the prem- Internet of Things will significantly
ise at home. These warnings indicate contribute to addressing crucial issues
that a thief or unauthorised persons such as marketing strategies, public
are near the house’s fence. health care monitoring systems,
Having forgotten to water flowers at everyday living monitoring, and traffic
home, moisture sensor installed in a congestion control.
garden sends alert to mobile phone, The increased usage of IoT devices
informing that flowers need watering. is bringing importance to a variety of
That person uses the smartphone to fields, including:
open water tapes for a given period.
Planning to get back home, and it is a (a) Providing reacher statistics in a
day with hot weather, that person uses particular industry that may be
smartphone to switch on air condition analysed to acquire more profound
at home to cool temperature, so that on insights into a topic of interest;
arrival, the house will already be cool. (b) The possibility for remote control
Before arriving home, a refrigerator and monitoring of systems is
sends alert to the smartphone that soft
drinks like juice are out of stock. That possible. You might be able to keep
person opens website of a store or su- up with what’s going on at home,
permarket and order for juice. office or farm even if you’re not
around;
This scenario elaborates on a storytelling (c) Monitoring of machine performance:
about how IoT changes how people Sensors attached to or installed in a
control their surroundings. Things machine report on its efficiency.
like soil, refrigerators, houses, light
bulbs, and water tapes are embedded or Application of the Internet of Things (IoT)
attached to devices that send and receive IoT can be applied in almost all area
information to/from cloud computing in life. Some of the areas where IoT is
services. In this context, the Internet is widely applied are:
no longer limited to people but extends (a) Home appliances, for example,
to many things, including livestock cooking appliances, refrigerators
farms and appliances. and lighting
Importance of the Internet of Things (b) The smart security systems that
(IoT) detect unusual movement and entry
into a premise
The Internet of Things enables (c) The wearable health monitoring
information gathering, transmission, equipment that collects and
and storage for devices in various communicates data about our
scenarios, creating or accelerating the health to a remote cloud server for

366
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 366 23/01/2023 11:27:06


processing and further analysis
(d) Smart containers for sensing the state of commodities parked in shipping

Computer Science
containers
(e) Transport logistics for tracking the movement of cargo in shipping
(f) Traffic monitoring whereby mobile phones report our pace of movement on the
road. A slow pace from many devices implies the presence of traffic congestion
(g) In irrigation for sensing and controlling necessary watering required in a farm
Big data
Data is created in large volumes and at a high rate in today’s environment. For
example, mobile phones that use map location services generate a daily history
of our movements. The amount of data generated by global social media posts is
enormous. Yet, vehicles and aeroplanes create and share data while on the route in
transportation. Social media, sensors incorporated in machinery equipment (such as
machines in the manufacturing industry), transaction processing systems (such as
mobile money transactions), and IoT devices generate a large quantity of data, as
shown in Figure 7.16.

Mobile money Web

Social media
Internet transactions
(sales/purchases, banking)
Sources of
Big data IoT devices/
sensors
Mobile phones (calls,
SMS/IM/text, Location)
Databases
Archives

Figure 7.16: Some sources of Big data

In line with the characterisation presented in the previous paragraph, Big data refers
to data that is often large in volume and generated at a high rate. Big data has four
primary characteristics: volume, velocity, variety, and veracity. These characteristics
are also referred to as the four Vs of Big data. The following is a brief description of
Big data characteristics as shown in Figure 7.17:
Volume: A large volume of data is generated every minute. Since the growth of
information is so rapid, then new types of database management are needed.

367
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 367 23/01/2023 11:27:06


Velocity: This is the immense speed at which data is created and processed. Big data
is usually generated at a higher rate.
Computer Science

Variety: Data is generated from various sources. Data generated may be unstructured,
semi-structured or structured, resulting in data that exists in a variety of forms.
Veracity: Signifies the trustworthiness of data, whether the data is correct and of
good quality. The data gathered may be of both excellent and lousy quality.

Volume
Data is generated in large quantities

Veracity Characteristics of Big data Velocity


Whether data may be trusted (Four Vs) Data is generated at higher
and is of good quality rate

Variety
Data exists in unstructured, semi-
structured and structured forms

Figure 7.17: The four characteristics of Big data

Importance Big data next step is to make sense and meaning


Big data has relevance in many areas, out of it, a point where Big data analytics
including: plays a critical role. Big data analytics is
the process of examining large amounts
(a) Making informed decisions due
of data with advanced techniques to
to the availability of rich insights
find hidden patterns, correlations,
generated from a large volume of market trends, customer preferences,
data; and other valuable insights. Advanced
(b) Acquiring citizen opinions on data analysis techniques are utilised to
a particular topic for smooth understand better issues that would take
administration of the government; a long time to uncover if advanced data
(c) Empowering a better understanding analytic techniques were not applied.
of customer needs in the retail Depending on the purpose, there are four
industry; main types of data analytics, which are:
(d) Determining and managing risks in Descriptive data analytics that focuses
credit facilities provided by financial on answering questions about what
institutions. happened in the past;
(a) Diagnostic data analytics which is
Big data analytics designed to explain why something
Now that you have that Big data, the happened;

368
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 368 23/01/2023 11:27:06


(b) Predictive data analytics that looks An autonomous or smart vehicle is a
at what could happen in the future; vehicle that can drive itself from a starting

Computer Science
and point to a predetermined destination in
(c) Prescriptive data analytics assists in autopilot mode. Autonomous cars, also
determining what should be done in known as self-driving vehicles, perform
terms of decisions and actions. driving functions on themselves without
human interaction. They can sense
Application of Big Data surroundings, accelerate speed, and
Application of Big Data include but bot apply brakes to reduce speed or stop the
limited to: car.
(a) Tracking customer behaviour
(b) Recomendeshen
Activity
7.8: Watching videos
(c) Smart and secure traffic
about autonomous vehicles
Unmanned aerial and smart vehicles 1. Open the YouTube channel (https://
A drone is an aircraft that has no pilot www.youtube.com/)
inside it. Drones are sometimes known
as Unmanned Aerial Vehicles (UAVs). 2. Use the following phrases to search
Drones differ in size, and they range video: “autonomous cars or self-
from large ones, such as military drones driving cars” and “Unmanned
carrying bombs and attacking in combat, Aerial Vehicles”
to small ones used to take video and still 3. 
Watch more than six (6) videos,
pictures of a scene. Drones are usually three for drones and others for “soft
controlled using a remote, as shown in driving cars”
Figure 7.18. Small drones have many 4. After watching the videos, answer
components, including a GPS module
the following questions:
that offers location services, a battery
to power the drone, and an antenna and (a) 
How does drones and self-
receiver for communicating signals. driving car see objects and
obstacles on their paths?
(b) What challenges could drones
and self-driving automobiles
face as a result of infrastructure
flaws?
(c) What are the benefits and
drawbacks of using drones
and self-driving cars?
(d) 
Can our road infrastructure
Figure 7.18: A drone for spraying rice support autonomous vehicles?
fields to fight malaria in Zanzibar Explain why.
(Source: https://apnews.com/article/
b2131aa51d4b4043a7c18e69236464 47)

369
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 369 23/01/2023 11:27:06


Importance of unmanned aerial (c) Drones can be used to deliver
vehicles shipping where items are moved
Computer Science

faster and efficiently from store to a


Drones and autonomous vehicles have customer
relevance in today’s industry and society.
The following list describes some of the (d) Large drones can be used to perform
reasons why drones and autonomous military operations
vehicles are essential.
(e) Autonomous vehicles can be used as:
(a) UAVs are easy to deploy and operate, (i) Taxis in cities and towns;
and their cost is relatively low;
(ii) Shuttles to serve need public
(b) UAVs can reach more difficult transport; and
heights and areas than where humans
can not; (iii) D
 elivery vehicles where
customised delivery is even
(c) The use of autonomous cars is more suited.
expected to reduce accidents,
particularly accidents whose sources Virtual and Augmented reality
are driver’s fatigue, laziness and
Virtual Reality (VR) is a term that
distraction; and
describes a situation in near reality. Virtual
(d) Autonomous vehicles will reduce Reality (VR) uses computer technology
traffic jams because human drivers to create a simulated environment. That
have stop-and-go behaviours while simulated environment is unreal, but it is
driving. Self-driving cars will not undoubtedly near reality. VR attains this
exhibit stop-go behaviours, which reality by enabling users to view a world
will lead to low traffic jams. through a virtual reality headset, making
the user immersed in the virtual world.
Application of unmanned aerial Unlike VR, Augmented Reality (AR) is a
vehicles and autonomous vehicle technologically enhanced representation
of the actual world created by supplying
Drones and autonomous vehicles
additional digital information in
have many applications, including the
audio or visual components or even
following:
textural description. AR enhances your
(a) UAVs are used in geographic surroundings by adding digital features
mapping. Drones can be applied to a live view, most commonly via
to take images in regular and a smartphone’s camera. An example
challenging areas, such as of an AR application may be found in
locations that are difficult to reach retail shopping. A customer may use a
(mountaintops and islands) smartphone’s camera to view a street,
as shown in Figure 7.19. Then names of
(b) UAVs can be used to take aerial shops available in that street appear on
view photos and videos in various the customer’s live view, together with;
including townships with tall a distance to a specific shop, ratings, and
buildings the number of votes.

370
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 370 23/01/2023 11:27:06


comedy film experiences and allow
people to enjoy them.

Computer Science
(c) Virtual reality in the military. Virtual
reality combined with sights and
sound may replicate dangerous
training scenarios to prepare and
train soldiers.
Application of AR are as follows:
(a) Augmented reality can be applied in
Figure 7.19: Using AR to find nearby picking products or parts stored in
shops warehouses.
Importance of virtual and augmented (b) Whether walking or driving,
reality augmented reality provides
On the one hand, VR immerses users guided navigation or guidance.
in a near-real world, allowing them It is beneficial while visiting a
to live and participate in a previously new location with which you are
unimaginable setting. The VR transports unfamiliar. The augmented reality
the user to a new experience obtained at may use the smartphone’s GPS to
a lower cost. Users can study or gain offer you directions that you may
a deeper understanding of a situation view in real-time until you arrive at
in prior. On the other hand, AR allows your location.
users to see actual objects broadly. It
empowers users with required details
when additional information is added to  ctivity 7.9: Watching virtual
A
a physical scene or item. reality videos
Application of virtual and augmented Resources:
reality A computer with video streaming
software, internet connection, speaker/
Virtual reality and augmented reality headphones
have a wide range of applications. The
following are descriptions of a few of Procedures:
these applications: 1. Open the YouTube channel (https://
www.youtube.com/).
Application of VR are as follows:
2. Use the following phrases to search
(a) Virtual reality in health care: A video: “virtual reality in medical
medical doctor can practice doing the care”.
surgical operation through training
without being in a real operational 3. Watch more than three (3) videos
theatre. plug you headphones to reduce
noise.
(b) Virtual reality in entertainment: It
may be used at theatres to mimic

371
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 371 23/01/2023 11:27:06


4. After watching the videos, answer physical components that are generally
the following questions: interchangeable, such as spray for the
Computer Science

(a) 
Identify physical objects in painting robot, electrode and electrode
the videos holder for the welding robot, and
grasping claws for a robot that picks
(b) Identify virtual objects in the items.
videos.
(c) 
Explain how virtual and
physical objects interact.
(d) 
Discuss how this can be
applied and benefit our
community.

Robotics
Robotics is a term that describes the
designing, construction, and use of
machines (robot) to perform tasks that Figure 7.20: Robots in the car
are traditionally done by humans that manufacturing industry
can interact with the world. Typically, (Source: https://media.jaguarlandrover.
there are two groups of robots –physical
com/2016/manufacturing-success-story)
robots and software robots.
As shown in Figure 7.20, physical
robots deployed in industries have five Software robots are computer programs
main components: sensors, control that perform non-physical jobs.
systems, actuators, power supply, and Examples of these robots are search
end effectors. engines (that you use to search for
Using a variety of sensors, the sensory various information on the Internet) and
component gathers information about chatbots. Chatbots are known for pop-
the surrounding environment. Data ups when you open a particular website,
collection includes visual data (using a asking visitors about what they can do
camera), audio (using a microphone), to help. They work as employees of
pressure, light, and temperature. The the customer service department in an
control system analyses data collected organisation.
by sensors and decides on the best Importance of robots
course of action. After analysis and
decision, the actuator components of In general, robots do tasks autonomously
a robot do the robot’s real job. These or semi-autonomously. Semi-
actuators are also known as effectors in autonomous robots require human
some cases. The robot must be powered intervention to complete their jobs,
by electricity to work, which is the whereas autonomous robots do not.
robot’s fourth component. The end Some robots are intelligent, but others
effector’s last component comprises are not. Although it was programmed

372
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 372 23/01/2023 11:27:06


with a pre-defined set of instructions, the services such as Short Message Service
robot that picks and transfers goods is

Computer Science
(SMS). It incorporated packet switching
not necessarily intelligent. On the other in the form of General Packet Radio
hand, an intelligent robot replicates Service (GPRS) and Enhanced Data
human behaviour by perceiving rates for GSM Evolution (EDGE). The
information, reasoning from facts, and 3G provided critical core network speeds
taking actions after a decision; take, for for smartphones. The 3G had a four
instance, Robot Sophia. Robot Sophia times 2G data transfer capacity, allowing
is realistic humanoid robot capable of video streaming and video conferences.
displaying human like expressions and The 4G provides high-quality data
interacting with people transfer speed, enabling video streaming
and other related services which demand
Application of robots
higher data transfer.
Robots may be applied in more expansive
ranges areas, as follows: The 5G technology is the next generation
of wireless telecommunications for
(a) Robots are a fantastic alternative
mobile internet connections. It has a fast
for investigating locations that
people cannot easily access, such connection and will allow smart homes,
as deep-ocean research and space automobiles, health care, and nearly
exploration. anything to connect to the Internet,
(b) Robots are used in the manufacturing creating an integrated environment. The
industry, for example, in car 5G is offers 100 times more data transfer
manufacturing industries. capacity than the 4G. The facts changing
(c) Robots are used in homes, for the digital world is influencing the
example, for doing cleanliness or demand for high Internet speed, which
cooking. may not be achieved from the traditional
(d) Robots are used in the health connection architecture of third and
industry, for example, in routine fourth generations. The 5G addressed
tasks and surgery. three critical challenges; ultra-high
throughputs, ultra-large connection, and
The 5G ultra-low latency. Generally, 5G has
The 5G refers to fifth-generation three main advantages:
wireless technology in cellular (a) It provides enhanced mobile
telecommunication. It’s important broadband of up to 20Gbits/s
to know what came before 5G to (b) It is a massive machine-type
comprehend it. The first generation –1G communication that has one
networks– allowed people to make phone million connections per second
calls, but they had a lot of flaws such as per square kilometre
reliability and signal interference. The (c) It has an ultra-reliable low
2G network was based on Global System latency of 1ms
for Mobile (GSM) communication. It
enabled circuit-switched mobile data

373
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 373 23/01/2023 11:27:07


Importance of the 5G Network Exercise 7.3
Computer Science

The 5G network transforms many


Answer the following questions:
sectors and individuals’ lives due to
the network’s unimaginable speed and 1. 
Analyse the trade-offs between
capacity. The following are among the applications deployed in the
significance of the 5G network: cloud and those installed on local
premises.
Supporting more interconnectedness
in the future: The continued increase 2. Study carefully a scenario described
in the number of devices connected to, in the section of the Internet of
will hardly be supported with 3G and Things (IoT) and answer the
4G in future. In contrast, 5G can support following questions:
around one million devices connected (a) 
Identify which physical
to a network at ultrafast speed, within processes were involved.
an approximate area of one (1) square
(b) Identify which cyber systems
kilometre.
were involved.
Speed of data transfer: The 5G offers
(c) 
With a sketch diagram,
high speed than its predecessors. The
explain how data would flow
5G is faster than 4G, sending up to 20
among all entities involved.
Gigabits-per-second (Gbps) data rates.
(d) 
Which types of cloud
Application of 5G computing services would be
The 5G will continue to be applied in appropriate in this scenario?
areas where 4G and 3G are currently Justify your answer.
used. However, critical applications will 3. Identify areas of 4IR applications
benefit from network speed and capacity that require a very high-
to handle many devices. To highlight speed network to function and
a few, the 5G has many applications, demonstrate how 5G may be used.
including:
(a) Healthcare –where doctors and
patients will be able to stay more Impact of emerging technologies
linked with 5G, for example, through
the use of wearable gadgets Emerging digital technologies that
(b) Agriculture –sensors placed across drive 4IR have impacted various
the farm will alert the farmer to fields, and more are expected. This
various scenarios. Also, wearable section looks at the impact of the fourth
gadgets that monitor livestock health industrial revolution that results from
will assist owners in knowing their emerging technology. This impact is on
health status early. employment, skills and nature of work,
(c) Logistics - it will be easy and fast business, economy, security, society,
to track the shipping of items across and individuals.
multiple nodes.

374
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 374 23/01/2023 11:27:07


Impact on employment Short Message Service (SMS), and
social media. As robotics and artificial

Computer Science
The fourth industrial revolution
creates fewer jobs in new industries intelligence technologies keep growing,
than in previous revolutions. That is systems that can send and receive emails
especially true in light of rising levels are being invented. Regarding the nature
of automation in industry, as human of work, the need for physical working
occupations are increasingly being spaces is decreasing. Some employees
replaced by automated machinery. For can now work from remote areas on
example, the automation of some work different continents and countries or
in offices and manufacturing industries, even their homes.
results in fewer jobs. Furthermore, These developments mean that new
in ride-sharing, featured by seamless job skills will be required to adapt
algorithms, people, do not oversee the to a changing working environment
selection of which driver to meet and characterised by emerging technologies.
which customer to choose. Most emerging technologies such as AI,
Emerging technologies will continue augmented reality, robots, and cloud
to alter the nature of employment in all computing, will require personnel who
sectors and vocations, and automation can use these technologies. Computer
will increasingly replace human labour. programming, coding, and project
Many diverse types of jobs have already management skills will be more in
been automated, particularly those that demand than today. Critical thinking,
need mechanically repetitive and exact problem-solving, judgment and decision-
physical work. Many more will follow making, interpersonal communication,
as computational power expands rapidly. and emotional intelligence are other core
This implies that different professionals competencies needed in this situation.
must be aware of this trend and prepare Impact on business
themselves by being more innovative to The impact of emerging technologies
remain relevant. on business is observed from the
Impact on skills and nature of work perspectives of access over ownership
Robotics and artificial intelligence and data-enhanced products. These
are transforming how we live and perspectives are also referred to as
work. Soon, other technologies such new business models under the fourth
as machine learning, autonomous industrial revolution.
vehicles, and the Internet of Things Access over ownership
will also change our lives. Building on Access over ownership is a business
the example of the postal service for strategy that allows customers to utilise
sending and receiving mail, you can a product without purchasing and
imagine how administrative processes owning it. Access over ownership is
in offices and the lives of individuals are also described as a sharing economy
changing. Previously mail carriers and because it involves parties sharing
individuals could walk to the post office an asset in space or time. People are
to send or pick up mail. This manner of starting to refrain from owning some
operation has been replaced by emails, assets and opting to access those assets.

375
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 375 23/01/2023 11:27:07


It is because the costs of purchasing business might be used to elaborate the
and owning some assets are high, and supply of additional information on a
Computer Science

meanwhile, some assets, such as drilling product. Imagine you are shopping
machines, are rarely used by owners. at a supermarket for a blender to use
Under the dimension of space, people at home in making juice, and you are
may share, for example, unused space unfamiliar with that sort of blender. It
in a personal car. Imagine driving alone is possible that the product information
from Dar es Salaam to Dodoma in a car written on the package is insufficient
with five seats while you are occupying to describe the blender and how to use
one seat only. You share unused (idle) it. A Quick Response (QR) code may
space when you allow other people to ride be helpful in this scenario. A QR code
with you in your car. Those passengers may be attached to the blender by the
do not need to own the vehicle (asset) manufacturer, allowing you to scan
but need access to it. Other examples the code with your smartphone (using
of ride-sharing are services offered by a specific mobile app). On scanning,
Uber, Bolt, Taxify and Bla Bla Car. more details about how the blender was
Moreover, vacation renting of homes or manufactured, how to operate it and its
rooms and car leasing services are forms life span are displayed in various formats
of sharing through renting but in the such as text, image and video. In this
dimension of time. case, a product has been enhanced with
Digital platforms that mediate data. Furthermore, augmented reality
interactions between service providers technology may be applied to improve
and consumers are critical to the the product in this particular case.
operational effectiveness of the access Impact on security
over ownership business model. The impact of emerging technologies
Typically, the asset provider (supplier) arises from the perspectives of cyber
registers on the digital platform and warfare and autonomous warfare.
gives relevant information such as the Cyberwarfare can take a variety of
description of the service they deliver forms, including attacks on financial
and the price. The consumer also creates infrastructure (bank and payment
an account on the digital platform by systems) and safety infrastructure
entering their information. Following systems (such as warning systems).
that, algorithms find the optimal match Autonomous weapons, a combination
between provider and consumer based of drone technology with artificial
on many parameters such as proximity, intelligence, can choose and engage
price, and preference. Digital platforms targets with limited or without human
like Uber, Bolt, and Taxify act as interaction, based on predefined criteria.
intermediaries between the driver and Drones which are flying robots, can also
the passenger, while seamless algorithms be used as weapons in combat while
perform their finest work behind the getting controlled remotely. The robot
scenes. will play a role in the war in future wars
Product data enhancement and involve deploying military robots
An application example from the retail and AI-powered automated weaponry.

376
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 376 23/01/2023 11:27:07


Impact on society and individuals trust algorithmic recommendations or
do we accept the opinions of our friends

Computer Science
Emerging technology has a variety of
impacts on society and individuals, and close relatives? Despite continuous
including socio-economic inequality technological advancements, we as
and anti-government objectives. We humans still need a personal touch.
are already seeing how technology and However, the trend reveals that our
robotics are displacing human labour. social ties, once deeply rooted in
Existing and potential employees’ skill physical contact, are beginning to drift
sets are restricted and tailored to the apart as social exchanges migrate to
market’s requirements. Individuals social media, an aspect that needs a
with higher innovation abilities, such balance between the two.
as bringing new ideas, business models,
and products to market, will be valued Exercise 7.4
more than those with lower expertise.
Answer the following questions:
This upward tendency suggests that
those with the necessary abilities will 1. 
Explain with examples how
survive and outperform the low-labour emerging technologies have started
skilled workforce. to impact people’s way of living,
Digital media has both beneficial and changing them from possessing
harmful effects. Digital (social) media assets to accessing assets
favour linking individuals to form 2. 
Describe how robotics and
friendships in one-to-one networks automation affect skills and
and social groupings. This networking employment.
stretches across national borders, 3. 
Identify the social impact of
allowing people to have incredible emerging technologies.
personal experiences and feelings.
Digital media, particularly social media,
which non-state players dominate, may Chapter summary
influence society with extreme agendas. 1. Unlike earlier industrial revolutions,
Some of these agendas have malicious the Fourth Industrial Revolution
intentions such as misinforming the (4IR) is progressing exponentially.
public and causing unrest. This is the outcome of our intimately
Furthermore, continued advancements interconnected society, and that new
in artificial intelligence and robotics technology opens us to previously
raise the question of whether or not unimaginable possibilities. The 4IR
we, as humans, will be able to govern builds on digital transformation and
intelligent machines. What if they one brings together a variety of emerging
day outstrip our ability to manage them? technologies that are causing
Algorithms are being used to choose extraordinary paradigm changes in
who should attend an interview, establish socioeconomic development.
prices for items in online stores, provide
health advice, determine who to date, 2. 
Emerging technologies drive the
where to travel, and which hotel to 4IR. In particular, emerging digital
book, among other things. Do we now technologies such as artificial

377
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 377 23/01/2023 11:27:07


intelligence, machine learning, 5. 
Other impacts are on security and
Blockchain, Cloud computing, society. Cyberwarfare attacks
Computer Science

and 3D/4D/5D printing account threaten financial infrastructure


for the 4IR. Others are Big data, (bank and payment systems) security.
the Internet of Things, drones, Based on pre-defined criteria,
virtual and augmented reality, autonomous weapons that combine
autonomous vehicles, robotics and drone technology with artificial
the 5G network. Some of these are intelligence are being engaged to
technologies already being applied hit targets with limited or without
in the industry while others have human interaction. In a social
use cases and prototypes. These context, emerging technologies are
advancements have brought broad causing socio-economic inequality
impacts on employment, skills and and anti-government objectives.
nature of work, business, economy,
security, society, and individuals.
3. The impacts of emerging technologies
are observed in employment, skills Revision exercise
and the nature of work. In ride-
sharing, for example, seamless Fill in the blanks
algorithms, not people (employees), 1. 
The ____________ uses your
oversee the selection of which existing real environment and
driver to meet and which customer overlays virtual information on top
to choose. Regarding skills and the of it.
nature of work, new job skills will
2. _____________ learns from data to
be required to adapt to a changing
working environment. For example, perform functions that are similar
computer programming, coding, and to those performed by people.
project management skills will be 3. 
_____________ learns from
more in demand than today. humans to perform functions that
4. In the business world, new business are similar to those performed by
models such as access over ownership people.
and product data enhancement, 4. ____________ is made up of data
are being driven by rising digital
that cannot be changed.
technologies. Customers utilise a
product (asset) without purchasing 5. Discuss with examples the benefits
and owning but share (rent) a whole and drawbacks of cloud data
or part of that asset for the access storage for businesses
over ownership business model. For 6. 
Examine how law enforcement
product data enhancement, items officials, particularly police
may now communicate about their
officers, can use wearable
current states, and other products can
computers in their daily duties.
now provide extra information about
themselves.

378
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 378 23/01/2023 11:27:07


7. Describe the benefits of using QR 10. How can wearable devices improve
code attached to product packages to: health care?

Computer Science
(a) Manufacturers 11. Discuss the impact of social media
(b) Retailers in business.
12. What is the influence of the fourth
8. 
Explain the difference between industrial revolution on our daily
augmented reality and virtual lives?
reality. 13. Give five (5) examples of things you
9. 
A vast amount of data about can print by using 3D technology.
academic records exists at a 14. Compare 3D-printed products and
particular high school in Tanzania. conventionally manufactured goods
The high school intends to safeguard in terms of strength and quality.
such information by regularly 15. Emerging technologies have both
backing up its records. The school’s positive and negative impacts on
ICT department is contemplating society globally. Discuss four of
using one of the following backup them.
systems; tape, hard drive, or cloud 16. Consider any four emerging
storage. Evaluate the three options technologies. Discuss their impact
and recommend, with reasons, the on people in Tanzania now and in
most suitable one. the future.

379
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 379 23/01/2023 11:27:07


Glossary
Computer Science

2D-Array It is an array containing a collection of cells laid out in a two-


dimensional grid, like a table with rows and columns, even though
the values are stored in linear in the memory

3-D Array It is a multi-dimensional array which is specified using three


subscripts, block size, row size and column size. The more the
dimensions in an array mean more data can be stored in that array.
In short, it is an array of arrays.

A function It is a block of code that performs a specific task.

A node It is a structure that contains a key or value and pointers in its child
node in the tree data structure.

Abstract data It is a special kind of the data objects that make up a data type
type and the functions that operate on these objects. These are special
kinds of the datatype whose behaviour is defined by a set of values
and operations. The keyword “Abstract” uses these data types and
performs different operations.

Access It refers to a selective restriction of access to a place or other


control resource.

Algorithm It is a process or set of rules to be followed in calculations or


other problem-solving operations, especially by a computer. It
is also defined as a predetermined set of instructions for solving
a specific problem in a limited number of steps.

Array It is a data structure that can store a fixed-size collection of


elements of the same data type. These elements are all of the
same data type, such as a string or an integer. An array is a group
of related data values (called elements) that are grouped together.

Attributes These describe characteristics or properties that define all items


about a specific category applied to all column cells.

Bubble sort Bubble sort is an algorithm which arranges a string of numbers


or other elements in the correct order. The method works by
inspecting each adjacent element in the string, from left to right,
switching their positions if they are out of order until it is arranged
in the required order (ascending or descending) order.

380
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 380 23/01/2023 11:27:07


Candidate key It is a specific type of field in a relational database that can identify

Computer Science
each unique record independently of any other data. A candidate
key is an attribute or set of attributes that can uniquely identify a
tuple. The remaining attributes in a table are candidate keys except
for the primary key.

Class A class is used in object-oriented programming to describe one or


more objects. It is a template for creating or instantiating specific
objects within a program.

Composite A composite key is a combination of two or more columns in a


key table that allows us to identify each row of the table uniquely. It is
a type of candidate key formed by more than one column.

Conceptual It is a Data Model that defines WHAT the system contains.


data model Business stakeholders and Data Architects usually create this
model. The purpose is to organise, scope and illustrate business
concepts and rules.

Fabrication It is the attacks which involve generating data, processes,


communications, or other similar activities with a system.

Foreign key Foreign keys are the column of the table used to point to the
primary key of another table.

Interception An interception is an act when an unauthorised individual


attack gains access to confidential or private information. Interception
attacks are attacks against the network, the confidentiality objective
of the CIA Triad.

Interruption Refers to making a service degraded or unavailable for legitimate


attack use. It is an attack against the availability of the network or service.

Logical data It defines the organisation of a set of data by standardising the


model people, places, things (entities) and the rules associated with them
and how the system should be implemented. It is geared toward
creating a technical map of data structures, rules, and relationships
between them using standard language and notation. Furthermore,
it provides all the information about the various entities and the
relationships between them in a database.

381
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 381 23/01/2023 11:27:07


Memory It is an exact assigned location in RAM used to track where
Computer Science

address information is stored. The memory address is the location where


the variable is stored on the computer. When the value is assigned
to the variable, it is stored in the memory address.

Merge sort A sorting technique that arranges data by continuously combining


items in the list. Every single item in the original unordered list is
combined with another, creating groups of two. Every two-item
group is merged, creating groups of four until there is one ordered
list.

Modification It is an attack against the integrity of the information by either


attack changing, inserting or deleting a piece of information to or from
the existing or original.

Physical data A Data Model that defines how the system will be implemented
model using a particular DBMS system. The goal is to get the database up
and to run. It also helps visualise database structure by replicating
database column keys, constraints, indexes, and other RDBMS
features.

Primary Key It is the first key used to identify one and only one instance of an
entity uniquely in the table.

Recursive It is an algorithm that calls itself with “smaller or simpler “ input


algorithm values and obtains the result for the current input by applying
simple operations to the returned value for the smaller or simpler
input.

Relational A relational database organises data into rows and columns,


database collectively forming a table. Data is typically structured across
multiple tables, which can be combined via a primary or
foreign key. These unique identifiers demonstrate the different
relationships which exist between tables, and these relationships
are usually illustrated through different types of data models.

Risk The process of identifying, assessing and controlling threats to an


management organisation’s capital and earnings.

Selection sort It is a sorting algorithm that selects the smallest element from
an unsorted list in each iteration and places that element at the
beginning of the unsorted list until the required order is attained.

382
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 382 23/01/2023 11:27:07


Stack It is a linear data structure that follows the principle of Last In

Computer Science
First Out (LIFO). This means the last element inserted inside the
stack is removed first. A good example is a pile of plates.

Syntax It is a set of rules which define what the various combinations of


symbols mean. The syntax tells the computer how to read the code.
It is also a very specific set of words with a specific order guiding
how to write code when we give the computer instructions.

Tree In the data structure, a tree is a nonlinear hierarchical data structure


and comprises a collection of entities known as nodes. It connects
each node in the tree data structure using directed and undirected
edges.

Tree topology In networks, it is a type of network layout resembling a tree, with


a root node at the top and leaves at the bottom.

Tuple It is a data structure consisting of multiple parts. (in a relational


database) it is an ordered set of data constituting a record, a row
that contains interrelated data about a particular entity

Typedef It is a reserved keyword in the programming languages such as,


C and C++. It is used to create an additional name for another
data type, provide some meaningful names to the already existing
variable in a particular program

Vulnerability It is the weakness in an information system, system security


procedures, internal controls, or implementation that could be
exploited or triggered by a threat source. These are flaws in a
computer system that weaken the overall security of the device/
system

Amateur Refers to unprofessional or inexperienced hacker


hacker

383
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 383 23/01/2023 11:27:07


Bibliography
Computer Science

1. Beñat Bilbao-Osorio, Soumitra Dutta, and Bruno Lanvin (editors). (2013).


The Global Information Technology Report 2013: Growth and Jobs in a
Hyperconnected World. Geneva: World Economic Forum.

2. Chemwa, G and Mburu, S. (2016). Mastering computer studies. S. Mburu, G.


Longhorn Publisher LTD, Kenya

3. Chemwa, G. and Mburu, S. (2005). Computer studies form 3, Longhorn


Publishers (K) Ltd, Kampala, Uganda

4. Chen, V. (2022, June, 14). An Introductory Guide to Visual Programming.


Bubble IO. https://bubble.io/blog/visual-programming/

5. Doorsamy, W., Paul, S. B., and Marwala, T. (2020). The Disruptive Fourth
Industrial Revolution: Technology, Society and Beyond. Springer. https://doi.
org/10.1007/978-3-030-48230-5

6. Farouzan, A. B(2013). Data communication and networking 5th Edition. McGraw


Hill Education, USA

7. Gartner, Inc. (2022). Gartner Glossary. https://www.gartner.com/en/information-


technology/glossary

8. Gnaneswari, G. (2020). Programming in Visual Basic 6.0, Bangalore University,


India

9. Gupta, M. (2020). Blockchain for dummies. 3rd IBM Limited Edition, John
Wiley & Sons, Inc., Hoboken, ISBN: 978-1-119-62196-6

10. Hallberg, B. (2015). Networking A beginner’s guide 6Th edition. McGraw Hill
Education, India

11. Halvorson, M (2010). Microsoft Visual Basic 2010, Microsoft Press, Redmond
Washinton

12. Hodson, J. (2006). Local Area Networks 4th ed. Bookpower,UK.

13. ITL Education solution Limited. (2011). Introduction to computer science 2nd
edition.Pearson, India

14. Kate T., Gauri S., Pooja Sehgal, Rupal Bansal, Nikhilesh Jasuja, Syed Ali
Husnain Gilan (2022, Oct., 23). Hardware vs Software. Diffen.com. Diffen
LLC, https://www.diffen.com/difference/Hardware_vs_Software

384
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 384 23/01/2023 11:27:07


Computer Science
15. Konsbruck Robert Lee. (2002). Impacts of Information Technology on Society in
the new century. Business and Management, 5(6), 46-55.

16. Kumar, V., & Sinha, D. (2021). A robust intelligent zero-day cyber-attack
detection technique. Complex & Intelligent Systems, 7(5), 2211-2234.

17. McBride, P. K. (2002). Introductory Visual Basic. Thomson Learning, High


House, 50-51 Bedford Row, London WC1 4LR

18. Mishra, S. (2015, December). Network security protocol for constrained


resource devices in Internet of things. In 2015 Annual IEEE India Conference
(INDICON) (pp. 1-6). IEEE.

19. Pal, S., Hitchens, M., Rabehaja, T., & Mukhopadhyay, S. (2020). Security
requirements for the internet of things: A systematic approach. Sensors, 20(20),
5897.

20. Proudfoot, R. and Kelley, S. (2017). Can technology save the planet? WWF
Australia.

21. Proudfoot, R., & Kelley, S. (2017). Can technology save the planet? WWF
Australia. https://www.wwf.org.au/ArticleDocuments/360/pub-can-technology-
save-the-planet-30may17.pdf.aspx?Embed=Y

22. Schwab, K. (2016). The Fourth Industrial Revolution. World Economic Forum.
Cologny, ISBN-13: 978-1-944835-01-9

23. Schwab, K., Nadella, S., and Davis, N. (2018). Shaping the Fourth Industrial
Revolution. World Economic Forum. ISBN 9781984822611, Ebook ISBN
9781984822628

24. Sensors, E. (2019). The Impact of Technology on the Environment and How
Environmental Technology Could Save Our Planet. Accessed at: https://
edinburghsensors.com/news-and-events/impact-of-technology-on-the-
environment-and-environmental-technology/
25. Smith, A J (2011). Visual Basic programs to accompany programming logic
and design six edition, Course Technology 20 channel centre street Boston, MA
02210 USA

26. UNACTAD. (2018). Technology and Innovation Report: Harnessing Frontier


Technology for Sustainable Development. United Nations.

27. Writing, A. (n.a.). The Advantages & Disadvantages of Visual Basic. Techwalla.
https://www.techwalla.com/articles/the-disadvantages-of-ruby-programming

385
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 385 23/01/2023 11:27:07


Index
Computer Science

Bluetooth, 128, 129, 181


Access, 285
Boolean, 3, 4, 59
Access control, 285, 286, 288, 322
bridge, 31, 62, 127, 138, 147, 148, 150,
Active, 285
182
alternate keys, 87
Broadband, 172
analog, 117, 118, 119, 146, 169, 172,
Brouter, 150
173, 185, 186, 189, 190, 193, 196
Bubble sort, 54, 60
Angry IP Scanner, 308
Burp Suite, 308
antenna, 174, 175, 176, 177, 196, 359
Cain & Abel, 308
Arithmetic, 188
candidate keys, 87, 103, 104
ARP, 155, 276, 309
Character, 4
Array, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15,
18, 24, 25, 26, 32, 45, 50, 52, 54, 57, Classful, 160, 162, 164
58, 59, 60, 61, 62
Classification, 2, 7, 119, 127, 128, 133,
artificial intelligence, 337, 345, 346,
Clearing tracks, 307, 308
365, 366, 368
Cloud computing, 311, 324, 325, 326,
Artificial Intelligence, 324, 334, 337,
327, 350, 351, 368
345, 365
Cloud Developers, 327
assessments, 285
Coaxial, 127, 169, 171, 172, 173
Asynchronous, 119, 122, 125, 131, 190
code, 12, 24, 38, 40, 56, 86, 107, 110,
Attributes, 86
273, 274, 277, 278, 294, 318, 320,
Augmented Reality, 337, 360 326, 328, 349, 350
Authorization, 264, 285 communication, 68, 71, 115, 116, 117,
118, 119, 120, 121, 122, 123, 124,
Base Band, 172
125, 126, 127, 128, 130, 131, 153,
Batch, 74, 75 154, 155, 156, 157, 159, 161, 168,
174, 176, 177, 178, 179, 180, 181,
Big data, 345, 357, 358, 368 185, 187, 188, 189, 190, 191, 192,
binary search, 34, 48, 49, 50, 60, 61 193, 196, 265, 275, 285, 287, 292,
294, 299, 322, 326, 331, 332, 336,
Blockchain, 337, 339, 345, 347, 348, 338, 341, 363, 365, 372
349, 368, 372

386
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 386 23/01/2023 11:27:07


composite, 16, 88, 101 data structures, 1, 2, 3, 4, 5, 6, 7, 14,
19, 24, 25, 32, 45, 59, 60, 82, 83, 99

Computer Science
computer, 1, 2, 6, 12, 19, 38, 49, 59,
60, 64, 66, 67, 68, 69, 70, 72, 73, 75, database, 17, 45, 63, 70, 74, 75, 77, 78,
76, 77, 105, 115, 116, 121, 122, 127, 79, 80, 81, 82, 83, 84, 85, 86, 87, 89,
128, 129, 130, 131, 132, 134, 140, 90, 91, 92, 93, 94, 96, 98, 99, 100,
141, 142, 143, 146, 150, 152, 154, 101, 105, 106, 107, 108, 110, 111,
160, 161, 164, 168, 172, 184, 187, 112, 113, 262, 273, 277, 278, 282,
192, 193, 194, 196, 262, 263, 264, 297, 299, 303, 305, 311, 326, 327,
266, 267, 268, 269, 270, 271, 273, 347, 348, 349, 357
275, 276, 279, 280, 281, 282, 284,
DBMS, 78, 83, 84, 112
285, 289, 303, 304, 305, 308, 309,
310, 311, 313, 317, 318, 319, 320, decision, 33, 63, 64, 65, 68, 70, 74, 75,
321, 322, 323, 325, 326, 332, 333, 76, 82, 150, 192, 295, 339, 345, 362,
334, 335, 337, 342, 345, 349, 350, 363, 365
353, 360, 362, 368, 372
Defence in depth, 284
computer programmer, 326
demodulator, 146
Computer security, 262
dependency, 82, 86, 96, 97, 98, 103,
Concatenation, 27, 28 104, 113
conquer, 50, 57, 58 depletion, 161, 331
CPU, 31, 47, 302 digital library, 77
Crack -proofing, 318 Distinct type, 88
Creation operation, 27 Do....while loop., 44
Cyber terrorism, 305 domain, 85, 86, 87, 92, 101, 147, 150,
161, 279
Data, ix, 1, 2, 8, 11, 28, 50, 63, 69, 70,
75, 76, 78, 80, 82, 83, 91, 99, 101, Double, 4
106, 107, 108, 110, 112, 115, 116,
117, 118, 119, 121, 122, 125, 129, drones, 345, 358, 359, 360, 368
130, 144, 148, 150, 153, 155, 156, Dynamic, 5, 24, 25, 149, 191
157, 158, 159, 172, 179, 192, 193,
265, 266, 267, 268, 271, 285, 301, emerging technologies, 2, 326, 336,
302, 303, 311, 323, 324, 334, 351, 337, 339, 364, 365, 366, 367, 368
357, 363, 372 encapsulation, 155, 157, 158, 159, 193,
Data Access, 285 196

data model, 79, 81, 82, 83, 84, 85, 92, encryption, 112, 113, 268, 270, 285,
93, 100, 113, 117 293, 302, 311

387
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 387 23/01/2023 11:27:07


Ethernet card, 150, 151 68, 69, 72, 73, 74, 75, 76, 77, 113,
262, 265, 266, 283, 305, 322
Computer Science

Ethernet network, 135, 180


infrared, 127, 128, 129, 179, 180, 184,
Ettercap, 308
193
Facial, 346
Inorder, 33, 34, 35
firmware, 262
Insertion operation, 27, 28
foreign key, 85, 87, 91, 92
Insertion-sort, 50, 52
Fragmentation, 155
Integer, 4, 9
frame, 100, 122, 123, 124, 134, 142,
Internet, vii, 68, 69, 70, 71, 115, 131,
148, 190, 294
132, 139, 153, 154, 155, 160, 161,
gadgets, 128, 333, 336, 364 163, 164, 166, 180, 184, 193, 196,
267, 275, 277, 280, 284, 289, 291,
Gateway, 77, 149 298, 299, 304, 311, 314, 316, 317,
Grey hat hackers, 306 326, 329, 330, 331, 332, 333, 334,
335, 337, 342, 345, 350, 351, 355,
Hacktivist, 306 356, 362, 363, 364, 365, 368
half-duplex, 126, 191, 192 IP Address, 160
Hard-disk loading, 317 IPv4, 160, 161, 162, 299
hardware, 2, 37, 63, 68, 69, 70, 73, 83, IPv6, 160, 161, 162, 196, 299
113, 115, 119, 120, 130, 138, 150,
152, 154, 168, 262, 263, 273, 280, iterative, 40, 44, 45, 60
281, 296, 307, 308, 309, 310, 312, LAN, 71, 129, 130, 131, 155, 164, 168,
313, 322, 325, 326, 332, 333, 334, 170, 173, 182, 183, 192, 277, 285
350
LIFO, 28
HTTP, 153, 288, 290
Linear data structure, 2, 4, 5, 28, 32, 60
hub, 127, 129, 130, 135, 136, 147, 148,
194 linear search, 46, 47, 48, 49, 50, 61
IaaS, 350 Linear search, 46, 47, 60
immutable, 347, 348, 349 linked list, 5, 25, 26, 27, 28, 45, 59, 60,
61
Information, ix, 63, 64, 65, 67, 68, 74,
75, 76, 132, 144, 266, 267, 268, 270, logical topology, 133
283, 312, 324, 325, 328, 330, 331,
Mandatory, 286
334, 336, 372
Merge sort, 50, 58
information system, 63, 64, 65, 66, 67,

388
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 388 23/01/2023 11:27:07


Metasploit, 308 POP, 28, 30, 153

Computer Science
Microwaves, 175, 176 Postorder, 33, 36, 61
mobile, 62, 70, 77, 102, 128, 132, 178, Preorder, 33, 35, 37
181, 268, 298, 322, 328, 329, 335,
primary key, 85, 86, 87, 91, 92, 98, 102,
336, 342, 347, 350, 357, 363, 366
103
Modem, 146
Primitive, 2, 3, 4, 5, 27, 59, 60
Multiplexer, 185, 186, 187, 188, 193
print, 32, 303, 353, 354, 355, 367
Multiplexing, 185, 186, 187, 188, 189,
Private Address, 160, 164
190, 191, 193, 196
Programming, ix, 1, 372
MySQL, 77, 92, 106, 112
project manager, 325, 327
Network, 70, 71, 80, 127, 128, 129,
130, 131, 132, 133, 135, 138, 140, properties window
142, 144, 146, 149, 150, 151, 153,
154, 155, 158, 159, 160, 161, 163, protection, 112, 119, 184, 262, 263,
164, 165, 168, 180, 181, 182, 183, 265, 266, 267, 268, 270, 280, 283,
184, 190, 193, 268, 280, 281, 283, 285, 304, 311, 314, 317, 318, 319,
285, 289, 290, 291, 294, 295, 296, 321, 322, 351
297, 298, 307, 324, 325, 326, 327, protocol, 147, 149, 153, 154, 155, 156,
363 157, 159, 160, 181, 192, 193, 197,
network layer, 149, 150, 153, 154, 155, 289, 290, 292, 294, 299, 300, 347
160, 295, 300 PUSH, 28, 29
normalization, 91, 99, 101, 105, 113 query, 82, 89, 91, 109, 110, 111, 113,
OSI, 151, 152, 153, 154, 155, 159, 193, 114, 277, 278
196 queue, 5, 26, 31, 32, 60, 61
PaaS, 350 Queues, 31, 32
packets, 147, 148, 149, 150, 153, 155, Quicksort, 57, 59
156, 157, 160, 161, 190, 276, 290,
292, 294, 298 radio, 70, 116, 127, 129, 175, 178, 179,
180, 182, 193
Passive, 285
real-time, 74, 75, 77, 115, 297, 361
Penetration testing, 305, 309
Records, 16, 17, 60
physical layer, 146, 152, 153, 193
recursion, 40, 41, 43, 57
piracy, 262, 316, 317, 318, 319, 322
Recursive algorithms, 40, 43
pollution, 331

389
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 389 23/01/2023 11:27:07


recursive function, 40, 41, 43 Sorting algorithm, 50
Computer Science

Recycling, 333 stack, 5, 24, 28, 29, 30, 45, 61, 296
Red Hat Hackers, 306 star, 133, 134, 135, 136, 147, 193, 197
redundancy, 78, 80, 98, 101, 268, 282 Switch, 148, 184
Renting, 317 Syntax, 8, 42
Robustness, 2 system administrator, 164, 275, 305,
325, 326
Router, 149, 150, 298
Systems Analyst, 325
Script Kiddies, 305, 306
TCP, 151, 154, 155, 156, 157, 159, 160,
security, 67, 91, 112, 113, 119, 132,
161, 193, 196, 197, 290, 292, 296,
141, 169, 183, 190, 193, 196, 262,
298
263, 264, 265, 266, 267, 268, 269,
270, 271, 278, 280, 281, 282, 283, Telecommunication, 70
284, 285, 286, 287, 288, 291, 293,
telephone, 64, 130, 132, 146, 169, 170,
297, 298, 299, 300, 302, 303, 304,
172, 173, 174, 176, 187, 190, 191,
305, 306, 307, 308, 309, 311, 312,
193, 341, 342
313, 314, 316, 321, 322, 323, 324,
325, 326, 327, 328, 330, 348, 350, terminator, 133, 172
351, 356, 364, 366, 368
topology, 127, 132, 133, 134, 135, 136,
Selection-sort, 50 137, 138, 139, 147, 192, 197, 291,
307
server, 106, 127, 130, 135, 140, 141,
142, 143, 144, 145, 193, 196, 197, transmission, 1, 70, 115, 116, 117, 118,
275, 276, 277, 278, 283, 284, 285, 119, 120, 121, 122, 123, 124, 125,
294, 299, 303, 304, 311, 327, 343, 126, 127, 131, 132, 133, 146, 148,
344, 347, 350, 351, 356 151, 153, 155, 168, 169, 170, 172,
173, 174, 175, 176, 177, 178, 179,
signal, 117, 118, 119, 122, 123, 125,
184, 186, 187, 188, 189, 190, 191,
126, 133, 134, 146, 147, 168, 169,
192, 196, 197, 262, 267, 298, 322,
172, 174, 175, 176, 177, 182, 183,
356
185, 186, 187, 188, 189, 190, 191,
192, 193, 363 Transmitter, 117
Simplex, 119, 125, 126 traversal, 26, 33, 34, 35, 36, 37
Software, 70, 131, 264, 316, 317, 318, Traversing, 27, 28
320, 322, 326, 350, 362
tree, 5, 32, 33, 34, 35, 36, 37, 60, 61,
Software as a Service, 350 79, 80, 133, 134, 138
Software counterfeiting, 317 Trojan, 274, 280, 281, 309

390
Tanzania Institute of Education (TIE) for Advanced Secondary Schools

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 390 23/01/2023 11:27:07


tuple, 85, 86, 87, 89

Computer Science
Two-dimensional, 7, 8, 9, 80
UDP, 153, 155, 156, 157, 161, 193,
197, 290
Unmanned, 337, 358, 359, 360
User Datagram Protocol, 153, 155, 156
user interface, 68, 329
User-defined data, 4, 11, 19, 24
variable, 4, 7, 11, 12, 14, 16, 26, 32, 60,
161
VB.Net
VICOBA, 347, 348
WAN, 71, 129, 131, 132, 155, 178, 182,
192, 193
Web, 132, 317, 324, 325, 328, 330
While loop, 9, 44
White hat hackers, 306
Wi-Fi, 151, 180, 181, 182, 183, 193,
276, 308, 309

391
Student’s Book Form Six Tanzania Institute of Education (TIE)

COMP SCIENCE - F6 (Jan 17) FINAL KAMISHNA.indd 391 23/01/2023 11:27:07

You might also like