CIT 213 - Revised
CIT 213 - Revised
1
NATIONAL OPEN UNIVERSITY OF NIGERIA
FACULTY OF SCIENCE
2
CO URSE
GUIDE
CIT 213
3
NATIONAL OPEN UNIVERSITY OF NIGERIA
e-mail: [email protected]
URL: www.nou.edu.ng
ISBN
4
TABLE OF CONTENTS PAGE
Introduction..............................................................................
What you will learn in this Course.....................................
Course Aims...............................................................................
Course Objectives......................................................................
Working through this Course....................................................
Course Materials...........................................................................
Study Units ...............................................................................
Textbooks and References ........................................................
Assignment File........................................................................
Presentation Schedule...............................................................
Assessment......................................................................
Tutor Marked Assignments (TMAs) .......................................
Examination and Grading..................................................
Course Marking Scheme............................................................
Course Overview
5
Introduction
CIT 213 Elementary Data Processing is a two (2) credit unit course of sixteen units. It deals with
the fundamentals concepts of data processing, essential components of computer systems, data
processing personnel, file access, and organization techniques. Also, it deals with the tools for
developing data processing applications and provides an overview of Visual Basic Language and
Structured Query Language. Sample programs and queries are provided to enable the students to
acquire the necessary skills for solving real-life problems. The study material provides adequate
background information that is relevant for students pursuing a career in data processing or related
disciplines. The course is divided into four modules:
Module 1 introduces the basic concepts of data processing, explains the meaning of data,
Information and data processing. A detailed description of the computer hardware and
software components required for data processing is covered. The various input and output
devices such as pointing devices, pen-based devices, optical character recognition, printers,
plotters, etc. and their suitability for data processing are explained.
Module 2 provides information on data storage devices and the parameters for disk performance.
File access and organization techniques - serial, sequential, indexed-sequential, and random file
organization are covered in this module. Besides, students will learn data processing techniques
such as Batch processing, online Processing, Transaction Processing, Real-time Systems, and
Distributed processing.
Module 3 begins with database processing, the meaning of database, components of a database, and
database models. For example, a relational database, hierarchical database, network database, an
object-oriented database, is explained. Data processing personnel are covered. Besides, tools for
developing data processing applications such as programming languages, report generators,
computer-aided software engineering, query languages, etc. are covered in this module.
Module 4 provides an overview of Visual Basic (VB) language and Structure Query Language
(SQL). The fundamental concepts of visual and event-driven programming are covered. The
student will learn how to write simple programs that respond to events Control structure, arrays, file
processing, and how to use the print statements are covered. Also, the students will learn how to
write simple SQL queries by using the CREATE, SELECT, INSERT, UPDATE, and DELETE
commands. This course aims to equip the learners with essential information and understanding of
data processing concepts as well as acquiring the relevant skills to manage and implement data
processing systems. At the end of the course, students would have gained the appropriate
knowledge and acquired the skills to manage the data processing department of any organization
effectively.
6
This Course Guide gives a brief overview of the course content, course duration, and course
materials.
The primary purpose of this course is to provide the required knowledge and business
programming skills for the students to effectively data processing systems and manage the data
processing department of an organization. The basic concepts of data processing, computer
systems required for data processing, data processing personnel, tools for developing data
processing applications, and basic programming skills are covered in this study material. This,
we intend to achieve through the following:
Course Aims
The aims of this course are to:
(i) Explain the concepts, systems, personnel, tools for data processing
(ii) Describe data processing techniques
(iii) Acquire skills for developing, implementing and managing data processing systems or
department
Course Objectives
Specific objectives have been set out to ensure that the course achieves its aims. Apart from the
course objectives, every unit of this course has set objectives. In the course of the study at the end of
each unit, the objectives would have been met. By the end of this course students should be able to:
To have a thorough understanding of the course units, students will need to read and understand the
contents, practice what they have learnt by studying the network of the organization, or proposing
one if there is none in existence and be committed to learning and implementing the knowledge.
This course is designed to cover approximately sixteen weeks, and it will require a devoted
attention. Students should do the exercises in the Tutor-Marked Assignments and submit to the
tutors.
7
Course Materials
These include:
1. Course Guide
2. Study Units
3. Recommended Texts
4. A file for your assignments and for records to monitor your progress.
Study Units
Module1
Module 2
Module 3
Module 4
Unit 1 CONTROL STRUCTURE AND STRING PROCESSING
Unit 2 ARRAYS AND PRINTING
Unit 3 FILE PROCESSING
Unit 4 STRUCTURED QUERY LANGUAGE (SQL)
Make use of the course materials, do the exercises to enhance your learning.
Alexis Leon and Matthew Leon, Fundamental of Information Technology, L & L Consultancy Services Pvt.
Ltd, 1999
ITL Education Solutions Limited, Introduction to Information Technology, 2nd Edition, Pearson Education
India, 2012, ISBN: 9789332525146
Introduction to Computers and Information Technology, 2nd edition, Pearson, 2015, ISBN-13:
9781323237120
8
Brain K. Williams, and Stacey C. Sawyer, Using Information Technology, A practical Introduction to
Computers and Communications, McGraw Hill, 2005, N.Y
Eric Frick, Information Technology Essentials Volume 1: Introduction to Information Systems, Volume 1 of
Information Technology Essentials Series, Amazon Digital Services LLC - KDP Print US, 2019,
ISBN:1708175148, 9781708175146
Carl Hamacher, Zvonko Vranesic, Safwat Zaky, Computer Organization, Fifth Edition, McGraw-Hill
Higher Education, N.Y, 2002
Gerald V. Post, Database Management Systems, Designing, and Building Business Applications, Third
Edition, McGraw-Hill, 2005
Jan L. Harrington, SQL Clearly Explained, Morgan Kaumann Publisher, An Imprint of Elsevier
Science, 2003, USA
Steve Tale, SQL: The Ultimate Beginners Guide: Learn SQL Today, CreateSpace Independent
Publishing Platform, 2016, ISBN 1533604568, 9781533604569
Dusan Petkovic, Microsoft SQL Server 2016: A Beginner's Guide, Sixth Edition, 6th Edition, McGraw-
Hill 2016, ISBN: 9781259641800
Linda Null, Julia Lobur, The Essentials of Computer Organization and Architecture
Jones & Bartlett Learning, 2006 – Computers.
Jeffery L. Whitten, Lonnie D. Bentley, Kevin C. Dittman, Systems Analysis and Design Methods,
McGraw Hill, New York, 2004,
Julia Case Bradley, Anita C. Millspaugh, Programming in Visual Basic 6.O, McGraw-Hill Higher
Education, 2002
Management Information Systems, Organization, and Technology in the Kenneth C. Laudon, Jane P.
Laudon, Prentice Hall International, Inc, 2000
Greg Perry and Dean Miller, C Programming Absolute Beginner's Guide, 3rd Edition, Que Publishing
2014.
R. G. Anderson, Data Processing, Volume 1: Principles and Practice, Pitman Publishing, Singapore,
1990
http://computer.howstuffworks.com/hard-disk7.htm
9
Assignments File
These are of two types: the self-assessment exercises and the Tutor-Marked Assignments. The self-
assessment exercises will enable you to monitor your performance by yourself, while the Tutor-
Marked Assignment is supervised. The assignments take a certain percentage of your total score in
this course. Your tutor will assess the Tutor-Marked Assignments within a specified period. The
examination at the end of this course will aim at determining the level of mastery of the subject
matter. This course includes seventeen Tutor-Marked Assignments, and each must be done and
submitted accordingly. Your best scores, however, will be recorded for you. Be sure to send these
assignments to your tutor before the deadline to avoid the loss of marks.
Presentation Schedule
The Presentation Schedule included in the course materials contains the important dates for the
completion of tutor marked assignments and attending tutorials. Students are required to submit all
the assignments by the due date. Please guard against lagging behind in your work.
Assessment
There are two aspects to the assessment of the course. First are the tutor marked assignments;
second, is a written examination.
In tackling the assignments, you are expected to apply the information and knowledge acquired
during this course. The assignments must be submitted to your tutor for formal assessment
following the deadlines stated in the Assignment File. The work you submit to your tutor for
assessment will count for 30% of your total course mark.
At the end of the course, you will need to sit for a final three-hour examination. This will also count
for 70% of your total course mark.
Assignment questions for the units in this course are contained in the Assignment File. You should
be able to complete your assignments from the information and materials contained in your set
textbooks, reading, and study units. However, you may wish to use other references to broaden
your viewpoint and provide a deeper understanding of the subject.
When you have completed each assignment, send it together with the form to your tutor. Make sure
that each assignment reaches your tutor on or before the deadline given. If, however, you cannot
complete your work on time, contact your tutor before the assignment is done to discuss the
possibility of an extension.
This course endows you with the status of a teacher and that of a learner. This means that you teach
yourself and that you learn, as your learning capabilities would allow. It also means that you are in
a better position to determine and to ascertain the what, the how, and the when of your course
10
learning. No teacher imposes any method of learning on you. The course units are similarly
designed with the introduction following the table of contents, then a set of objectives and then the
concepts and so on. The objectives guide you as you go through the units to ascertain your
knowledge of the required terms and expressions.
Assessment Marks
Assignment 1- 4 Four assignments, best three marks of the at
30% of course marks
Final Examination 70% of overall course marks
Total 100% of course marks
Revision Week 16
Examination Week 17
TOTAL 17 weeks
11
How to get the best from this course
In distance learning, the study units replace the university lecturer. This is one of the great
advantages of distance learning; you can read and work through specially designed study materials
at your own pace and at a time and place that suits you best. Think of it as reading the lecture
instead of listening to a lecturer. In the same way that a lecturer might set you some reading to do,
the study units tell you when to read your set books or other material. Just as a lecturer might give
you an in-class exercise, your study units provide exercises for you to do at appropriate points.
Each of the study units follows a standard format. The first item is an introduction to the subject
matter of the unit and how a particular unit is integrated with the other units and the course as a
whole. Next is a set of learning objectives. These objectives enable you to know what you should
be able to do by the time you have completed the unit. You should use these objectives to guide
your study. When you have finished the units, you must go back and check whether you have
achieved the objectives. If you make a habit of doing this, you will significantly improve your
chances of passing the course.
Remember that your tutor’s job is to assist you. When you need help, don’t hesitate to call and ask
your tutor to provide it.
1. Read this Course Guide thoroughly.
2. Organize a study schedule. Refer to the Course Overview for more details. Note the time you
are expected to spend on each unit and how the assignments relate to the units. Whatever method
you chose to use, you should decide on it and write in your dates for working on each unit.
3. Once you have created your study schedule, do everything you can to stick to it. The primary
reason that students fail is that they lag in their course work.
4. Turn to Unit 1 and read the introduction and the objectives for the unit.
5. Assemble the study materials. Information about what you need for a unit is given in the
overview at the beginning of each unit. You will almost always need both the study unit you are
working on and one of your sets of books on your desk at the same time.
6. Work through the unit. The content of the unit itself has been arranged to provide a sequence
for you to follow. As you work through the unit, you will be instructed to read sections from your
set books or other articles. Use the unit to guide your reading.
7. Review the objectives for each study unit to confirm that you have achieved them. If you feel
unsure about any of the objectives, review the study material, or consult your tutor.
8. When you are confident that you have achieved a unit s objectives, you can then start on the
next unit. Proceed unit by unit through the course and try to pace your study so that you keep
yourself on schedule.
9. When you have submitted an assignment to your tutor for marking, do not wait for its return
before starting on the next unit. Keep to your schedule. When the assignment is returned, pay
particular attention to your tutor s comments, both on the tutor-marked assignment form and
also written on the assignment. Consult your tutor as soon as possible if you have any questions
or problems.
10. After completing the last unit, review the course and prepare yourself for the final
examination. Check that you have achieved the unit objectives (listed at the beginning of
each unit) and the course objectives (listed in this Course Guide).
12
Tutors and Tutorials
There are 12 hours of tutorials provided in support of this course. You will be notified of the dates,
times, and location of these tutorials, together with the name and phone number of your tutor, as
soon as you are allocated a tutorial group.
Your tutor will mark and comment on your assignments, keep a close watch on your progress, and
on any difficulties you might encounter and provide assistance to you during the course. You must
mail or submit your tutor-marked assignments to your tutor well before the due date (at least two
working days are required). They will be marked by your tutor and returned to you as soon as
possible.
Do not hesitate to contact your tutor by telephone or e-mail if you need help. The following might
be circumstances in which you would find the necessary support. Contact your tutor if:
• you do not understand any part of the study unit s or the assigned readings,
• you have difficulty with the self-tests or exercises,
• you have a question or problem with an assignment, with your tutor s comments on
an assignment or with the grading of a project.
You should try your best to attend the tutorials. This is the only chance to have face to face contact
with your tutor and to ask questions which are answered instantly. You can raise any problem
encountered in the course of your study. To gain the maximum benefit from course tutorials,
prepare a question list before attending them. You will learn a lot from participating in discussions
actively.
Summary
Elementary Data processing provides knowledge and skill for data processing. The skills you need
to manage and implement the data processing system are expected to be acquired in this course.
The content of the course material was planned and written to ensure that you receive the proper
knowledge and skills to solve real-life data processing problems. Fundamental programming
principles are taught. The sample programs provided are for you to develop your programming
skills.
13
Course CIT 213
Code
Course Co-ordinator :
National Open University of Nigeria
Lagos.
14
National Open University of Nigeria
Headquarters
14/16 Ahmadu Bello Way
Victoria Island
Lagos
Abuja Annex
245 Samuel Adesujo Ademulegun Street
Central Business District
Opposite Arewa Suites
Abuja
e-mail: [email protected]
URL: www.nou.edu.ng
ISBN
It was printed by
For
National Open University of Nigeria
15
MODULE 1
UNIT 1: INTRODUCTION AND SCOPE OF DATA PROCESSING
Table of Contents
1.0 Introduction
2.0 Objectives
3.0 Main Text
3.1 Data and Information
3.2 Electronic Data Processing Systems
3.3 The Scope of Data Processing System
3.4 Computer Systems
3.4.1 Computer Generation
3.4.2 Analog and Digital Computer
3.4.2.1 Analog Computers
3.4.2.2 Digital Computers
3.5 The Basic Operations of Computing
3.6 Benefits of Using Computer in Business
4.0 Conclusion
5.0 Summary
6.0 Tutor Marked Assignment
7.0 References/Further Readings
1.0 Introduction
The word data refers to raw facts about and object. Data is meaningless until it is subjected to
manual or electronic processing by a computer to produce information used for decision making.
Computers are used to process data because of their speed, reliability, and other functionalities
they offer. Their sizes, types can distinguish computers and generation.
2.0 Objectives
At the end of this unit, you should be able to:
• Define and explain the terms; data and information
• Describe a computer system
• Explain the meaning of data processing
• Distinguish between the different types of computer
• Describe the basic operations of a computer
• List some benefits of using the computer in business
16
Table 1: Student Registration
The details of this student (Adebayo Musa, Ada), if treated independently, may not have specific
meanings until it is subjected to some manual or computerized processing. A human or input may
further process the raw data in the tables into a computer, stored, processed, and transmitted
(output) to another human or a computer. A typical data processing function will be to locate a
student record or data from a large file-based on matriculation numbers. If this is to be carried out
manually, a lot of time and effort will be required by the data processing personnel.
When the method of data processing is manual, it is called manual data processing. On the other
hand, when the method of processing is electronic, we refer to it as electronic data processing.
Computers are used to turn meaningless data by processing them into useful information, such as
spreadsheets, graphs, and reports. Information is defined as either a meaningful answer to a query
or a significant stimulus that can cascade into further queries. For example, with the data in
table1 and table 2, the bank official may be interested in the number of students from each
school that has subscribed to a particular service its offers. In which case, a query will be run on
the existing database. The result of the query will provide information that will help the
management of the bank to discontinue or continue with the service. Some characteristics of
information are relevance, accuracy, conciseness, timeliness, and completeness.
17
useful information as output. In many organizations, these systems exist as payroll systems, sales
and marketing systems, finance and accounting systems, manufacturing and production system,
human resources systems, University management systems, etc.
Also, the term data processing can apply to any process of transforming data into information
and also the converting of information back to data.
Thus, data processing consists of those activities concerned with the systematic recording, sorting,
computing, modifying, reporting displaying, and printing of details relating to business
transactions. At the same time, a data processing system can, therefore, be viewed as an
administrative system superimposed upon the physical business systems such as banking,
engineering, insurance, etc. The ultimate goal of data processing is to obtain information with
which to control the financial and administrative aspects of the business. Besides, managers and
administrators with up-to-date information can make the right decisions that will positively affect
the growth of the organization.
18
data, raw facts and figures, and processes, or manipulates it into useful information Computers are
used primarily to speed up problem-solving and increase the overall productivity of its users. The
computer reads in data and instructions does some processing, and stores or outputs desired
results. The laptop is designed with an input mechanism for reading data into the computer,
internal storage facilities, and means for communicating with the outside world (output for writing
data out.) For data to be processed by a computer, the data needs first to be converted into a
machine-readable format. Once data is in digital format, various procedures can be applied to the
data to get useful information.
CHARACTERISTICS OF COMPUTERS
Computers have certain definite characteristics that make them unique.
(a) Speed: ability to execute or carry out instructions at very great speed.
(b) Accuracy: Computers per se do not make errors i.e. there is accuracy of work. Any error is
usually caused by the human elements.
(c) Storage: store large volume of data/information on secondary storage, which can be retrieved
at a later time.
(d) Consistency: ability to consistently follow instructions without getting tired.
(e) Repetitiveness: ability to continue processing over an extended period.
(f) Complexity: carry out very complex operations that beats the best human ability.
19
- Generate a lot of heat
- They relied on machine language for performance
- Solve one problem at a time
- Input was based on punched cards and paper tape
20
- Smaller computers were linked together to form networks
- This development led to Internet
- Development of Graphical User Interface (GUI)
21
Figure 1: Analog Computer
Mainframe
A mainframe is the most extensive and relatively most powerful computer, a powerhouse with
ample storage and very rapid processing power and speed. It is used for a substantial amount of
business, scientific and engineering, military data. They are found in many data processing
centers, such as in Banks, military, airports, nuclear stations, universities, and other organizations
where large amounts of data are processed.
22
Figure 3: Mainframe Computer
Minicomputer
A minicomputer is a mid-range, multi-purpose computer about the size of an office desk produced
by several manufacturers, including Dell, Hewlett Packard, and IBMC, often used in universities,
factories, and research laboratories. Applications processed on minicomputers include Accounting
routines, banking, examination processing, hospital management systems, databases, geographical
information systems, and other management information systems. Some training or professional’s
certifications may be required to handle these systems compared to the operations of
microcomputers.
Microcomputers
Microcomputers are sometimes referred to as personal computers (PCs). They are the computers
that can be placed on desktops or carried from room to room. Some manufacturers of
microcomputers include IBM, Dell, Hewlett Packard, Apple, and Compaq. As the names apply,
PCs are used and operated by end-users for their own particular processing needs such as
payroll, inventory control, asset management, result verification, patient medical records, and
other general accounting routines. Laptops and palmtops, in particular, are the portable types of
23
PCs built with a lot of mobility functionality. Not so much skill is required to operate
microcomputers as compared with mini and mainframe computers.
Workstation
A workstation is so much like a PC except that it is more powerful and has more capabilities for
handling mathematical and graphics-processing than a PC. It can take more complicated tasks
than PC in the same amount of time. Workstations are used mainly in handling computing
(number crunching and algorithmic) applications such as in science, engineering, and design work
that requires powerful graphics or computational capabilities rather than data processing
applications where the arithmetic operation may be ideal.
Supercomputer
A supercomputer is a highly sophisticated and robust machine that is used for tasks requiring rapid
and complex calculations with hundreds of thousands of variable factors. Supercomputers
traditionally have been used in scientific and military work, but they are starting to be used in
business as well. A supercomputer is an incredibly sophisticated and powerful type of computer
that is used primarily for extremely rapid and complex computations with hundreds of thousands
of variable factors. Supercomputers traditionally have been used for classified weapons research,
weather forecasting, and petroleum and engineering applications, all of which use complex
mathematical models and simulation. Although extremely expensive, supercomputers are
beginning to be employed in the business for data mining and the manipulation of vast quantities
of data. Supercomputers can perform complex and massive computations almost instantaneously
because they can perform hundreds of billions of calculations per second-many times faster than
the most massive mainframes.
As technology continues to advance, we expect that these distinctions will become less
pronounced.
24
Figure 6: A Supercomputer
Input Operations:
At this stage, data or instructions are captured electronically or entered employing the available
input device. An input device is a hardware such as a keyboard that allows data from the external
environment to be entered into the computer for processing. The data after it has been captured is
transformed into a form in which the computer can process it.
Processing Operations:
At this stage, the already captured and transformed data is manipulated to generate the desired
result for the end-user other processing systems. The information is worked on by the instructions
in the form of programs or queries provided by the users. The instruction and the data determine
what output is received from the computer. The processing instructions may be to add, subtract,
multiply, find total, summarize, group, select some data based on some condition, etc.
Output Operations:
At the stage the result or information obtained from the data is produced in a
form acceptable by the user. An example of on output will be a list of all registered students in the
department of accounting who are in their second year at National Open University, Lagos Centre.
The output can be printed as printed text, played as sound, displayed as charts or graphs on the
computer screen. The output is usually governed by the need to communicate specific information
to a specific audience. The only limit to the different forms of output you can produce is the
different types of output devices currently available.
25
Secondary-storage operations:
At this stage of operations, data, information, and the instructions used for the processing of data
are stored temporarily or permanently in primary or secondary storage devices. Data and
instructions are stored in primary storage devices during processing to allow easy access and fast
processing. Secondary storage devices are used to store data or instructions more permanently. An
example of a primary or internal storage device is RAM (Read Only Memory). While an example
of a secondary or external storage device is a flash disk.
Communication Operation
There may be a need to transmit already processed data to an end-user or an output device in a
remote location. Similarly, data may be gathered from a remote location. The communication
operation of the computers performs these by using communication hardware. This facilitates the
connection between computers and between groups of connected computers called networks.
Computers linked together can share hardware, programs, and data. Though computers can
operate as standard alone machines, that is, they may not be connected to anything else. By
connecting them in a network, more benefits are realized.
The five basic operations of a computer system take place so fast that they seem to happen all at
the same time.
Computers have also drastically changed the way agricultural tasks and businesses are carried out
all over the world. In agriculture, computers are being used to find out the best possible kinds of
soil, plants and to check which match of these would result in the perfect crops. The use of
computers thus in this sector, along with the use of better agricultural practices and products in
several countries, like India, could help the agricultural industry reach soaring heights, directly
assuring the welfare of the economy. It is also wonderful to see that the invention of this
unbelievable machine has brought a ray of hope in the darkness of the sick citizens’ world.
Computers are very capable of bringing along a medical revolution. Where in health sectors,
computers are being used for research regarding blood groups, medical histories, etc. and helping
to improve medicine in a big way. The knowledge that computers are providing in this field may
lead to better use and purchase of medicinal drugs and ensure better health. This also leads to a
better diagnosing pattern and makes health care faster and more efficiently.
26
3.7. Benefits of Using a Computer in Business
• It leads to improved customer relations due to its reliability, generation of more timely
reports, and speedier responses to inquiries regarding business operations
• Increases the productivity of staff, in general, be helping to handle boring and routine
operations leaving the staff to be engaged in decision making.
• Improved cash flows due to improved sales accounting systems particularly those relating
to credit control, invoicing and statement preparation
• It guarantees improved access to information through online and real-time access to
information systems.
• It allows for a more significant degree of systems integration on the basis that the output of
one part of the system (subsystem) provides the input to a related subsystem, which has the
effect of eliminating duplication and delay.
• Makes the presentation of information for decision making it easy to comprehend.
Information is presented in simplified formats such as graphs, charts, graphics images, etc.
• It helps in the simplification of problem-solving by the use of problem-solving software.
• Makes the supply of information for improving managerial decision readily available
4.0 Conclusion
There terms data and information are commonly used by many people as if they mean the same
thing. The differences between them have been made more evident. Data processing is not the
same as computing. Some basic operations that are involved in data processing include Data
Collection, Data Capture, Data Recording, Data Entry, Data Transmission, Data Sorting.
Electronic data processing requires the use of computers which their sizes, types or generation
distinguish ma y
5.0 Summary
In this unit, we have explained the fundamental Electronic Data Processing Concepts. This should
provide a good background for the easy comprehension of the contents in other units.
27
MODULE 1
UNIT 2: BASIC HARDWARE COMPONENTS AND MEMORY CAPACITY
MEASUREMENT
Table of Contents
1.0 Introduction
2.0 Objectives
3.1 Input Device
3.2 The Central Processing Unit (CPU)
3.3 The Control Unit
3.4 Arithmetic and Logic Unit
3.5 Memory
3.6 Measuring the Memory Capacity of Computer System
4.0 Conclusion
5.0 Summary
6.0 Tutor Marked Assignment
7.0 References/Further Readings
1.0 Introduction
To function properly, the computer needs both hardware and software. Thus a computer system is
made up of hardware and software. The hardware consists of the electronic and electromechanical
parts of the computer. This is the tangible or touchable part of the computer. These components
include input devices, central processing units, main memory, secondary memory, and output
devices. Two components handle processing in a computer: the central processing unit, or CPU,
and the memory. Both are located on the computer system board or motherboard, the circuit that
connects the CPU to all other hardware devices. The processor works hand in hand with other
circuits known as the main memory and registers to carry out the processing. The basic unit of
information representation in the computer is the bit.
2.0 Objectives
At the end of this unit, the student should be able to:
• Identify and describe the essential hardware components of a computer system
• Explain the units of measuring computer memory
28
3.2 The Central Processing Unit (CPU)
The CPU is the brain of the computer, and it is the place where data is manipulated within the
computer system. In a microcomputer, the entire CPU is contained on a tiny chip called a
microprocessor, which is usually mounted on a piece of plastic with metal wires attached to it.
The CPU is otherwise known as the heart of the computer. Where
- All manipulations are done,
- Main operation is being carried out. It is as important to computer as the heart is to the body.
- It stand between the input and output devices.
- It receives incoming data and instructions, works upon the data and sends to destination unit
- It consists of the arithmetic and logic unit, the control unit and the memory unit. processor
consists of two functional units: the control unit and the arithmetic-logic unit. The CPU
- It performs most of the calculations within the computer responsible for the smooth running of
your operating system (Microsoft Windows) as well as your application programs, such as
word processors, spreadsheets and databases.
- A small amount of memory associated with the CPU is used to perform these operations. It also
accesses and uses the main memory (RAM - Random Access Memory) within your computer.
- CPU is the single most important item within your computer that governs the overall speed of
your computer. The CPU's speed is measured in MHz.
- the higher the MHz rating of your CPU the faster your computer will run
3.5 Memory
The CPU's main job is to follow instructions encoded in programs, but it cannot store entire
programs or large sets of data permanently. However, the CPU has registers, which are devices
29
capable of holding a few bytes of data or instructions at a time. CPU needs to have millions of
bytes of space where it can hold programs and the data being manipulated while they are being
used. This area is called memory. Computers use two types of memory- primary and secondary
memory. The Primary Memory is an electronic device that stores the information necessary for a
program to run. This consists of the volatile memory (RAM) and the nonvolatile memory (ROM).
RAM
RAM is an acronym for Random Access Memory. It is used for short-term storage of data or
program instructions. RAM is volatile: Its contents will be lost when a power outage disrupts the
computer s electric supply or when the computer is turned off. The purpose of RAM is to hold
programs and data while they are in use. Physically, RAM consists of some chips on a small
circuit board. A computer does not have to search its entire memory each time it needs to find
data. Access to the data is usually direct using its memory address. The main functions of the
RAM chip include:
• It holds data for processing
• It holds instructions (the programs) for processing
• It holds data that has been processed (useful information) and is waiting to be sent to an
output device.
• main 'working' memory used by the computer
• modern computer can effectively house as much RAM as you can afford to buy.
• modern computers are supplied with over 128 MB of RAM.
• a Microsoft Windows based computer will operate faster if you install higher size RAM
• Data and programs stored in RAM are volatile (the information is lost when you switch off
the computer).
ROM
This is an acronym for Read-Only Memory. This is a nonvolatile type of memory. Nonvolatile
chips always hold the same data; the data in them can be read and used; it cannot be changed.
One crucial reason a computer needs ROM is so that it knows what to do when the power is first
turned on. Among other things, ROM contains a set of start-up instructions, which ensure that the
rest of the memory is functioning correctly, check for hardware devices, and check for an
operating system on the computer disks drives. Unlike the RAM, which is constantly being
written on an erased, ROM cannot be written on or erased by the computer user. Besides, ROM
chips remember, permanently, the information supplied by the manufacturers, such as the
information about the manufacturer. This unit is also known as Secondary storage, Auxiliary
storage, Backing storage or External storage. Data coming to the computer are received by the
memory and passed to a permanent storage device. This memory is used to store data not currently
being operated on but which will be transferred to the main storage when required. Secondary
storage is non-volatile and retains data even when the computer is turned off. There are many
kinds of secondary storage; the most common ones are magnetic tape, magnetic disk and compact
disk.
30
3 It is very expensive It is not expensive
Three variations of ROM chips are used in special situation-PROM, EPROM and EEPROM
PROM :
This is an acronym for programmable read-only memory. These are blank chips on which the
buyer, using special equipment, write the programs. Once the program is written, it cannot be
erased. Some microprocessor software packages come on PROM units. Manufacturers use PROM
chips as control devices in their products.
EP ROM
EPROM stands for electronically erasable read-only memory. They are like PROM chips except
that the contents can be erased, using special equipment and new materials can be written. PROM
chips are used for intelligent device control, such as in robots, where the program may have to be
modified regularly. Programs in the EPROM chip can be erased and reprogrammed.
EEPROM
This is an acronym for electronically erasable programmable read-only-memory. The memory
chips can be reprogrammed can be erased by exposing it to an electrical charge. The advantage of
EEPROM chips is that they need not be removed from the computer to be changed.
3.6 Registers
These are special, high-speed storage area within the CPU. All data must be represented in a
register before it can be processed. For example, the control unit might load two numbers from
memory into the registers in the ALU. Then it might tell the ALU to multiply the two numbers
(arithmetic operations) or to see whether the number is equal (a logical process). The number of
registers that a CPU has and the size of each help determine the power and speed of a CPU. For
example, a 64-bit CPU is one in which each register is 64 bits wide. Therefore, each CPU instruction
can manipulate 64 bits of data.
31
Figure 7 The System Mother Board
Bits
The term bit is a short form of binary digit. A bit is the smallest possible unit of data. To represent
anything meaningful, the computer needs groups of bits.
Bytes
A group of eight bits is called a byte. It is the next larger unit of data representation within a
computer system. With one byte, the computer can represent up to 256 different values because it
is possible to count from 0 to 255 with eight binary digits. A byte is a basic unit because it can be
adequately used to represent any character on the keyboard, including all the letters (uppercase
and lowercase), number, punctuation marks, and other symbols.
Kilobyte
A kilobyte abbreviated K or KB represents approximately 1000 bytes (or characters). The actual
value of I Kilobyte is 1024 (210) bytes
Megabyte:
A megabyte abbreviated M or MB and sometimes called meg is used to refer to about 1 million
bytes of data.
Gigabytes:
A gigabyte, G or GB, often pronounced gig-a-bite, is used to refer to about 1 billion bytes of
data.
Terabyte:
A terabyte, T or TB, is used to refer to about 1 trillion bytes or 1000 gigabytes of data.
Petabyte:
This is a new measurement which accommodates the substantial storage capacities of the modern
database- It is used to refer to about 1 million gigabyte data
32
4.0 Conclusion
Computers require the hardware components and software to process data. Computer hardware
consists of input devices, central processing units, memory, and output devices. A bit is the
smallest possible unit of data. More considerable amounts of data are measured in Bytes,
Kilobyte, Megabyte, etc.
5.0 Summary
This unit has provided you with adequate information on the different hardware components. This
unit also discussed in details some major computer hardware components. The units of measuring
the memory capacity of computers are also covered.
Introduction to Computers and Information Technology, 2nd edition, Pearson, 2015, ISBN-13:
9781323237120
33
MODULE 1
UNIT 3: BASIC SOFTWARE FOR DATA PROCESSING
Table of Contents
1.0 Introduction
2.0 Objectives
3.1 Software systems
3.1.1 Systems Software
3.1.2 Application Software
3.2 Software for Data Processing
4.0 Conclusion
5.0 Summary
6.0 Tutor Marked Assignment
7.0 References/Further Readings
1.0 Introduction
Apart from the hardware of a computer discussed in Unit 2, a computer system requires
software to make the best use of its capability in solving problems. Computers do not have the
intelligence of their own; they rely on the instructions and data supplied by a user to perform a
task. These instructions are called software. The software consists of a group of related
programs written in a specific code called programming language. The software can be
purchased as Commercial, off-the-shelf (COTS), or developed in house for data processing
purposes. Software purchased to perform general business functions is often referred to as a
software package.
2.0 Objectives
At the end of this unit, the student should be able to:
• System software
• Application Software
34
keyboard, the screen, the printer, and the disk drive. However, it does not solve specific
problems relating to a business or a profession as application software. Some examples of
system software are operating systems and Language translators
System software is sets of one or more programs designed to control and supervise the
operation and performance of a computer system. They are the software that acts as interface
between the hardware and the user or computer resources. The overall control of the hardware
operations and the user self-written programs is done by the system software.
The systems software may be divided into the following:
(i) Operating systems
(ii) Utilities and service programs
(iii) Translators
(iv) Database Management System
(i) Operating System
Operating System is a software that manages the resources of the computer. The workings of
all hardware components as well as execution of application programs are controlled by the
operating systems (OS). Those programs are concerned with the internal control and co-
ordination of all aspects of the computer system. An operating system is essential software for
a computer. It is made up of many component programs and manages the overall operations of
a computer system. Some of the tasks performed by the operating system are:
• It controls various input and output devices and coordinates input and output
operations.
• It manages the systems resources such as available memory space in the primary
and secondary storage devices.
• It allocates memory and processor time to programs.
• It validates users and ensures that the resources a user is requesting are made
available
Some popular operating systems are Windows, Operating System 2, Macintosh Operating
System, Novell Netware, UNIX, and Linux.
(ii) Utilities and service programs: are used for general housekeeping on the computer. They are
system programs that provides useful service to the user of the computer by providing facilities
for performing common tasks in a routine nature. These tasks are: Formatting a disk, copying
of files, sorting, printing, editing, back-up etc. These services include translators for any
languages supported by the system and utility programs such as program editors and other aids
to programming. These are programs that are often required by many application programs.
Examples include programs for formatting or defragmenting a disk. Also, we have the
sort/merge utilities which are used for sorting and merging large volumes of data.
35
Application software includes programs that are developed using systems software to achieve
some tasks. There are two types of application software: application programs that you
purchase for solving particular classes of problems and application programs that you write to
solve your problems. Some commercially available end-user programs (application software)
which are developed by professional programmer teams can be used with little or no
additional programming skills. Examples of application software include word processing and
desktop publishing software; spreadsheet; database programs; graphics programs;
communication software; and special-purpose programs suitable for accounting, scientific and
engineering application, education, and entertainment and so on.
Application software or program is a computer program designed to help users perform a certain
kind of activity. Depending on the task(s) for which it was designed, an application program can
manipulate text, numbers, graphics or a combination of these elements.
36
Traditionally, the spreadsheet was simply a grid of rows and columns on special paper that
was used by the accountant and others to produce financial projections and reports. Electronic
spreadsheets application allows users to enter data in rows and column, calculate means
perform statistical analyses, create tables, and make other financial schedules. Spreadsheet
software also has features that allow the creation of analytical graphics. When viewed on a
monitor or printed out, analytical pictures, or business graphics, help make data and the
generated report easily to comprehend and analyzed for decision making by management.
Electronic spreadsheets have features that allow charts and graphs to be created from a table of
numbers to show the significance of a selection of data, which can be displayed in several
ways: bar graphs, line graphs, and pie charts, etc. A spreadsheet document is called a
worksheet. Some commonly used Spreadsheet software are VisiCalc, Lotus 1-2-3, and
Microsoft Excel, etc.
37
Figure 11: Oracle Database Management Platform
4.0 Conclusion
38
The data processing requirements of an organization is a significant factor in determining
which software to acquire or use. Software development could be one of the functions of a
data processing department.
5.0 Summary
In a data processing center, different computer hardware and software are usually
required for the manipulation of data. Some of the commonly used software are a word
processor, database, presentation graphic, spreadsheets, operating system, etc.
Introduction to Computers and Information Technology, 2nd edition, Pearson, 2015, ISBN-
13: 9781323237120
39
MODULE 1
UNIT 4: DATA CAPTURING AND REPORTING DEVICES
Table of Contents
1.0 Introduction
2.0 Objectives
3.1 Input Devices
3.1.1 Keyboard
3.1.2 Pointing Devices
3.1.3 Pen-Based Devices
3.1.4 Source-Data Entry
3.2 Other input devices
3.3 Output Devices
4.0 Conclusion
5.0 Summary
6.0 Tutor Marked Assignments
7.0 References/Further Readings
1.0 Introduction
Computers interact with their external environment and users via the Input / Output devices.
Inputs are the signals or data sent to the system, and outputs are the signals or results received
from the design to the outside. Input devices are hardware equipment by which a computer
system receives data, while output devices are hardware equipment by which outputs are
communicated to the outside world.
2.0 Objectives
At the end of this unit, the student should be able to:
• Identify and describe data capturing devices
• Identify and describe data reporting/output device
3.1.1 Keyboard
The keyboard is used for entering text and numeric values into the computer. It is the most
popular means of data entry in microcomputers. The keyboard may look like a typewriter but
with some special keys added. The keyboard has facilities for converting letters, numbers, and
other characters into electrical signals that are machine-readable the processor of computers.
Data entry functionality is also available via keys on a bank's automatic teller machine or the
keypad of a personal digital assistant or a cell phone.
40
Figure 13: Keyboard
a.) Mouse
A mouse is an input device that is popularly used with microcomputers. When used with
desktop computers, it is rolled about on a desktop to direct a pointer and select commands on a
computer display screen. The point-and-click actions of the computer mouse are fast, making
it an alternative to the keyboard and text-based commands since most of the commands
executed with a keyboard can almost be done with a mouse. Besides, the mouse can be used to
draw images on the screen.
b.) Trackball
This is a variant of the mouse. It can be moved on a stationary device that is rotated with the
fingers or palm. The trackball is commonly used with handheld devices.
41
Figure 15: A trackball
c.) Touchpad
Touchpads allow a user to control the cursor/point on the computer display screen with his
fingers. It is about the same size as a mouse but is usually rectangular and flat devices that are
used in the very weak electrical field to be activated.
d.) Joysticks
A joystick is a pointing device that consists of a vertical handle like a gearshift lever
mounted on a base with one or two buttons. Joysticks are used principally in video games, in
some computer-aided design systems, and computerized robot systems.
42
Figure 17: Touchpad
Scanning Devices
Scanners use laser beams and reflected light to capture and translate hardcopy images of text,
drawings, photos, and the like into computer understandable form for processing. Scanning
devices include Mark and character recognition devices, Fax machines, and imaging systems.
Specifically, the Mark and character recognition devices are usually referred to by their
abbreviation OCR, OMR, and MICR,
43
(a) Optical mark recognition
Optical mark recognition (OMR) uses a device that reads pencil marks and converts them into
computer-understandable form. This technology is widely accepted by many examination
bodies such as Joint Admission and Matriculation Board (JAMB), West African Examination
Council (WAEC), NECO (National Examination Council Organization), and other Scholastic
Examination bodies across the world as a convenient way of processing their candidates’
results.
Sensors are devices that collect data directly from the environment for input into a computer
system. For instance, atmospheric data can be captured and transmitted via sensor network to a
data processing center for weather forecasting.
(a) Voice input
These devices convert spoken words into computer understandable digital form for processing.
When voice recognition systems are used to capture data for processing, the user documents
can be created by speaking words into a computer rather than keying them in. The system will
have audio facilities such as sound card, microphone, and speakers.
The physical component or materials in which data is stored are called storage media. The
hardware components that write data to, and read it from, storage media are called storage
devices. For example, a diskette is a storage medium, whereas a diskette drive is a storage
device. Storage media and derives have evolved dramatically since computers were in their
infancy, and this pace has accelerated since the introduction and growing popularity of PCs.
44
computer to the outside world. Some standard output devices include Visual display unit A
visual display unit (also called VDU, monitor, or screen), Printers and Plotters.
(a) Monitors
The first is the typical monitor that looks like the television screen and uses a large vacuum
tube called a cathode ray tube (CRT). Its operation is very similar to that of a television picture
tube, with an electronic gun shooting a beam of electrons to illuminate the pixels (picture
elements) on the screen. The number of pixel per screen determines the resolution. The
resolution of a monitor indicates how densely the pixels are packed. The second type, known
as the flat-panel display, is used with laptops or notebook computers. While the earlier
monitors could only display one color, that is, black, grayscale, etc. modern monitors have
good support for color and graphics show though this may require more memory.
(b) Projector
A projector or image projector is an optical device that projects an image (or moving images)
onto a surface, commonly a projection screen. The images created from most projectors
happen by shining a light through a small transparent lens, but some newer types of projectors
can project the image directly, by using lasers. A virtual retinal display, or retinal projector, is
a projector that displays an image directly on the retina instead of an external screen. A video
projector is the most common type. Video projectors are digital replacements for earlier types
of projectors such as slide projectors and overhead projectors.
(c) Printers
The printer is a device that prints text or illustration on paper and, in many cases, on
transparencies and other media. They are the most popular output devices besides monitors.
The speed of early printers was measured in units of characters per second, while that of
modern printers is measured in pages per minute. There are different types of printers based on
the technology they use. We shall only describe a few that you will find in a data processing
center:
This works by spraying ionized ink at a sheet of paper. Magnetized plates in the ink s path
direct the ink onto the paper in the desired shapes. They are popular with portable printers
because they could exist in small sizes. Ink-jet printers require a particular type of ink that
may smudge on low-cost copier paper. They provide an economical way of the way to print
full-color documents.
45
The laser printer utilizes a laser beam to produce an image on a drum. The light of the laser
alters the electrical signal on the drum wherever it makes a hit. The drum is made to roll
through a reservoir of toner, which is picked up by the charged portion of the drum. After this,
the toner is transferred to the paper through a combination of heat and pressure. LaserJet
printer produces very high-quality output. This is as a result of the resolution, that is, how
many dots per inch (dpi) they lay down. The available resolutions range from 300 dpi at the
low end to 1,200 dpi at the high end. The color laser printers can produce colored outputs
though they are usually more expensive because of the addition toners required. Laser printers
are non-impact printers; they are not as noisy as dot-matrix or line printers. They are relatively
fast, although not as fast as some dot-matrix printers. Their speed ranges from 4 to 20 pages of
text.
(d) Plotter
A Plotter, though mainly used for engineering applications, uses the drawn pictures or
lines on paper based on commands from a computer. The can produce continuous lines,
whereas printers can only simulate lines by printing a closely spaced series of dots. Plotters are
not as fast as printers but are useful introducing a large-size chart, maps, or drawings even in
color.
(e) Speaker
A voice output device such as a speaker converts digital output data back into intelligible
speech. They are used to deliver audio output from animation, multimedia applications from
the web, and music to the user.
4.0 Conclusion
The communication of Input/Output refers to the communication between a data processing
system such as a computer, and the outside world. Users interact majorly with computer
systems through input and output devices.
5.0 Summary
This unit covers a wide range of devices that can be used for capturing data. The choice of
input device will depend on the type of source. For example, in capturing bank transaction
data from a cheque, a MICR device will be most suitable. Also, we covered various output
devices, such as printers, plotters, and speakers.
Q1. List the input and output devices you would expect to see in an examination processing
IT center?
Q2. List three (3) input devices and two (2) output devices that are nbe needed for data
processing in a supermarket.
Q3 Why does mouse generally preferable to Joystick?
46
MODULE 2
UNIT 1: DATA STORAGE DEVICES
Table of Contents
1.0 Introduction
2.0 Objectives
3.1 Diskette
3.2 Hard disks
3.3 Removable hard disks
3.4 Magnetic tape
3.5 Optical Storage
3.6 Accessing Data from Disk
3.7 Disk Performance
4.0 Conclusion
5.0 Summary
6.0 Tutor Marked Assignment
7.0 References/Further Readings
1.0 Introduction
The computer primary memory is limited in the amount of information it can store at a time. In
addition, the content of the RAM is temporary i.e., once the power of the computer is turned off,
all the data and program within it simply vanishes. This is why data must be stored on
secondary storage devices which are able to hold data and programs on a more permanent basis.
External storage devices consist of large-capacity, slow-access data storage attached to a digital
computer and used to store information that exceeds the capacity of main storage. Two main
technologies are used to store data today: magnetic and optical storage. Although devices that
store data typically employ one or the other, some combine both technologies. The primary
types of magnetic storage are:
2.0 Objectives
The objectives of the unit are to:
3.1 Diskette
A Diskette or floppy disk is a data storage medium that is composed of a disk of thin, flexible
magnetic storage medium encased in a square or rectangular piece of mylar plastic. Floppy
disks are read and written by a floppy disk drive or FDD, the initials of which should not be
confused with "fixed disk drive," which is another term for a hard disk drive. Floppy disk exists
in the following sizes; 8-inch (200 mm), 5¼-inch (133 mm), and the most common 3½-inch (90
mm). Though floppy disks are still used in some data processing environment, they are now
superseded mainly by flash and optical storage devices. At the same time, some users consider
emails as a convenient way of exchanging small to medium size digital files. Floppy optical
drives combine magnetic and optical technologies to store about 21MB of data on a media
similar to 3½-inch floppy disks. The name is a portmanteau of the words 'floppy' and 'optical.'
This device was introduced in 1989 by Insite Peripherals of San Jose but did not become
popular because of the limited storage capacity it offers. Similar technology was used in the
Laser Servo-120 drive introduced in 1996 with 120MB capacity.
47
Figure 18: Floppy Disk
48
market share of tape storage devices.
49
When a program reads a byte from the disk, the operating system locates the surface, track, and
sector containing that byte, and reads the entire sector into a particular area in main memory
called buffer. The bottleneck of disk access is moving the read/write arm. So it makes sense to
store a file in tracks that are below/above each other on different surfaces rather than in several
tracks on the same surface.
Cylinder
A cylinder is the set of tracks at a given radius of a disk pack. i.e. a cylinder is the set of tracks
that can be accessed without moving the disk arm. All the information on a cylinder can be
accessed without moving the read/write arm.
In measuring the performance of a storage device, we may consider the following three
parameters.
Min latency = 0
Max latency = Time for one disk revolution
Average latency (r) = (min + max) / 2
= max / 2
= time for ½ disk revolution
Typically, 68 ms average.
(b) Throughput
This is the rate at which information can be read from or written to the storage. It is expressed in
terms of megabytes per second or MB/s. A media accessed sequentially, as opposed to
randomly, typically yield maximum throughput.
50
Figure 23: A Flash
4.0 Conclusion
Computer data storage, often called storage or memory, refers to computer components, devices,
and recording media that retain digital data used for data processing. Secondary storage differs
from primary storage in that it is not directly accessible by the Central processing unit.
Secondary storage does not lose the data when power suddenly goes down i.e. it is non-volatile.
Secondary storage is not as expensive as primary storage consequently, a higher magnitude of
data are stored in secondary storage than primary storage in data processing centers.
5.0 Summary
This unit covered computer data storage devices and their performance
measurement.
The knowledge acquired will be useful in the following units.
51
Q3. Highlight and write short note on 8 kinds of storage devices.
ITL Education Solutions Limited, Introduction to Information Technology, 2nd Edition, Pearson
Education India, 2012, ISBN: 9789332525146
Computer Service and Repair Fifth Edition, Revised, Lab Manualby Richard M. Roberts (Author),
Dr. Adam Beatty.
52
MODULE 2
UNIT 2: FILE ORGANIZATION
1.0 Introduction
2.0 Objectives
3.1 What is a Computer file?
3.2 File Organization
3.3 Classification of Storage Devices
3.4 Types of data files
4.0 Conclusion
5.0 Summary
6.0 Tutor Marked Assignment
7.0 References/Further Readings
1.0 Introduction
It is not enough to acquire excellent computer system; hardware and software. Files within the
system must be well maintained, managed and organized. Good file organization leads to
productivity. When files are well arranged and maintained, users can easily access and retrieve
the information they need in good time. Different ways of file organization are: Serial File
Organization, Serial File Organization, Sequential File Organization, Indexed Sequential
Organization, Direct or Random File Organization.
2.0 Objectives
At the end of this unit, the student should be able to:
• Explain the meaning of a computer file
• Identify and describe file organization techniques
• Describe the type of data files used in a Data Processing Environment
53
These are files that store sets of instructions written in a programming language. A source program file,
for example, contains the instructions written in a high-level language such as BASIC or FORTRAN
programming language by a programmer. In contrast, the object file is the translated form of the source
file in machine code after. The files that contain the machine code are called executable files (or binary
files)
This is a file that is used to store digitized sound or digitized video images and animation.
This refers to document files, contain data, not programs. Their contents are using application software.
In this method of the file, organization records are not arranged in any specific order. If magnetic tapes
are used to store data, it would be necessary to wind the tape forward and backward to access a given
record since access can only be made in the sequence in which the records were physically stored on the
tape, i.e., serially. Moreover, if records are stored on disk, a full index will be required to access any
given record. This method of file organization is, therefore, inefficient.
54
(c) Indexed Sequential Organization
This technique of file organization uses both the sequential and direct access methods. It is widely
applied to the storage of records on the magnetic disk. It allows the sequential file to be manipulated
serially as the record is stored in ascending order of key field. Also, it will enable direct access to storage
devices to be accessed directly using the indexed sequential access method (ISAM). This access method
relies on an index or key fields to locate individual records. An index to a file is similar to how a book
can be used to find its physical position //on a library shelf. The method requires that data are stored in a
magnetic or optical disk. For example, a university could index specific ranges of students’ matriculation
numbers from 0000 to 1000, 1001 to 2000, and so on. For the computer to find the record with the key
field 8888, it would go first to the index, which would give the location of the range in which the key
field appears (for example, 8001 to 9000). The computer would then search sequentially (from 8001) to
find area 8888
Storage devices can be classified generally as sequential access or random access. For example, a tape
drive is a sequential-access device because to get to record five (5) on the tape, and the drive needs to
pass through points 1, 2, 3, and 4. A disk drive, on the other hand, is a random-access device because it
allows the record at any position on the disk to be accessed without passing through all intervening
positions
Data stored in a data processing center could be considered as a transaction file and master file.
55
This refers to a collection of transaction records. The transaction file is a temporary holding file that
stores records that generally have a limited useful lifetime. For an employee file for payroll processing, a
transaction file would hold, the name, contact information, hour worked, pay rate, tax, utility bills, etc.
for staff for a particular month. At the end of every month or so, there will be a need to compute the
staff's salaries from the information in the transaction file. After the transactions are successfully carried
out, the transaction file's information will be used to update the master file. In a data processing system,
transaction records may be retained online for some period and later achieved on permanent storage
devices. Transaction files can serve as audit trails and history for the organization.
In addition, the master file of a payroll system may be composed of discrete pieces of information (such
as a name, address, or employee number, called data elements. Data are keyed into the system, updating
the data elements periodically. The master file features are combined in different ways to make up
periodic reports of interest to management and government agencies or to generate paychecks sent to the
staff at the end of the month. Other examples of master files include Customer, Product, Result, or
Supplier file.
4.0 Conclusion
An effective data processing system is that one provides users with timely, accurate, and relevant
information. The type and size of devices used for data storage determine how fast information can be
retrieved. Two types of data files are described: Transaction and master file -The data in transaction files
are regularly used for generating information, while data that require periodic updates are moved to the
master file.
5.0 Summary
In this unit, we explained the meaning of a computer file, described the different types of file
organization, and explain the importance of the terms, transaction, and master file. These details are vital
for the comprehension of the contents in the subsequent units.
Introduction to Computers and Information Technology, 2nd edition, Pearson, 2015, ISBN-13:
9781323237120
56
MODULE 2
UNIT 3: DATA PROCESSING TECHNIQUES
Table of Contents
1.0 Introduction
2.0 Objectives
3.1 Meaning of Data Communication
3.2 Batch Processing
3.3 Online processing
3.4 Transaction Processing:
3.5 Real-time Systems
3.6 Distributed Processing
4.0 Conclusion
5.0 Summary
6.0 Tutor Marked Assignment
7.0 References/Further Readings
1.0 Introduction
The processing of data need not be restricted to a particular environment. Data processed in remote
locations can be accessed via telecommunications infrastructure. Different kinds of processing
techniques are made possible by telecommunications. The methods are discussed in this unit.
2.0 Objectives
Data communication refers to the process of transmitting data/information from a source via a
telecommunications system in coded forms to a destination to interchange details of the business
transactions. The transfer of data requires some forms of electromagnetic energy such as electricity,
light, radio, or waves transmitted through a physical medium such as the atmosphere, cable, or wire. A
telecommunication system refers to a collection of compatible hardware and software required to
exchange information from one location to another. A telecommunication system can transmit text,
graphic images, voice, or video information. The major components of a telecommunication system are:
• Terminals: These are any input/output device that sends or receive data
• Communication channel: This is the link by which data, graphic images, voice, or video are transmitted
between sending and receiving devices in a network. Communication channels use various
communications media, such as telephone lines, cable, coaxial cable, fiber-optics and wireless
transmission
57
• Communications software: This controls input and output activities and manages other functions of the
communication network
Another example is a banking system where accounts' reconciliation is done only after the close of day
operations, and the entire transactions are processed as a batch. Any queries performed before the batch
is processed will certainly not be accurate. However, many banks in Nigeria have begun to integrate
real-time modules into their application.
58
3.3 Online processing
This is a method of data processing method whereby data about a single transaction is processed
immediately. It is captured. This processing method allows transactions to be entered directly to the
system via terminals, PCs, or workstations as they occur, thereby updating the master file immediately
as the transactions occur. The point of entry may be remote from the location at which the update his
made. For example, when you withdraw cash from an automated teller machine, your withdrawal is
instantly processed, and your account balance is updated. Other online processing systems include:
• Visa processing
• Result checking
• Application processing
• Examination
Because of the prevalence of PC in data processing, we rarely hear the term online processing. The term
client/server computing is more prevalent where the PC is the client.
Many organizations that were used to centralized systems for data processing can now adopt Distributed
data processing because of advances in computing technologies. A centralized system consists of a
central multi-user computer (usually mainframe) that hosts a data processing system. The users interact
with this host via terminals or PCs serving as a client, but virtually all of the actual processing and work
is done on the host computer. All the devices in the centralized system such as PCs, terminals, network
devices, and printer converge on one central computer, even though the users may work from remote
locations via terminals. All processing and storage take place in the central area.
59
On the other hand, a distributed system allows the components of the data processing system to be made
available at multiple locations in a computer network, which means that the processing workload
required for supporting the elements is also distributed across multiple computers on the network.
Besides, the computers, storage devices, and even some computer personnel may need to be distributed
to separate locations throughout the organization for the system's efficiency. Distributed data processing
allows data processing and storage to occur at several locations in the computer system. There are
advantages and disadvantages associated with adopting distributed data processing in an organization.
Moreover, these are as follow:
• Modularity
• Easy Integration
• Better response time
• Data processing is closer to the end-user.
• Ability to share data
• Greater reliability
• Local control of data
• Lower cost
• Direct Users interaction
4.0 Conclusion
Some of the processing techniques studied in this unit are closely related but with a little meaning. For
example, an on-line system needs not to be a real-time system, but a real-time system must be an online
system.
5.0 Summary
An essential feature in modern organizations is the need for users to access and use data from different
computers. Timely availability of information enhances decision making. In this unit, we studied central
data processing techniques.
Dusan Petkovic, Microsoft SQL Server 2016: A Beginner's Guide, Sixth Edition, 6th Edition, McGraw-
Hill 2016, ISBN: 9781259641800
Networking for Beginners: Easy Guide to Learn Basic/Advanced Computer Network, Hardware,
Wireless, and Cabling. LTE, Internet and Cyber Security Paperback – November 28, 2019
60
MODULE 2
UNIT 4: TRADITIONAL FILE SYSTEM PROCESSING
Table of Contents
1.0 Introduction
2.0 Objectives
3.1 Traditional File Systems / Processing
3.2 Problem with the Traditional File Environment
4.0 Conclusion
5.0 Summary
6.0 Tutor Marked Assignment
7.0 References/Further Readings
1.0 Introduction
File systems were an early attempt to computerize the manual systems prevalent in the early days of data
processing. The manual system works well while there are not many items, but it breaks down when we
have many items, and we want to cross-reference them. So the file-based system was a response to
industry needs for more efficient data access. However, rather than have everything centralized, each
department would have its own set of files. File system, which is also referred to as a traditional file
processing approach, is inadequate for many organizations because it involves creating, organizing,
storing, manipulating, and maintaining records within an organization that leads to each functional area
or department creating and maintaining its data files and programs.
2.0 Objectives
As an organization grows, computer systems and applications become more complex. For example, a
University s computer system that handles student s information if the data of students is to be kept
independently by the units that each student interacts with, for example, Registration, Hostel, Accounts,
Examination, and Records, Students Affairs, Health Centre, etc. Worse still, each department is allowed
to keep students' information independently in their application. A time comes when multiple files
containing the same records of students will exist in the different units.
61
Figure 26: A File System
Figure 26 shows two departments: registration and exams and records with each department having its
own set of files and programs written for them. As this process goes on for more than five years,
depending on the number of students’ enrollment, the university is saddled with hundreds of programs
and applications without adequate control of the data. The University will be collecting the same
information in more than one file. Some of the resulting problems are data redundancy, lack of data
integrity, and lack of program-data dependence, inflexibility, and inability to share data.
62
(c) Difficulty of Data-Sharing
It is difficult to share data in a file environment because it may be challenging to relate the data in one
file with that of another within one or several departments were files are kept. Besides, there is no
control over the access to data, which makes it difficult to retrieve the desired information.
4.0 Conclusion
The file systems lead to a situation where an organization collects the same information in far too many
files. Some of the resulting problems are Data Dependence, Program-Data Dependence, and Difficulty
of Data-Sharing amongst several others.
5.0 Summary
In a data processing center, there is a need to plan for the data will be managed from the onset. Most
organizations began information processing on a small scale, automating one application at a time until
there is no more control over the data. Understanding the problems of file-based systems may prevent us
from repeating these problems.
Traditional file-based systems are the predecessor of database systems. We shall discuss
the database systems in the next unit.
63
MODULE 3
UNIT 1: DATABASE PROCESSING
Table of Contents
1.0 Introduction
2.0 Objectives
3.1 Database Management System
3.2 Components of a Database Management System
3.3 Database Model
3.4. Demerits of DBMS
4.0 Conclusion
5.0 Summary
6.0 Tutor Marked Assignment
7.0 References/Further Readings
1.0 Introduction
The database technology is an answer to the traditional file system. It helps to solve many of the
problems associated with the traditional file organization. A database is a collection of more than one
related files which are usually integrated. A database can also be seen as a collection of data organized to
serve many applications efficiently by centralizing the data and minimizing redundant data. So, instead
of storing data in separate files for each application, data are stored physically to appear to users as if
they are stored in only one location. In this way, a single database would be made to service multiple
applications. Database technology has a lot to offer in managing an organization s data though not
without some demerits.
2.0 Objectives
At the end of this unit, the student should be able to:
Let take the student information system; instead of storing data in a separate system and separate files
for medical, hostel, finance, exams and records, registration, the university would only need to create a
database. In the figure below, a single database is created to process students' results and the handling of
registration information.
64
Figure 27: A Database Management System
When the application programs call for a data item such as Matric no, the DBMS finds the item
in the database and presents, it sends the information to the application program. With the data files, the
programmer would need to provide adequate information in the program of a database on how the
computer would locate a data item that has already been defined. With a DBMS, most of the data
definition statements found in traditional programs would not be necessary. DMBS makes it possible to
do many routine tasks. DMBS provides a convenient interface to create and maintain a database and
enable individual business applications to extract the data they need without having to create separate
files or data definitions in their computer programs. Examples of common DBMSs include: Oracle,
DB2, Sybase Adaptive Server Enterprise, Data was, FileMaker, Firebird, Ingress, Informix, Microsoft
Access, Microsoft SQL Server, Microsoft Visual FoxPro, MySQL, PostgreSQL, Progress, SQLite.
(b) A data manipulation language is a language associated with a database management system
employed by end-users and programmers to manipulate data in the database. Most DBMS has a
specialized language called a data manipulation language used in conjunction with some conventional
third or fourth-generation programming language to manipulate the data in the database. The language
contains commands that permit end users and programming specialists to extract data from the database
to satisfy information requests and develop applications. The most prominent data manipulation
65
language today is Structured Query Language or SQL. Complex programming tasks cannot be
performed efficiently with specific data manipulation language. Most mainframe DBMS are compatible
with COBOL, FORTRAN, and other modern programming languages, permitting greater processing
efficiency and flexibility.
(c) Data dictionary: This is an automated or manual file that stores definitions of data elements and data
characteristics such as usage, physical representation, ownership (who is responsible for maintaining the
data authorization, and security. It is the third element of a DBMS. Many data dictionaries can produce
lists and reports of data utilization, groupings, program location, etc.
66
Table 6: A Relational Database
Fields
Matric_No Name Department Level
Records NOU050010456 Sonekan Tunde Accounting 400
NOU050010457 Daramola Kemi Mathematics 400
NOU050010459 Akinlabi Oluwafemi Economics 400
In a hierarchical database, records are organized in a treelike structure by type. The relationship between
records types is said to be a parent-child relationship, in which any child type relates only to a single
parent type. A record is subdivided into segments that are connected in a one-to-many parent-child
relationship. The most common hierarchical DMBS is IBM S IMS (Information Management System).
67
Figure 30: Network Database
68
• Avoids duplicate data
• Increased access and availability of data and information
• Logical & Physical data independence Control of data redundancy
• Data consistency
• Sharing of data
• Improved data integrity
• Improved maintenance through data independence.
• Minimal data redundancy
• Integration of data
• Improved integrity
• Consistent security
• Increased productivity
The following are the problems associated with Database Management Systems
• Complexity
• Cost of DBMS
• Cost of conversion
• Higher impact of a failure
• Additional Hardware Costs
• Take a long time to design and implement
• Performance
• Experts -Specialized Personnel
• Potential organizational Conflict
4.0 Conclusion
In an ideal database management system, the data in the database are defined only once and used for all
data processing applications whose data reside in the database, thereby eliminating data redundancy and
inconsistency. As data processing applications request data elements from the database, the data
elements called for by the application are found and delivered by the DBMS. This enhances both the
productivity of the application developer and the end-user.
5.0 Summary
The use of a suitable Database Management System for data processing can reduce program-data
dependence along with program development and maintenance costs. Access and availability of
information can be increased because users and programmers can perform impromptu queries of data in
the database. However, the use of DBMS may lead to additional hardware costs, a higher impact on
failure, and some complexities among other demerits.
Q1. What do you consider as the significant differences between hierarchical database and network
database?
Q2. Highlight 10 merits of DBMS
Q3. Highlight 5 demerits of DBMS
69
MODULE 3
UNIT 2: DATA P ROCESSING PERSONNEL
Table of Contents
1.0 Introduction
2.0 Objectives
3.1 Data Processing Manager
3.2 Systems Analyst
3.3 Computer Programmers
3.4 Operation Manager
3.5 Database Administrator
4.0 Conclusion
5.0 Summary
6.0 Tutor Marked Assignment
7.0 References/Further Readings
1.0 Introduction
The categories and number of staff found in a data processing center will largely depend on the
organization's size and the volume of work handled by the department. In any typical data processing
center, the following categories of staff will be found performing various duties:
Objectives
At the end of this unit, you should be able to:
· Liaises with the user departments to ensure their requirements and problem are fully captured before
systems design and implementation occur.
70
· Interprets terms of reference before embarking upon systems projects
· Studies the feasibility report before embarking on a systems development project
· Supervises, Organizes and coordinates the activities of subordinate staff
· Reviewing Performance of subordinates for appropriate recommendations to the Data processing
manager
· Organizes and reviews systems documentations to ensure its compliance with data processing
standards
· Studies, reviews and report progress on projects to the data processing manager
· Coordinates the development and implementation of alternative systems
· Reviewing performance of implemented systems and assessing the need for amendments or additional
training of staff
· Discusses project proposal with subordinates such as the chief programmer
• Liaise with system analyst to determine the philosophy of proposed systems and establish the type of
programming language to use a high level or assembly code
• Reviews systems specification to establish the details of system requirements before actual
implementation(coding)
• Converts systems specification and design documents to actual products
• Develops, implements and maintains computer software
• Deploys and configures software in the specified environments
• Handles integration and interoperability associated issues
• Develops user-friendly software
• Chooses test cases and monitor test runs
• Reviews the performances of subordinates
• Reports status of program development to systems analyst
• Controls all operations activities such as data preparation, capture, and control, processing of data,
report generation, storing of data, preservation of backup devices, etc.
• Develops the operating schedule for all jobs to be run on the computer
• Ensures that data is received on time from the user’s department
• Maintains records on equipment utilizations
• Implements standard procedures to improve the efficiency of operations
• Keeps the inventory of data processing hardware supplies such as tapes, disk, hard drive, Monitors, etc.
• Maintains log of computer operations for audit trails
• Reports to superior when system problems and other operational matters arise
• Implements specific policies and procedures through which data can be managed as an organizational
resource.
• Plans for data usage
• Oversees the logical and physical database design and data dictionary development.
• Formulate information policy that specifies its rules for sharing, disseminating, acquiring,
standardizing, classifying, and inventorying information in an organization
• Specifies rules governing the maintenance, distribution, and use of information in an organization
• Define and organizes database structure and content
71
• Develops security procedure to safeguard the database
• Develops database documentation
• Maintains the database management software
4.0 Conclusion
In modern days, the data processing department may be referred to as the Information Technology
department. Thus, the staff may be known with different nomenclatures, such as Information Analyst for
Systems Analyst, Software Engineer for Programmer, System Support Manager for Operation Manager,
etc.
5.0 Summary
In this unit, the primary duties of data processing personnel were covered. In the next unit, we shall
discuss the tools for creating data processing applications.
John W. Satzinger, Robert B. Jackson, Stephen D. Burd, Systems Analysis and Design in
a Changing World,7th Edition, Cengage Learning, 2016
72
MODULE 3
UNIT 3: TOOLS FOR CREATING DATA PROCESSING APPLICATION
Table of Contents
1.0 Introduction
2.0 Objectives
3.1 Machine languages:
3.2 Assembler Language
3.3 High-Level Language
3.3 Other Tools
3.4 Approaches to Programming
3.5 Limitation of Structured Programming
4.0 Conclusion
5.0 Summary
6.0 Tutor Marked Assignment
7.0 References/Further Readings
1.0 Introduction
No matter the computer infrastructure in place for data processing - a standalone PC, a small peer-to-peer
network, or a wide area network, having the right software is an essential requirement for good
productivity. Depending on the organization, one or more of the following software would be required for
data processing:
Accounting software
Bank management software
retail point-of-sale software
Financial planning software
Legal and medical office Management systems
Medical diagnostic software
Insurance claims processing system
Report Generator Application
Software is developed by using programming languages or other software development tools. The
following section explains how software programs function and describes the processes and tools
developers use to create software.
Programming is a way of communicating with the computer via instructions to perform some tasks.
Though hundreds of computer programming languages are now used, they are broadly classified into
machine languages, assembly languages, and high-level languages.
2.0 Objectives
At the end of this unit, the student should be able to:
73
3.1 Machine language
Machine Languages are the most basic languages for computer systems. Machine languages consist of
strings of numbers defined by hardware design. Each type of CPU has its machine language. Thus
machine language programs vary from computer to computer; that is, they are machine-dependent. For
example, the Intel Pentium and Motorola PowerPC understand different machine languages. The
instructions in Machine language are written in 0 and 1. These binary digits, which correspond to the
computer, is on and off electrical states, clearly are not convenient for people to read, write, or use. Thus
to provide the machine-language instructions to accomplish a simple task such as finding the sum of 2
numbers, the program may look like:
101100101001 1001011111
111011011101 0101001011
100001010010 1010010010
Load A
Add B
Store C
A programmer can write instructions in assembly language more quickly and much more comfortable than
in machine language. Although assembly language gives programmers some level of control, it is still
costly in terms of programmer s time and effort: it is also difficult to read, debug, and learn. Assembly
language is used primarily today in system software. Another drawback is that, like machine language,
assembly language varies from computer to computer. That is, it is machine-dependent. Instructions
written in assembly language require an assembly to be translated into machine-language equivalents.
This language was developed by John Kemeny and Thomas Kurtz at Dartmouth College in mid-1960 as
an easy-to-learn, interactive alternative to FORTRAN, especially for beginning programmers. It was a
74
suitable tool for teaching programming to students. It was the first high-level language to be implemented
on PCs because of its simplicity. This further led to its popularity amongst developers, hobbyists, and
students. Several versions of BASIC language exist today, including Visual BASIC (VB) - the most
popular programming language ever created. We shall deal more extensively on VB later in this course.
The Identification Division is used to provide some documentation on the program's name, what the
program does, and the author (programmer), and perhaps some other helpful comments. The Environment
Division describes the computer on which the program will be compiled and executed. The Data Division
provides information that describes what data will be processed. The actual instructions or commands that
the computer should follow in accomplishing given tasks are written in the Procedure Division COBOL is
machine-independent and can handle many files and records.
The capability of COBOL for file processing makes it suitable for developing data processing
applications. However, the advent of Database Management Systems with Languages that can easily
manipulate them has made COBOL unpopular for data processing.
In this Days of advanced computing technologies. There are new well robust and technical accepted high
level languages. Some of these Programming languages include:
(i) C:- C is especially important for the development of Operating Systems and other foundational
software. Many compilers and interpreters for other languages are written in C. See: C Developer
Resources.
(ii) C++:- C++ is, in many ways, simply a more advanced successor to C; though the situation is a lot
more complicated than that. C++ was developed to add high-level programming paradigms to C,
while retaining the low-level hardware-manipulation capabilities. Many of these additions have
been added to C over the years, and the languages are more like two dialects of a single language.
(iii) C#:- Used as the primary language for .NET programming, and much like C++, it is an
extension of the C programming language with the major addition being object-oriented
capabilities. See C# Resources.
(iv) Lisp:- Lisp is one of the earliest high-level programming languages and is still actively use. It
is a general-purpose language, but is most associated with work in artificial intelligence.
(v) Pascal:-Pascal is a language much loved by programming purists.
75
(vi) Python:- Python is a high-level programming language. It is an interpreted (not compiled)
language, also known as a “scripting language.” It is mostly used as a tool for performing ad hoc
programming tasks such as task automation and data analysis. It has a strong set of tools for
mathematical and scientific computing, and is frequently used by researchers.
(vii) JAVA:- Java is a high-level language designed to be used by the Java Virtual Machine. It has
very few external dependencies, and was intended to be able to run on any physical machine.
It is used a lot in network architecture and also in embedded devices, kiosks, and other in
situ computing applications.
There are a good number of tools that are much users-oriented and allow programmers to develop
applications with fewer commands, although they also require more computing power. These consist of
report generators, query languages, and application generators.
These are also called reports writes. They are programs for end-user which are used to produce reports.
They allow reports to be generated directly to as printout or a screen display. The items to be generated
may be the outcomes of database queries. You can specify the format such as header, footers, column,
heading, etc. in advance. The report generator will produce data in the specified format.
76
(a) Structured Programming
Structured programming was developed in an attempt to overcome the use of GOTO statements in
programming. Structured programming is a technique to make the programming process more
comfortable and more productive. A structured program does not depend on the GOTO statement to
control the logical flow. Instead, it is built from a smaller program called module, or subprograms, which
are, in turn, made up of even smaller modules. The programmer combines the module using the three
basic control structures: sequence, repetition, and selection. Structured Programming evolved in the 1960
and 1970s.
This executes statements in the order in which they appear, with control passing unconditionally from one
statement to the next. The program will execute statement X and proceed to statement Y. See Figure 1.
77
Figure 33: Selection Construct
Software developers have found that using structured programming results in improved efficiency, but
there had been some challenges with building software quickly and correctly. As applications become
larger and more complex, the application's complexity increases, so do the number of persons-years
required to complete the project. One proven approach to handling this increase in complexity is object-
oriented programming. Object-oriented programming allows the reuse of code. Reusing code allows
programs to be built quickly and correctly. OOP builds on and enhances structured programming.
78
be used several times in different applications and by different programmers, thereby leading to improved
software developers' productivity. Examples of OOP languages; Smalltalk, C++, Eiffel, C#, Java, etc.
79
· Polymorphism means to process objects differently based on their data type.
· In other words, it means one method with multiple implementations for a particular class of action. And
which implementation to be used is decided at runtime depending upon the situation (i.e., the data type of
the object)
· This can be implemented by designing a generic interface that provides generic methods for a particular
class of action. There can be multiple classes, which provides the implementation of these generic
methods.
Lets us look at the same example of a car. A car has a gear transmission system. It has four front gears and
one backward gear. When the engine is accelerated, depending upon which gear is engaged, a different
amount of power and movement is delivered to the car. The action is the same applying gear, but based on
the type of gear, the action behaves differently, or you can say that it shows many forms (polymorphism
means many forms). Polymorphism could be static and dynamic both. Method Overloading is static
polymorphism, while Method overriding is dynamic polymorphism.
(v) Overloading, in simple words, means more than one method having the same method name that
behaves differently based on the arguments passed while calling the method. This called static
because which method to be invoked is decided at the time of compilation
(vi) Overriding means a derived class is implementing a method of its superclass. The call to an
overridden method is resolved at runtime, thus called runtime polymorphism. Examples of Object-
oriented programming are a discussed as follows.
(a) JAVA
Java is a general-purpose programming language that is class-based, object-oriented, and designed to have
as few implementation dependencies possible. It is intended to let application developers write once and
run anywhere, meaning that compiled Java code can run on all platforms that support Java without
compiling again. Java applications are typically compiled to bytecode, which can run on any Java virtual
machine (JVM) regardless of the underlying computer architecture. It has a syntax that appears the same
as C and C++, but it has fewer low-level facilities than either. Java was one of the most popular
programming languages in 2019 used according to GitHub, particularly for client-server web applications,
with a reported 9 million developers.
(b) C++
C++ is a general-purpose programming language created by Bjarne Stroustrup as an extension of the C
programming language, or "C with Classes." The language has expanded significantly over time, and
modern C++ now has object-oriented, generic, and functional features and facilities for low-level memory
manipulation. It is almost always implemented as a compiled language. Many vendors provide C++
compilers, including the Free Software Foundation, LLVM, Microsoft, Intel, Oracle, and IBM, so it is
available on many platforms. C++ was designed with a bias toward system programming and embedded,
resource-constrained software and large systems, with performance, efficiency, and flexibility of use as its
design highlights. C++ has also been found useful in many other contexts, with key strengths being
software infrastructure and resource-constrained applications, including desktop applications, video
games, servers (e.g., e-commerce, Web search, or SQL servers), and performance-critical applications
(e.g., telephone switches or space probes).
(c ) C#
C# is a general-purpose programming language with multi-paradigm encompassing strong typing, scoped
lexically, imperative, declarative, functional, generic, object-oriented (class-based), and component-
oriented programming disciplines. It was developed around 2000 by Microsoft as part of its .NET
initiative and later approved as an international standard by Ecma (ECMA-334) in 2002 and ISO
(ISO/IEC 23270) in 2003. Mono is the free and open-source project's name to develop a compiler and
runtime for the language. C# is one of the programming languages designed for the Common Language
Infrastructure (CLI).
80
4.0 Conclusion
A computer program collects instructions or statements (also called codes) carried out by the computer’s
CPU to perform a task. To ensure that the computer and programmers can understand themselves,
standard computer languages such as FORTRAN, COBOL, ADA, etc. are used. Apart from programming
with standard languages, simplified tools such as report generators, query languages, and application
generators are also widely used for software development.
5.0 Summary
Object-oriented software development models a system as a series of reusable objects that combine both
data and procedure. This leads to a reduction in the time and cost of
writing software and also makes maintenance easier.
a) Structured Programming
b) Object-Oriented Programming
81
MODULE 3
UNIT 4: VISUAL AND EVENT PROGRAMMING
Table of Contents
1.0 Introduction
2.0 Objectives
3.1 Visual and Event-Driven Programming
3.2 Visual Basic Development Environment
3.3 Working with control
3.4 Working with Properties, Methods, and Events
3.5 Writing Procedure for Events
3.6 Using Data Types, Constants, and Variables
3.7 Assignment Statements and Assignment Expressions
3.8 Sample Program in VB
4.0 Conclusion
5.0 Summary
6.0 Tutor Marked Assignment
7.0 References/Further Readings
1.0 Introduction
Visual BASIC, developed by Microsoft in the early 1990s, is one of the most popular visual programming
languages. It offers a visual environment for program construction, allowing users to build various
applications components using a drag-and-drop tool, buttons, scroll bars, and menu. It is a very suitable
language for developing user-friendly data processing applications. In this unit, we shall provide an
overview of the language and explain the relevant features /statements that will enable you to develop
useful data processing applications.
2.0 Objectives
At the end of this unit, you should be able to:
• Explain the term visual program and event-driven programming
• Identify the elements in the Visual Basic environment
• Explain the concept of an object, properties, and method
• Define the term data types and explain the terms variable and constants
• Use simple assignment statements and expression
• Describe and use mathematical operators
• Write sample program in Visual Basic
VB is termed an event-driven programming language because, with it, you can write program code that
responds to events that are controlled by the system or users. Examples of the event include:
82
• Opening or Closing a form.
• Moving the mouse over the top of an object such as a text box.
Before we proceed with learning the VB language, we shall define some terms required for us to have a
good understanding of the language.
Object
An object is a thing like a noun in English. Examples include Forms and Controls on forms such as
Buttons, Text boxes, and Icons.
Property
Objects have properties like adjectives in English. Properties describe objects. Examples of properties
include Text, Name, BackColor, Font, and Size.
Method
A method is like a verb in English. It is an action word that objects exhibit. Examples include methods to
Show and Hide Forms and methods to Print Forms.
Event
An event occurs when users take action, such as clicking a button, pressing a key, scrolling, or closing a
Window. Actions of other objects can also trigger events.
Form
A Form is the window and dialog box where you put all the things that people interact with as they use
your program. Forms are the foundations you generally use to build programs. Forms are containers for
Controls.
Controls
Controls are the elements; you place inside a Form, such as Text boxes, Command buttons, and List
boxes. Those things you put on the form are controls, which enable the people who use your program to
do things, such as enter text and click buttons.
The development environment in Visual Basic looks like the environment you have in any other Microsoft
product such as Word, Excel, Powerpoint, MS Access, etc. It allows you to create and test your programs.
The screenshot in Figure 13.1 shows a VB development environment.
83
The Tool Box holds the tools you use to place control on the form. All of the controls that appear See
Figure xx for detail description of the Control. You may have more or different tools in your toolbox,
depending on the edition of Visual Basic you are working with.
84
ii. Move the mouse pointer over your form. Notice that your pointer is now shaped as a
crosshair instead of an arrow. Click (and hold) the mouse button where you want the
control to go.
iii. Drag the mouse down slightly and to the left. As you move the mouse, notice that a box
starts to appear.
iv. When the box is the proper size, let go of the mouse button. The control you selected
now appears on the form.
You can also remove a control by right-clicking it. From the context menu that appears, select
Property Description
Left The position of the left side of a control with respect to its container
Top The position of the top of a control with respect to its container
Height The height value of a control
Width The width value of a control
Name The string value used to refer to a control
A Boolean (True/False) value that determines whether users can manipulate the
Enabled control or not
The Boolean (True/False) value that determines whether users can see control or
Visible not
Methods are blocks of code designed into a control that tells the control how to do things, such as
move to another location on a form. Just as with properties, not all controls have the same methods,
although some common methods do exist, as shown in Table 9.
85
Table 9: Common Methods of Visual Basic Controls
Method Use
Move Changes an object's position in response to a code request
Drag Handles the execution of a drag-and-drop operation by the user
SetFocus Gives focus to the object specified in the method call
ZOrder Determines the order in which multiple objects appear
onscreen
Not all controls in VB have the same events, but some events are shared controls. These are
represented in Table 10.
Writing codes VB is an interesting one. Your major task is event-driven programming. VB codes
are written to handle events as they occur. The codes are contained within a procedure defined as
any block of code that can be called from within your application.
An event procedure is a place in your project where you put the code that will run when an event occurs.
To write an event procedure, you must access the Code window for your object by doing one of the
following:
86
· Selecting the object and choosing Code from the View menu
· Selecting the object's form in the Project Explorer, clicking the View Code button, and choosing the
object from the Code window
Naming a variable
To make your code easy to read and understood your variable names should describe their task
but, to make your code easy to type, they should be short as possible. To enhance the
understanding of code many programmers prefer to use some standard prefixes on their variables
to indicate the type of data of the variable. See Table 11.
87
Variable Declaration
There are many ways to declare a variable in VB. The most common way is to use the
Dim statement. The syntax of the DIM view is:
Constants
There are occasions where data items in a program have values that do not change. Such values
are referred to as constants. In Visual Basic, there are two main types of constant Intrinsic and
Named constant.
Intrinsic Constants
These are built in constants or systems defined constants. They are usually stored as library files
and available for use by the programmer when they are called: Common examples are color
definition constants such as vbRed, vbBlue and Message statements such as vbOKOnly,
vbCritical, vbInformation etc
Named Constant:
These are programmer defined constants.
Const is a reserved word i.e word with a special meaning to the Visual Basic interpreter.
Notice that String values are enclosed in quotation marks while numeric values are not
so retained.
88
3.7 Assignment Statements and Assignment Expressions
It is not enough to just declare variables, and you need to be able to assign data to variables, manipulate
the data, and use the content of the variable. To do this, you must write some code statements. A
statement is a line of code that makes a computer achieves a task. An assignment statement, for
example, is used to assign a value to a variable. The syntax for assignment statement
is as follows:
Variable = expression
Examples:
int Num1 = 5
frm Main.Visible = False
fAvgScore = nTotal / nNumberofPapers
Mathematic Operations
The primary reason for using a computer in data processing is for the processing of numerical data.
Mathematical operations can be used to determine the total deductions or net pay to be paid to an
employee when the payroll is processed. Similarly, customer’s bill, interest due, account balance, and
the total score of students in an examination would need some mathematical operation to be performed
by the computer. Mathematical operators perform mathematical functions. A list of the available
mathematical operator and their corresponding VB operator are provided in Table 12.
Now that we have learnt some basics of VB, we will illustrate with a Sample Program.
Question: Develop an application in VB to calculate the Total and Average scores of students in
Four papers in an Examination
Solution
To develop this application, you need to go through the following steps:
1. Plan and define your user's interface (Create your forms and add the appropriate
controls).
2. Plan and set the properties (Assign names to your objects. See Figure 5)
3. Plan and Write the Basic codes (Write codes to handle the events. Also see
Figure5)
89
Private Sub cmdProcess_Click()
lbltotal.caption = Val(txtPaper1.Text) + Val(txtPaper2.Text) + Val(txtPaper2.Text)+
Val(txtPaper4.Text)
lblavg.Caption = Val(lbltotal.caption) / 4
End Sub
Exercise:
4.0 Conclusion
Visual Basic is one of the most popular visual languages and very easy to learn. However, to be able to
practice some of the topics covered in this unit, you will need to install Visual Basic 6.0 or Visual
Studio.NET Professional edition on your computer.
90
5.0 Summary
This unit covers the Visual Basic Development Environment, and explains the fundamental concepts of
event driven and visual programming. Applications written in Visual Basic are very users friendly. The
concepts learnt in this unit will be very useful in your programming career and the understanding of the
remaining parts of this study material.
Julia Case Bradley, Anita C. Millspaugh, Programming in Visual Basic 6.O, McGraw-Hill Higher
Education, 2002
Jan L. Harrington, SQL Clearly Explained, Morgan Kaumann Publisher, An Imprint of Elsevier Science,
2003, USA
91
MODULE 4
UNIT 1: CONTROL STRUCTURE AND STRING PROCESSING
Table of Contents
1.0 Introduction
2.0 Objectives
3.1 Control Structures/Statement
3.2 Selection
3.3 Iteration
3.4 String Processing
4.0 Conclusion
5.0 Summary
6.0 Tutor Marked Assignment
7.0 References/Further Readings
1.0 Introduction
A piece of Visual BASIC code executes from the first line of code and proceed line by line until the end of the
statement is reached if no control statements are used. Control statements are used to transfer control to a
particular section of the program. They may also be used when a particular segment of a program needs to be
repeated. This unit describes the various control statements and operators that are required in a control structure.
Also, string manipulation is covered in this unit.
2.0 Objectives
• String processing
Control statements are used to introduce some branch or iteration (repetition) into our codes. Controls can be
implemented in our programs by using any of the three fundamental Control Constructs:
Before we consider the various control structure in VB, we shall examine the relational and logical operators.
Relational and logical operators are often used to implement selection and Iteration. Conditional expressions are
formed using relation and logical operators.
92
Relational Operators
Relational operators are used to forming statements that allow values to be compared. Every
relational statement evaluates to True or False. Study Table13.
Table 13: Relational Operators
Symbol Meaning Example Result
= Equal 3=4 False
> Greater Than 3>4 False
< Less Thank 3<4 True
>= Greater than or 3>=3 True
equal to
<= Less than or 2<=2 True
equal to
<> Not equal to 2<>3 True
Logical Operator
In writing your program, you may want to test two or more relations. For example, you
may want to test that the age of a student is more than 15 years, and his examination score
is more significant than 260 before he can be considered for admission into the university.
Logical operators are used to combine the two relations. The VB logical operators are:
Notice that logical expression like relation expression (statement) must always evaluate to True or
False.
The VB expression for the combined relation for the student admission into the university can be
expressed as
intAge > 15 And intScore >260
3.2 Selection
i) If Statement
VB language has two statements for implementing the selection control: if and Case. For many decisions
you may want to execute a statement (or group of the statement) if a particular condition is true. Two
forms of the if statement handles True conditions: The single-line if statement and the multiple-line if
statement. Each uses the if statement to check a condition and execute the corresponding code when the
condition is true. See the examples
93
Single line If
Multi-line If
If a > 10 Then
Label1.Caption = "A is greater than 10"
Label2.Caption = "B is less than 20"
End If
The else statement is used with the If statement to handle false condition.
If and Else
94
The expression in a Case structure is usually a variable or property you wish to test. The constant list is
the value that you want to match; it ma y be numeric or string constant or variable, a range of value, a
relational condition, or a combination of these.
There is no limit to the number of statement that can follow a Case statement.
Example 1
Select Case intExamscore
Case 70 To 100
lblMessage.Caption = A
Case 60 To 69
lblMessage.Caption = B
Case 50 To 59
lblMessage.Caption = C
Case 40 To 49
lblMessage.Caption = D
Case Else
lblMessage.Caption = F
End Select
Example 2
End Select statement defines the end of the Case block. To trap any values not picked up by earlier
cases use the Case Else construct:
Case 12
strMonthName = December
Case Else
MsgBox Cannot be a Month, 12 Month in a year
End Select
The elements used for the constant list may have any of the forms. The following example is used to
test for a string
Example 3
Select Case txt.SchoolName.Text
Case Science_and_Technology
(Code for the school of science and technology)
Case Education
95
(Code for school of Education)
Case Humanities
(Code for school of Humanities)
Case Law
(Code for school of law)
Case Else
(code for others)
End Select
3.3 Iteration
A pretest repetition statement computes a value for the condition expression before entering the loop.
The loop may never be executed if the terminating condition is true the first time it is tested.
A posttest repetition statement first executes the loop body and then computes a value for the condition
expression. If the value satisfies a true condition, the loop body is executed again; otherwise, the repetition
is terminated. The statements in the loop will always be performed at least once.
A DO/Loop terminates based on a condition that you specify. Execution of a DO/Loop continues while
a condition is True or until a condition is True. The DO/loop command is used in two forms:
(Syntax):
Example:
month = 1
Do While month <= 12
month = month + 1
Loop
Do while tests the loop condition at the beginning of the loop. With this type of loop, the statements
inside the loop may never be executed if the condition for running them is not satisfied.
(Syntax):
96
Do
[statements]
Loop [{While | Until} condition]
Example:
intTemp = 0
Do
intTemp = intTemp + 1
Loop While inTemp < 10
Example 1
curTotal = 0
For intConter = 1 To 10
curTotal = curTotal + intCounter
Next intCounter
Example 2
curTotal = 0
For intConter = 10 To 1 step -1
curTotal = curTotal + intCounter
Next intCounter
Note the use of steps in this example to indicate a decrement. When it is not used, an increment is
assumed. as in example 2
97
This is used to extract the leftmost characters of a string up to a specified position. The String
expression may be a string variable, string literal, or text property.
Example
This is used to extract the rightmost characters of a string up to a specified position. The String
expression may be a string variable, string literal, or text property.
Example
This is used to extract the rightmost characters of a string up to a specified position. The String
expression may be a string variable, string literal, or text property.
Example
Example
Len (strCoursetitle). This expression will return the value 15
98
4.0 Conclusion
The ability of computers to process data such as numbers and strings make them very suitable tool for
data processing. For you to be able to practice programming in VB you must have a computer
5.0 Summary
As your lines of codes continue to increase, your certainly would need to execute or repeat the execution
of a section of the codes before proceeding to another. The control statements covered in this unit help
you to accomplish just what you need.
Jan L. Harrington, SQL Clearly Explained, Morgan Kaumann Publisher, An Imprint of Elsevier Science,
2003, USA
99
MODULE 4
UNIT 2: ARRAYS AND PRINTING
Table of Contents
1.0 Introduction
2.0 Objectives
3.1 Working with Arrays
3.2 Declaration of Array
3.3 Looping through the Elements of an Array
3.5 The MsgBox Statement
3.7 Sending Information to the Printer
4.0 Conclusion
5.0 Summary
6.0 Tutor Marked Assignment
7.0 References/Further Readings
1.0 Introduction
We can use arrays to introduce some efficiency to the use of variables names. An arra y is
a series of variables with the same name. Sometimes array are referred to as table, or subscripted
variable. The individual value is referred to as elements, and each element is accessed by its subscript,
which is a position number.
2.0 Objectives
At the end of this unit, you should be able to:
100
[6] Isaac
[7] Ronke
[8] Osarobo
[9] Yobo
When you use a control array, the individual controls are referenced as strStudentName (0),
strStudentName (1), strStudentName (2), etc. Each individual variable is called an element of the
array. The subscript inside the parenthesis is the position of the element within the array. For
example, strStudentname (2) = Musa while strStudentname (7) = Ronke
The dimension of an array may have an empty parenthesis as in the following statement
The array declared above without a specification of its dimension is a dynamic array because the
number of elements ma y change during the execution of the program. A static array is one with a
fixed size. Any attempt to change the size while the program is running would result in an error
message.
To loop through the element of an array you use the For/Next or FOR Each and Next statement. The
For / Next works well to traverse the elements in the array. With the For Each/Next you wouldn’t
need to manipulate the subscript of the array. The general syntax of the For/ Each Next
Statement is:
For Each ElementName In ArrayName
Statements(s) in loop
Next [ElementName]
The statement above allows a Visual Basic program to automaticall y loop through each element of
the array, assign value to ElementName, and makes one pass through the loop. If the array has say,
10 elements, the loop will execute 10 times. ElementName must be declared as type Variant.
Example
101
Printer.Print vnt1Nme
Next vnt1Nme
(statement(s))
When the loop has finished execution depending on the numbers of elements in the array, the
statement(s) following the Next statement will be executed. However, an EXIT For statement may
be used within the loop to exit early.
A one-dimensional array is a one-row collection of variables. In Visual Basic, however, you can
create arrays that have up to 60 dimensions. Usually, two-dimensional arrays will suffice for most
introductory programming projects, and you won’t likely need to work with more than more than
three dimensions.
A two-dimensional array is made up of columns and rows that intersect to form a grid. Each grid cell
has a location defined as ColumnNumber, RowNumber. Notice that each element is defined by the
coordinates of the column position and the row position. For example, the array element intScores (0,
0) is 59 and the element intScores (2,2) is 79.
59 69 56
70 45 78
23 77 79
45 67 56
To define a two dimensional array table, the Dim statement specifies the number of rows and
columns in the array. The row is horizontal and the column is vertical. The following table has four
rows and three columns
Dim|Public|Private ArrayName(SubscriptOfCols, _
SubscriptOfRows) As DataType
In this syntax,
• Dim, Public, and Private are Visual Basic keywords that declare the array and its scope. If you use
Dim, the array is private to the procedure in which it is declared. Public makes the array visible
from anywhere in the program, and Private makes the array visible only to the form or module in
which it is declared. Using Dim within a module automatically makes the array available
anywhere in the program, as if the Public keyword were used.
• ArrayName is the name of the array.
• SubscriptOfCols is the number of the highest column in the array.
• SubscriptOfRows is the number of the highest row in the array.
• DataT ype is any valid Visual Basic data type.
Therefore, to declare the array, you would use this syntax we will have:
102
Whereas you can consider a two-dimensional array to be a rectangle, you can consider a three-
dimensional array to be a rectangular block.
The message box is a simple form that displays a message and at least one command button. You can
display a message, an optional icon, a title bar caption, and command button(s) in a message box
The message string is the message you want to appear in the message box. The button portion is
optional; it determines the command buttons that will display and any icons that will appear. If you
omit the Caption of title bar, the project name will appear in the message box title bar.
E.g
If txtAddress.Text = Then
MsgBox Please Enter your address. , vbOKOnly, Address required Endif
The MsgBox statement works fine for informing users of problems or prompting them to take an
action. If you need to obtain a decision from users, however, you must return a value by using the
MsgBox() function.
When you print using PrintForm all output is sent as a graphics. The Printer.Print is used to set up
output to a printer. When the statement Printer.Print is encountered, you desired output will be added
103
to the Printer object. VB only sends the contents of the Printer.object when it encounters an EndDoc
or NewPage method.
To enhance the presentation of your output there is the need to format you object texts or objects. The
comma, semicolon, Tab function and Spc functions are used to format text in VB
The print page takes five columns per line. Each of the columns is referred to as a print zone. A
comma is use to advance the position of printed output to the next print zone within a page.
Example
Printer.Print , Processing
ii.) Semicolon:
Semi colon is used if you need to separate printed items without advancing to the nest print zone.
Printer. Print Department: ; Computer Science
Compare this output with the one generated with the use of a comma
Please note that if the last character of a line of output is a semicolon or a comma, the next Print
command will continue on the same line without moving to the next line provided the printer has not
reach the last print zone for that page.
For example:
Printer.Print Department: ;
Printer.Print Computer Science
Will output as
To print a blank line use the Printer method without any items to print
104
Example:
Printer.Print
Printer.Print Department: ;
Printer.Print Computer Science
Printer.Print
Printer.Print Level: ;
Printer.Print 300
Will output as
Level: 300
Syntax
Tab (Columnposition) : This is used to place a the printing of an item in as specified position on a printed
line. The column position specified in the Tab function is a absolute one that is, position 1 1 means
column 1 while position 30 means column 30 on the line
Example
Will output as
Notice that since column position in a tab function is relative, the Tab function for the Computer science
print item could only start from position 22 to create room for the
Department: starting from column position 10.
This function is used to advance a number of spaces from the last item in a printed line
Example
Will output as
105
Department: Computer Science
The NewPage is used to send the current page to the printer and clears the printers object in memory
so that a fresh page can begin. The EndDoc method sends tha current page to the printers and
terminates the current printing process.
Example
Everything that appears in position will get printed by the default printer The printer enddoc is used
to tell the printer the job is finished.
Will output as
Department Level
Mathematics 300
Economics 400
Accounting 100
Nursing 400
4.0 Conclusion
As programming become more complex, it may be necessary to work with variables that hold more
than one value. In the case, arrays can be used to streamline your code by allowing you create shorter
and more efficient variables.
5.0 Summary
In this unit we covered arrays and described how to display messages using the MessageBox
command, and how to send documents to a printer. Printed copies of documents are also referred to
as hardcopies.
106
6.0 Tutor Marked Assignment
Q1. Write a VB program sending your name, address and other personal details to a printer?
Q2. Write a VB program that enables user to input their name, date of birth and prints out their
current age.
Q3. Write a VB program using the array function to allow user input a number of names and
searching them using an index. This program will get the item in a particular array set by requesting
the position before displaying.
Jan L. Harrington, SQL Clearly Explained, Morgan Kaumann Publisher, An Imprint of Elsevier
Science, 2003, USA
Greg Perry and Dean Miller, C Programming Absolute Beginner's Guide, 3rd Edition, Que
Publishing 2014.
107
MO DULE 4
UNIT 3: FILE PROCESSING
1.0 Introduction
2.0 Objectives
3.1 Working with Files
3.2 Working with Sequential Files
3.3 Working with Random Files
4.0 Conclusion
5.0 Summary
6.0 Tutor Marked Assignment
7.0 References/Further Readings
1.0 Introduction
A data file is a named collection of related records normally kept in external storage. Data stored in
files are permanent until you decide to delete them. Data files once they have been created can be
used as input for the same program for as many program run as you want without having to retype
data. Data files facilitate the sharing of data by many applications. Each record is broken down
into fields.
For example, in the Student registration file, information on Matriculation Number, Name, School,
Department, and Level, make up a record.
2.0 Objectives
At the end of this unit, you should be able to:
This refers to the manner in which data are organized, stored and retrieved. Two major ways of
file organization are sequential and random
The three main steps used for processing files are as follow:
1. Open the file: A file must be open for data to be read or written to it.
2. Read or Write records to a file
3. Close the file
108
i.) The Open Statement
The Open statement makes a file ready for use. The syntax of the Open statement is
The mode is used to indicate the way that the file is accessed and could be INPUT, OUTPUT,
APPEND or RANDOM
• Filenumber is a number associated with the open ed file. It value can be from 1 to 511.
This opens a file named Studrec as an Input file in the current directory calling it file #1
This opens a file named library.dat as an Output file in drive A calling it file #2
This opens a file named Inventory.dat as a Random file in drive A calling it file #3 with record
length of 30.
Close #Filenumber
109
Examples
a) Close #1
c) Close
Example
110
Append mode. The write statement is used to place data in a sequential file. The general
syntax of the Write statement is
Examples
Before a record can be used as a random file you need to set up its structure with a Type
statement and then dimension a record variable of the data type. The following code uses the
Type statement to declare Student record type:
To access a custom record type use the dot notation. This is similar to accessing object properties
The Put and Get statement are used to access random files.
111
(iii.) Using the Get Statement
The get statement is used to retrieve record from a random file. The syntax of the get statement is
as follow
Examples
Get #1, intScore1, intScore2, intTotalscore
Example
Seek #1, 5
4.0 Conclusion
One of the features of a computer that makes it suitable for data processing is its ability to store
data either temporarily or permanently. Data files are used to store information more permanently
in secondary storage devices. Data files once they have been created can be used as input for the
same program for as many program run as you want without having to retype data. Data files are
very essential for data processing
5.0 Summary
Data processing applications such as inventory, payroll, accounting, budgeting, and student s
information systems require that data are stored permanently in a file. In this unit we explained
the meaning of a file and covered how Visual Basic language is used to implement the
processing of files.
Tony Gaddis , Starting out With Visual BASIC - With Access - 7th edition, Pearson 2017,
ISBN13: 978013440015
112
MODULE 4
UNIT 4: STRUCTURED QUERY LANGUAGE (SQL)
Table of Contents
1.0 Introduction
2.0 Objectives
3.1 Structure of a SQL Statement
3.2 Using SQL Statements
3.3 Using the SELECT Statement:
3.4 Using the CREATE Command
3.5 Using the INSERT Statement
3.6 Using the UPDATE Statement
3.7 Using the DELETE Statement
4.0 Conclusion
5.0 Summary
6.0 Tutor Marked Assignments
7.0 References/Further Readings
1.0 Introduction:
Structured Query Language (SQL) is a programming language that is typically used in relational database
or data stream management systems. SQL has remained a consistently popular choice for database users
over the years primarily due to its ease of use and the highly effective manner in which it queries,
manipulates, aggregates data and performs a wide range of other functions to turn massive collections of
structured data into usable information.
For this reason, it has been incorporated into numerous commercial database products, such as MySQL,
Oracle, Sybase, SQL Server, Postgres and others. In fact, many non-relational databases like MongoDB
and DynamoBD are called NoSQL products due to their lack of SQL programming. While different
iterations of SQL may utilize different syntax for key operations, in general, basic commands like select,
insert, update and create are common to all SQL releases. This makes it very easy for someone with a
basic knowledge of SQL to work in many different environments and perform a wide variety of tasks.
There are many relational DBMSs. All relational database management systems speak a common
language called SQL (Structured Query Language). The aim of this language is to store, manipulate,
and retrieve data stored in relational databases. SQL combines the familiar database concept of tables,
rows (records), and columns (field) and the mathematical idea of a set. Typical SQL queries define
the fields to be processed, the table containing the fields, the range of records to be included, and, for
records retrieval, the order in which the returned records are presented.
2.0 Objectives
At the end of this unit, you should be able to:
113
i. The SQL operation
ii. The target
iii. The Condition
The four basic operations performed by a SQL Data Manipulation Language statement are:
Syntax
To illustrate with the above syntax, assume that we have the following table:
114
Also, let us assume that we are interested in the matriculation number of all the students in the
Student_Information table: To accomplish this, we use the command:
NOU0400010311
NOU0500011211
NOU0600012311
NOU0700034435
NOU0700042341
NOU0600051332
Similarly to select all the departments from the student_Information table you can use the
command:
Computer Science
Economics
Mathematics
Nursing
Computer Science
Accounting
Notice that the result of the SELECT statement in ii.) produced some redundancies i.e., the
department Computer Science appears twice. To avoid this, you may which to apply the
command DISTINCT after SELECT. That is to select all distinct departments in table
Student_Information write
Computer Science
Economics
Mathematics
Nursing
Accounting
Next, we might want to conditionally select the data from a table. For example, we may want to
only retrieve student names with Level above 200. To do this, we use the WHERE clause. To
select all Names with Level above 200 in the Student_Information Table, we apply the
commands
115
James
So far, we have seen how to retrieve relevant data from a table using SELECT and WHERE
commands. Sometimes, however, you may want the result of your query to be in a particular
order. This could be in ascending order, in descending order, or could be based on either
numerical value or text value. To achieve these, you can apply the ORDER BY clause to achieve
your goal. The syntax for an ORDER BY statement is as follows:
SELECT "column_name"
FROM "table_name"
[WHERE "condition"]
ORDER BY "column_name" [ASC, DESC]
For example, we ma y wish to list the contents of the Table, Student_ Information by Name, in
ascending order: We use the command
Result
Adamu Computer Science 400
Adebayo Accounting 200
James Economics 300
Musa Nursing 100
Peter Mathematics 200
Sule Computer Science 100
The Count command is an arithmetic function that allows you to count up the number of row in a
certain table.
The syntax is: SELECT COUNT ("column_name") FROM "table_name"
For example, if we want to find the number of departments in the table we use the command
SELECT COUNT (Department) FROM Student_ Information
116
Count(Department)
6
COUNT and DISTINCT can be used together in a statement to fetch the number of distinct
entries in a table. For example, if we want to find out the number of distinct department, we type
in the following
A table as discussed earlier is divided into rows and columns. Each row represents one piece of
data, and each column can be thought of as representing a component of that piece of data. So, for
example, if we have a table for recording student information, then the columns may include
information such as Matriculation Number, Name, School, Department and Level. As a result,
when we specify or create a table, we include the column headers and the data types for that
particular column.
Now that you know how to write simple queries to retrieve information from a table and the
command for creating a table, we shall look at the INSERT, UPDATE and DELETE command.
117
The INSERT statement is used to create new rows of data in a target database table or view. The
statement provides a list of columns that will receive the data provided and the corresponding list
having the data elements to be placed in each column.
The general syntax for inserting data into a table one row at a time is as follows:
INSERT INTO "table_name" ("column1", "column2", ...)
VALUES ("value1", "value2", ...)
and now we wish to insert one additional row into the table representing the data for student with
For example, say we currently have a table with the following data:
118
UP DATE Student_ Information
SET Dept = Economics
WHERE MatricNo = "NOU050010456 "
It should be noted that the matriculation number which is unique to all students in a
university was used as the search key.
4.0 Conclusion
The use of SQL statement increases the productivity of programmers in the development of
applications. SQL statements allows table be created, allow insertion, update, deletion of records,
etc. to be performed easily.
5.0 Summary
This unit covers describe and explain the use of basic SQL statements. Most modern day
programming languages support the use of SQL statements. The SQL statement allows easily
manipulations of record in database. You will find the skills acquired in this unit very useful in
your career as a Data Processing personnel
Exercise
Develop a simple data processing application that have features to add, delete, search,
edit, access first, access next, access previous and last student record from a database. The user s
interface should look like Figure 1. The information stored for each student contains
Matriculation Number, Name, School, Department and Level. Hint: Adapt the sample codes and
follow the procedures given below to write your application.
119
STUDENT REGISTRATION INFORMATION
Sample codes
120
MsgBox "No more Records Found ", vbInformation, "Message Box"
End
End If
End If
End With
End Sub
===============================================================
121
With rstud
If txtdept.Text = "" Or txtlev.Text = "" Or txtmat.Text = "" Or txtname.Text = "" Or txtsch.Text
= "" Then
MsgBox "Incomplete Registration", vbCritical, "Message Box"
Else
.AddNew
!MatricNo = txtmat.Text
!Dept = txtdept.Text
!School = txtsch.Text
!Names = txtname.Text
!Level = txtlev.Text
.Update
MsgBox "Registration Successful!!!", vbInformation, "Message Box"
Call clr
End If
End With
End Sub
===============================================================
=======
Source Code for command (Edit)
If datstud.constud.State <> adStateOpen Then datstud.constud.Open
If rstud.State <> adStateOpen Then rstud.Open "Select * from tblstud", datstud.constud,
adOpenDynamic, adLockOptimistic
With rstud
If txtdept.Text = "" Or txtlev.Text = "" Or txtmat.Text = "" Or txtname.Text = "" Or txtsch.Text
= "" Then
MsgBox "Incomplete Registration", vbCritical, "Message Box"
Else
122
!MatricNo = txtmat.Text
!Dept = txtdept.Text
!School = txtsch.Text
!Names = txtname.Text
!Level = txtlev.Text
.Update
MsgBox "Update Successful!!!", vbInformation, "Message Box"
Call clr
End If
End With
End Sub
===============================================================
=======
Source Code for command (delete)
Private Sub Command6_Click()
If datstud.constud.State <> adStateOpen Then datstud.constud.Open
If rstud.State <> adStateOpen Then rstud.Open "Select * from tblstud", datstud.constud,
adOpenDynamic, adLockOptimistic
If txtdept.Text <> "" And txtlev.Text <> "" And txtmat.Text <> "" And txtname.Text
<> "" And txtsch.Text <> "" Then
MsgBox "Sure you want to delete this Record", vbYesNo, "Message box"
If vbYes Then
With rstud
.Delete adAffectCurrent
.Requery
MsgBox "Recod Deleted", vbInformation, "Message Box"
End With
End If
End If
End Sub
123
Figure 42: Student Information
===============================================================
=======
Source Code for command (Search)
Private Sub Command8_Click()
If datstud.constud.State <> adStateOpen Then datstud.constud.Open
If rstud.State <> adStateOpen Then rstud.Open "Select * from tblstud", datstud.constud,
adOpenDynamic, adLockOptimistic
With rstud
.Filter = "MatricNo='" & txtmat.Text & "'"
If Not .EOF Then
txtname.Text = !Names
txtdept.Text = !Dept
txtlev.Text = !Level
txtmat.Text = !MatricNo
txtsch.Text = !School
Else
MsgBox "This name was not found in the database", vbCritical, "Message
Box" End If
End Sub
124
Figure 43: Other Registration
===============================================================
=======
Database Connection
SCREEN SHOTS
125
Figure 44: Database format
Step 2 Right click in the project explorer then Add a data environment this is what it looks
like:
Step 3
Figure 446
Right on the constud an click on the properties this is what you will see:
126
Figure 46: Data Properties
Step 4 Use connection string as shown on the screen shot then build. To build, you need
to supply your data source name. If you have not created any, enter a new data source name.
Step 5 Select the database used from the outlined databases then proceed
Step 6 Repeat step 4 because you don t have any created data source.
Step 7 You then select your database that has been created then you click ok!
Step 8 Test you connection. If successful, it means that your data source has been successfully
created otherwise repeat the step again.
Step 11 Link each recordset with the corresponding table that has been created in
the database in your form load() as follows:
Steve Tale, SQL: The Ultimate Beginners Guide: Learn SQL Today, CreateSpace Independent
Publishing Platform, 2016, ISBN 1533604568, 9781533604569
Dusan Petkovic, Microsoft SQL Server 2016: A Beginner's Guide, Sixth Edition, 6th Edition,
McGraw-Hill 2016, ISBN: 978125964180
127