a0.9.0.0 INTRODUCTION TO DATA PROCESSING SYSTEMS
a0.9.0.0 INTRODUCTION TO DATA PROCESSING SYSTEMS
DATA
Data is a collection of unprocessed items, which can include text, numbers, images, audio, and video.
Computers process data in a database into information.
By itself, data might not mean very much. In order to understand it, it needs to be interpreted (or
processed) to become information.
DATABASE
A systematically arranged collection of computer data, structured so that it can be automatically retrieved
or manipulated.
Simply put, a database is just a collection of related data organized into tables stored in a computer
system.
There are two main types of databases;
1. Relational Database:
RDB is a collective set of multiple data sets organized by tables, records and columns.
A well-defined relationship between database tables.
Relational Databases uses Structured Query Language, which is a standard user application that
provides an easy programming interface for database interaction.
2. Flat File Database:
FFD is a database that consists of a simple list and may have duplication of data much like a simple
record card.
So-called flat database consisting of a single table does not require much knowledge of database
theory.
DATA INTEGRITY
Identifies the quality of the data. The more errors the data contains, the lower its integrity.
130
GIGO
Garbage In, Garbage Out is a computing phrase that points out the accuracy of a computer’s output
depends on the accuracy of the input.
• Customer List
• Product List
RECORD:
An element or row in a database/file that contains a collection of data about an item. Information about a
single entity or item. it is a group of details about one specific item of the
table. It could contain a customer's name, his phone number, his member
ID, his work number, his marital status, etc.
• Customer Record
• Product Record
FIELD:
An element or column in a database table/file that contains a specific item or information. A single item of
data common to all records or the individual data items held for each record.
131
TABLE:
A table is made of rows and columns in which data is organized. A row is considered a Record.
QUERY:
It is a set of instructions passed to a database to retrieve particular data. E.g. SELECT firstName,
LastName, Age FROM STUDENT. A question/request about the data stored in a database.
FORMS:
Forms allow you to view data stored in your tables. It also allows you to enter data into fields.
132
REPORTS:
Reports allow you to print data based on queries or tables that you have created.
PRIMARY KEY:
The Primary Key is the unique identifier for each record in a table. Access will not allow duplicate entries
in a Primary Key field. By default, Access sets the first field in the table as the Primary Key field. The
primary key is vital for establishing relationships with other tables.
RELATIONSHIP;
133
A relationship in Access helps you combine data from two different tables. Each relationship consists of
fields in two tables with corresponding data.
Types of relationship
• One-to-Many relationship
• Many-to-Many relationship
• One-to-One relationship
VIEWS:
A database view is a searchable object in a database that is defined by a query. Though a view doesn't
store data, some refer to a view as “virtual tables,” you can query a view like you can a table. A view can
combine data from two or more table, using joins, and also just contain a subset of information.
DATABASE DESIGN
Is a collection of processes that facilitate the designing, development, implementation and maintenance
of enterprise data management systems. It helps produce database systems
1. That meet the requirements of the users
134
2. Have high performance.
The main objectives of database designing are to produce logical and physical designs models of the
proposed database system.
The steps in the development life cycle do not necessarily have to be followed religiously in a sequential
manner.
Requirement analysis
• Planning - This stage concerns with planning of entire Database Development Life Cycle. It takes
into consideration the Information Systems strategy of the organization.
• System definition - This stage defines the scope and boundaries of the proposed database system.
Database designing
• Logical model - This stage is concerned with developing a database model based on requirements.
The entire design is on paper without any physical implementations or specific DBMS
considerations.
• Physical model - This stage implements the logical model of the database taking into account the
DBMS and physical implementation factors.
Implementation
• Data conversion and loading - this stage is concerned with importing and converting data from the
old system into the new database.
• Testing - this stage is concerned with the identification of errors in the newly implemented system.
It checks the database against requirement specifications.
Microsoft access
Ms. Access is a Database Management System (DBMS) from Microsoft that combines the relational
database system with a graphical user interface and software development tools.
Microsoft Access can be used for;
135
• personal information management,
• in a small business to organize and manage all data, or
• in an enterprise to communicate with servers.
Relational Database
RDB is a collective set of multiple data sets organized by tables, records and columns.
A well-defined relationship between database tables.
Relational Databases uses Structured Query Language, which is a standard user application that provides
an easy programming interface for database interaction.
CREATING A DATABASE
Create Database
1. To create a database, we first need to open MS Access.
2. Select Blank desktop database.
3. Enter a name in the File name field and specify the location for your file to be saved.
4. Now, press the Create option. Access will create a new blank database and will open up the table
which is also completely blank.
We know this database is blank because it only contains one table (called Table1) and that table only has
one column (called ID). So we need to add some more columns to the table and give the table a name.
136
Create a Table
With database management systems, you need to create your tables before you can enter data.
Using our blank database, we are going to rename Table1 to Customers. This table will have 4 columns:
CustomerId, FirstName, LastName, and DateCreated.
1. Rename the ID field to CustomerId. To do this, Right-click on the ID column and select Rename
Field. Enter CustomerId when prompted.
2. On the next field, click on Click to Add (unless Access has already opened the menu for you) and
select Short Text.
3. At this point, Access will conveniently highlight/select the field name (currently Field1) so that you
can name the field. Call it FirstName.
4. Do the same again for the next field (LastName) and select data type Short Text.
5. In the next field, select the Date & Time data type and name the field DateCreated.
What we just did was create the column names and specify the type of data that can be entered into
them. Restricting the data type for each column is very important and helps maintain data integrity. It can
ensure that the user enters the data in the intended format. It can also guard against accidents like for
example, inadvertently entering an email address into a field for storing the current date.
Your database table should now look like this:
137
NB: Don't worry if you accidentally entered the wrong data type. You can change the datatype in the
Ribbon toolbar by adjusting the data type under the Data Type dropdown (top right area of the toolbar).
We have just created a database table. We did this in Datasheet view. Next, we will see how it appears in
Design view.
Design View
Design View is a database window in which tables are designed for a database. Design view enables you to
design and set up your database (kind of a "behind the scenes" view of your database). This is where you
set up and configure your tables, forms, reports, etc.
As you continue working with MS Access, you will find yourself switching between Design view and
Datasheet view (or in the case of forms, Layout view) often.
Switch to Design View
The following steps demonstrate how to switch to Design view.
1. Click on the View icon at the top left (just under the File menu). The View icon currently looks like
this:
2. At this point, Access will ask you to name and save the table you just created. Type Customers and
click OK.
3. You are now looking at your Customers table in Design view. Click on the DateCreated field, then in
the bottom pane, enter =Now() in the Default Value field. Also click in the Format field and select
General Date from the contextual menu.
138
We have just set a default value for the DateCreated field. This means that, whenever a new record is
entered, this field will automatically be populated with the current date and time. We have also specified
a format for all dates that are stored in this field.
Note: Primary Key - You might have noticed the little "key" icon to the left of the CustomerId field. This
indicates that the field is a primary key.
Switch Back to Datasheet View
Now that we're in Design view, you might have noticed that the View icon looks different - it has changed
from a Design view icon into a Datasheet view icon. It now looks like this:
Click the View icon to return to Datasheet view, and we'll look at the options for adding data to our table.
Adding Data
In Microsoft Access, there are many ways to add data to your database. Which method you choose will
depend largely on how much data you need to add and whether the data already exists outside of Access.
139
The main methods of adding data to a database;
1. Datasheet View
A database window that displays data from a table, form, report or query for changes (e.g., editing,
viewing, addition, deletion and searching) to be affected.
You can type directly into the table while it's in Datasheet view. While this is fine for smaller tables with a
small number of records that are rarely updated, it's not suitable if you plan to maintain a lot of records.
It's also not really suitable if there will be non-technical users maintaining the database. For non-technical
users, it's better to create a nice user-friendly form.
2. Form
You can set up a form, so that non-technical users can enter data into the form. Once they submit the
form, the data is automatically inserted into the database. One of the great things about forms is that they
can insert into many tables - saving you from having to open up each table to manually insert the data.
3. SQL View
You can use SQL view to insert data into your database. You can also use SQL view to do many other
things with your database (including creating tables). SQL (which stands for Structured Query Language) is
the standard programming language for working with databases.
4. External Data
There may be times when you need to load your database with data that already exists. For example, you
might have data in an Excel spreadsheet or even a .csv file that you want to transfer to an Access
database. This can be done!
Access 2013 allows you to import data from the following file types: Microsoft Excel, Microsoft Access,
ODBC Databases (such as SQL Server), Text or comma-separated value (CSV) files, SharePoint List, XML,
Data Services, HTML Document, Outlook folder
To import data from any of these file types, select EXTERNAL DATA from the Ribbon, select the file type,
then follow the prompts.
For now, we will create a form to enter data into our Customers table.
Create a Form:
As mentioned, Access forms provide non-technical users the ability to add data to your database. Forms
also make it easier to insert data across multiple tables.
There are several methods to create a form, options include using the;
• Form Wizard,
• Design view, and
• even starting with a blank form
Here's the quickest way to create a form in Access.
140
1. Ensuring that the Customers table is selected (in the left navigation pane), from the Ribbon, select
CREATE > Form
2. Access has just created a brand new form in Layout view, based on the fields in the Customers
table. Click on the inverted triangle under the View icon and select Form View:
3. This is how the user will see the form. Go ahead and enter data into the FirstName and LastName
fields. Be sure to hit Enter after you've entered the last name. Then hit enter again to add another
record.
141
4. Now let's check our table. Click Customers in the left navigation, then click Refresh All on the
Ribbon. You should now see your newly created record in the table:
You might notice that the DateCreated field is full of hashes symbols ######. This is because the
column is currently too narrow to display the data. You can resize the column to fit the data by
double clicking at the side of the column header. First, move the cursor to the edge of the column
header until it changes appearance into a resize tool, then double click. The column should now be
wide enough to display the data.
Now let's switch back to the form and save it.
1. Click on the second tab called Customers (the first one is for the Customers table), then click the
Save icon in the top left (above the Ribbon):
142
2. Rename your form Customers Form when prompted:
The form will now appear in the left navigation column under the heading Forms.
Next, we will switch to Design view and modify our form.
Modify Form
Here, we'll give the form a fresh new look and we'll also prevent users from modifying the DateCreated
field.
Design View
1. Click the Design view icon at the bottom right corner of Access (you can also use the icon at the
top left of the Ribbon if you prefer):
143
2. Click on the DateCreated field, then click Property Sheet. The Property Sheet will appear to the
right of the form:
144
3. On the Property Sheet, scroll down until you see the Locked option. Change its value to Yes using
the drop-down control.
We have just "locked" the DateCreated field so that users can't change it. This field is intended to store the
date that each record was first entered into the system.
4. Next, select the CustomerId label (the label is the one on the left - don't touch the ones on the
right), and add a space so that it becomes Customer Id. Do the same for the other fields. This just
makes the form a bit more readable and more presentable, as the labels are what the user sees. It
should look like this:
145
5. Now close the Property Sheet and switch to Layout view.
Layout View
It's time to give our form a new look.
1. In Layout view, click in a blank part of the form (i.e., away from the fields). This should select the
form detail area.
2. From the Ribbon, select a background colour for the form:
3. Now feel free to format some of the other elements on the page. For example, background colours
on each field, change the border colour of each field, bold the labels, etc. If you want to select
multiple fields, hold the Shift key down while you select them. You can even move fields around by
clicking and dragging them. And you can resize the fields by clicking and dragging their edges (you
can also do it via the Property Sheet). Don't forget to save the form once you're happy with it.
Here's an example of how a form can look by doing just that:
146
Form View
Now switch back to Form view and see how the form looks and works. Enter in a few records. And a few
more. You can also slide the Navigation Pane back to make more room for the form (you can do this in any
view).
147
Done. Next, we'll create a relationship.
Create a Relationship
A primary feature of relational databases is that they contain multiple tables, each of which can have a
relationship with any of the other tables.
Our database needs more than one table anyway, because we need to be able to track not only
customers, but also products, as well as the products the customers actually purchase.
So, let's create two more tables and establish a relationship between them. One table will hold product
information; the other will hold order information.
Create the Related Tables
Go ahead and create two tables as follows.
Be sure to set a format and default value for the DateCreated fields on both tables (the user shouldn't
need to enter this field - the system can do that).
148
Primary Key
Remember that the key icon indicates that the field is a primary key. A primary key ensures that the data in
this field is unique - no two values can be the same. A table must have a primary key before a relationship
can be established with another table. Access automatically sets the ID field as a primary key, so as long as
you simply rename ID to ProductId (or OrderId as the case may be) it will already be a primary key.
Establish the Relationship
Now that you've created two extra tables, our database has three tables. Now it's time to create the
relationship between all three tables.
1. While viewing a table in Design view, and ensuring that the DESIGN tab is selected, click
Relationships from the Ribbon:
2. A Show Table dialog box will pop up, displaying all three tables. Select all of them and click Add:
149
3. Click Close to close the dialog box.
4. You will now see three boxes, which represent your three tables. Click and drag the CustomerId
from the Customers table across to the corresponding CustomerId field on the Orders table:
5. The Edit Relationships dialog will pop up. Click Enforce Referential Integrity so that it is checked.
Check that the values are the same as the following screenshot and click OK:
150
You will now see a line established between the CustomerId field on the Customers table and the
CustomerId on the Orders table.
6. Now do the same for the Products table. That is, click and drag the ProductId from the Products
table across to the corresponding ProductId field on the Orders table. Your table relationships
should look like the ones in the following screenshot:
Relationship Types
We just established a many-to-many relationship. There are three (3) types of relationships that you can
establish between tables. These are as follows:
1. Many-T-Many Relationship* - This is an association between tables in which one record in either
table relates to many records in the other table.
2. One-To-Many Relationship – This is an association between two tables in which the primary key
value in each record in the primary table (i.e., the one side of this relationship) corresponds to the
value in the matching field or fields of many records in the related table.
3. One-To-One Relationship – This is an association between two tables in which each record in the
first table contains a field value that corresponds to the field value of one record in the other table.
NB: A relationship establishes an association between common fields in two tables. The type of
relationship that you use depends on the table structure and how the fields are defined.
Junction Table
In the above relationship, the Orders table is known as a junction table. A junction table is one that
contains common fields from two or more other tables within the same database. It is used as a reference
table in a many-to-many relationship (such as we are doing in our example).
Junction tables are known under many different names. Here are some: cross-reference table, bridge table,
join table, map table, intersection table, linking table, many-to-many resolver, link table, pairing table,
pivot table, transition table, or association table.
151
Foreign Key
A foreign key is simply the primary key's corresponding field in the related table. So, in our example, the
CustomerId field in the Orders table is a foreign key, while the CustomerId field in the Customers table is a
primary key. Likewise, the others.
Relationships and Queries
Creating relationships like the one above can assist in building queries against the database. Next, we're
going to use our newly created relationship to help us create a query against the tables in our database.
Create a Query
A query refers to the action of instructing the database to return some (or all) of the data in your
database. In other words, you are "querying" the database for some data that matches a given criteria.
The queries are run against one or more tables to return only the data that you're interested in. For
example, you might like to see a list of all individuals whose last name is "Griffin". And so on and so on.
Sample Data
Before we start querying the database, we should probably make sure we've got enough data in there
first. Otherwise, it doesn't matter how good our queries are - they will all return zero results if there's zero
data. So, let's add some data.
Remember, the ID columns and DateCreated columns are automatically generated, so you only need to
enter data into two columns in each table.
Feel free to make up your own data. Here's mine:
Customer
152
Products
Order
Referential Integrity
When you create a relationship, you also have the option to Enforce Referential Integrity (which we
selected when we created our relationship). This prevents foreign key values from having no corresponding
primary key value in the referenced table.
153
Create the Query
Now let's create a query that returns the names of all customers who have ordered a product.
1. Ensuring you have the CREATE tab open on the Ribbon, click Query Design.
2. The Show Table dialog box will appear with all of our tables listed. Select all three tables and click
Add, then click Close:
3. The three tables are now represented in the top pane (beneath the Ribbon). Choose the fields
you'd like to be presented in the results of your query. You can either double click on the field
name or click and drag it down to a column in the bottom pane. Select the fields as follows:
154
4. Click the Run button at the top-left part of the Ribbon:
5. You should now see the result of the query. Here's mine:
155
6. Save the query by right-clicking on the Query1 tab and giving it a name. Call it Customer Orders:
Our query successfully returns all customers who ordered at least one product and it includes the product
and its price next to their name. You can also see that some customers have ordered more than one
product. The query has automatically joined the three tables using the relationship that we created and
returned the matching data.
This query will only return those customers who have ordered at least one product. If a customer is in the
Customers table but does not order a product, that customer's record will not be displayed in the results
of this query. If you look back at the Customers table (near the top of this page), you'll see that Marge
Simpson is a customer but she hasn't ordered any products yet (i.e., she doesn't have a corresponding
record in the Orders table).
Next, we're going to modify our query so we can look at some of the other things we can do with queries.
156
Modify a Query
OK so we just created a query to return all customers in our database who have ordered a product. Now
we'll see if we can tweak the query a little bit here and there to see what other results we can return.
Product Name
The marketing department wants to see who, if anyone, ordered their most expensive space ship. So, let's
return a list of all customers who purchased the most expensive space ship - the "Venus Carrera ET".
1. From Design view, in the bottom pane, enter "Venus Carrera ET" (double quotes included) into the
Criteria field of the ProductName field:
2. Click the Run button in the Ribbon to view the results of the query. Alternatively, you can just click
the Datasheet View icon. And here's the result:
3. Once you're satisfied with the results, return to Design view and remove your modification (i.e.,
remove "Venus Carrera ET" from the Criteria field).
Price
You could also modify your query so that it returns customers who purchased a product worth over a
certain price.
So, let's construct a query that returns all customers who purchased any product with a price over
$80,000.
1. From Design view, in the bottom pane, add (>80000) into the Criteria field of the Price field:
157
2. Click the Run button in the Ribbon to view the results of the query. Alternatively, you can just click
the Datasheet View icon. And here are the results:
You could spend a lot of time tweaking this one simple query. For example, here's some ideas:
158
3. Click OK to save the file at the default location. Alternatively, change the location and/or a file
name. You can also select any other options you wish to include:
159
4. Click Close. Alternatively, you could select Save Export Steps before clicking Close.
You now have an Excel spreadsheet containing the data from your query that you can send to anyone you
like.
As you can see from the Ribbon, you can export to other file types such as XML, text file, and even PDF
documents. The steps are similar to the above.
160
WORKING WITH REPORTS
Designing and Managing Reports
LESSON ASSESSMENT
OBJECTIVE
1. The code that is stored with a form or report is called
A. Class module
B. Form module
C. General module
D. Standard module
2. The maximum length of a text in a database is
A. 75
B. 120
C. 255
D. 265
3. The SQL statement used to read data from a table is
A. GET
B. QUERY
C. READ
D. SELECT
4. Which of the following data types would be appropriate to use to store the name of a customer in a
database?
A. DATE
B. MEMO
C. NUMBER
D. TEXT
5. Which of the following fields in a database application can help speed up data retrieval?
A. Data
B. Key
C. Program
161
D. Record
6. In order to add a new row to an existing table, the SQL statement to use is
A. CREATE
B. INSERT
C. UPDATE
D. WHERE
7. One-to-many relationship between student and class tables means
A. One class may have many students
B. One student may have many classes
C. Many classes may have many students
D. Many students may have many classes
8. A database that informs database management system about the whole data structure is called
A. Data control language
B. Dynamic link library
C. Data definition language
D. Data manipulation language
9. Which of the following options is not a data type in a database application?
A. Date/Time
B. Number
C. Picture
D. Text
10. In a datasheet, each column represents a
A. Database
B. Field
C. Record
D. Table
11. Checking input data against specified criteria is referred to as data
A. Check
B. Control
C. Validation
D. Verification
12. The object that stores commands to retrieve data from a created database is called a
A. Form
B. Query
C. Report
D. Table
13. In order to sort or arrange rows in a table based on one or more columns in SQL, the statement use is
A. ARRANGE BY
B. GROUP BY
162
C. ORDER BY
D. SORT BY
14. The following terms represent database objects except
A. Queries
B. Reports
C. Relationships
D. Tables
15. The correct order of keywords used in an SQL statement is
A. FROM, SELECT, WHERE
B. SELECT, FROM, WHERE
C. SELECT, WHERE, FROM
D. WHERE, SELECT, FROM
SUBJECTIVES
1. A) What is;
I. Relationship, as used in database;
II. Lookup field?
B) Explain the following database relationship types;
I. one-to-one
II. one-to-many
III. many-t- many
2. A) What is a database?
B) Define the following terms as used in Database;
I. File
II. Field
III. Record
IV. Table
V. Query
PRACTICALS
1. Create a database application and save it as MOCK in the folder created.
163
2 210099 34 55 76
3 210022 88 75 66
2 210077 45 53 55
1 210064 89 55 43
TABLE 1
A) Create:
I. the structure for table 1 using ST_ID as the primary key and save as EXAMS.
II. a form that will enable users to enter data into EXAMS and save as EFORM.
B) Use the from in 2 (a)(ii) to enter data as shown in table 1.
C) Create a query to sort the table EXAMS by LEVEL and MATHS in ascending order. Save as SRTEXAMS.
2. At a recent Parent Teachers Association meeting in a certain Senior High School, the school authorities
expressed their concern about the health of the students. Towards this, some data of the students were
collected as shown below.
STUDENTDETAIL
SUBJECT
SUBJECTSELECTION
165