Chapter 9 – databases
In this chapter you will learn about-:
- Creating relational databases
- Designing forms and reports
- Creating queries
- Importing and exporting data
- Applying database security
Madzingira 12/26/2024
DATABASES
A Database is a collection of related and
organised files sharable among computer
users of an organisation. Databases
enable addition, deletion and
modification of data held in the
computer. Madzingira 12/26/2024
Bit: A single binary digit like 0 or 1.
•Nibble: A group of 4 bits, which is half a byte, eg 1001.
•Byte: A group of eight bits representing a character for
•Field: A specific category of information in a table
(database), for example Surname, Date of Birth, etc
•Record: A collection of related fields describing an enti
•File: A collection of related records
Madzingira 12/26/2024
•Database: A collection of related files
A database system (elements) is
made up of stored data,
software to maintain the
database, procedures and the
person working with the
database.
Madzingira 12/26/2024
Types Of Databases (Database Models)
These includes relational, hierarchical and network
databases.
1. Relational databases: These are
database that organises data in a table
format, consisting of related data in
another file, allowing users to link the
files together. Each column represents an
attribute (characteristic or field). Each
Madzingira 12/26/2024
row represents a record (or tuple), as
Relational databases organise data in a flexible manner.
They are also simple to construct and are easy to use.
However, it may be difficult to come up with
Madzingira 12/26/2024
relationships.
From the above database structure, it can be
noticed that:
- There are three records for Kapondeni, Turugari
and Moyo. A record is also called a tuple.
- There are four fields: Student Number, Surname,
First Name and Date of Birth.
The student Number is used as a Primary Key (Key
field) because it gives a unique(one) record.
Madzingira 12/26/2024
ELEMENTS OF A RELATIONAL DATABASE
A primary key is a field that is used to
identify a unique record from a database.
All other fields from the above database
are not appropriate for a key field because
they can identify more than one record.
That is surnames can be similar for 2 or
more people as well as date of birth.
Madzingira 12/26/2024
*NB: Concatenated key: the combination of two
or more fields in a database in order to identify a
unique record, e.g. using the Surname, First Name
and Date of Birth in search of one record.
*NB: Secondary Key: A field used to identify more
than one record at a time, e.g. a surname.
*NB: Attribute: A characteristic of a record, e.g. its
surname, date of birth.
Entity: any object or event about which data
Madzingira 12/26/2024
can be collected, e.g. a patient, student, football
Field-: a single piece of data eg name, date of
birt or national ID. It is basic unit of data entry
in a record. It is normally represented by a
column in a relational database. Each field has
its attributes such as names and data types.
Foreign key-: it is special column or field or
combination of fields in one table that uniquely
identifies a row of another table.
Composite key-: Refers to two or more columns
that can be used to uniquely identifies each row
in a table. Madzingira 12/26/2024
Record: is a collection of fields. It can also be
Object-: refers to a table, a
query a form or report
Table-: is made up of group of
records. It can be called a
relation
Query-: it is an extract of a
relation/table using a given
criteria for example names
Madzingira 12/26/2024
Report-: Is a database object that is
used to display and print your data
in an organised manner.
Database-: is made up of objects. It
may contain several forms queries
and reports.
Madzingira 12/26/2024
Form-: It is an object made up of
controls that are used to create
user interface for a database
application a form can be bound or
unbound. A bound form is the one
that is connected directly to a data
sources such as a table, query and
can be used to enter, edit or display
Madzingira 12/26/2024
data from the data sources.
Data types for fields can be:
- Numeric: consists of digits 0-9 only (negative or
positive), 12, 900, -50, etc
- Alphabetic: Consists of letters of the alphabet (a-z,
lowercase or uppercase) only, for example a person’s
name, like Tungamirai.
- Alphanumeric: Combination of digits and letters of the
alphabet, eg. National
Identification Number, like 27-134575-C-27
- Text: Combination of digits and letters of the alphabet.
Madzingira 12/26/2024
- String: Combination of digits and letters of the
alphabet. Same as text data type
- Currency: in monetary value, e.g. $10.00
- Date/time: shows date and time, e.g.
27/01/1997
- Array: An array is a series of elements of the
same type placed in contiguous memory
locations that can be individually referenced by
Madzingira 12/26/2024
adding an index to a unique identifier.
Advantages of Databases
• Validation checks are made on data during entry thereby reducing data
entry errors.
• Searching and retrieval of data is very fast.
• Less likelihood of data getting lost.
• Record structure can be easily modified if the need arises.
• Files can be linked together making file updating easier and faster.
• Avoids/reduces data redundancy.
• Data can be secured from unauthorised access by use of passwords.
• Users can share data if the database is networked.
• Duplication of records is eliminated.
• Ad hoc reports can be created easily.
• Sorting of records in any order is very fast
Madzingira 12/26/2024
Disadvantages of databases
• If the computer breaks down, you may not be
able to access the data.
• It is costly to initially setup the database.
• Computer data can be easily copied illegally and
therefore should be password protected.
• Takes time and costs to train users of the
systems.
• Expensive to employ a database administrator
who will manage the database
Madzingira 12/26/2024
Database System of a
School
Admission
program
Students DBMS
Schedule
Data Program
tafadzwa musika 12/26/2024 19
Common File processes
• File updating
• Insertions
• Deletions
• Amendments
tafadzwa musika 12/26/2024 20
File Updating
• Involves bringing a file up-to-date
with any changes that have
occurred.
• There are various process that
can take place during updating.
tafadzwa musika 12/26/2024 21
Insertions
• A new entry in the file.
• Suppose we had a file containing the
details of pupils in a school.
• A new pupil may have joined the school
and so that pupil’s details will need to be
added to the file.
tafadzwa musika 12/26/2024 22
Deletions
• A delete record in the file.
• A pupil could have moved to a
new school so that the pupil’s
detail will need to be removed
from the file.
tafadzwa musika 12/26/2024 23
Amendments
• Some changes occur in the field
of file.
• A pupil has moved house so the
address field needs changing.
tafadzwa musika 12/26/2024 24
File Manipulations
•Sorting
•Merging
tafadzwa musika 12/26/2024 25
Sorting
• Some time a field need to be sorted in
particular order.
• It may be
• Ascending
• Descending
tafadzwa musika 12/26/2024 26
Merging
• Sometimes we want to combine the
contents of two files to form a single
• The process of combining the files is
called merging.
• If the two files to be merged are on
magnetic tape then we must sort the
tapes into order before merging them.
• Merging is very important when we want
to divide the work.
tafadzwa musika 12/26/2024 27
Examples
FIELD A Students Files
Roll Name Phone# DOB
No
1 Ali 042-78888 12/12/9
8
2 Ahmed 544545 09/4/97
RECORD
tafadzwa musika ITEM
12/26/2024 28
Creating
Queries
Reports
Forms
Importing data from external sources
Exporting data from Access
Database security
Madzingira 12/26/2024