0% found this document useful (0 votes)
2 views

Chapter Seven Database Management Systems (1)

Chapter Seven covers Database Management Systems, focusing on MS Access as a tool for storing and managing data. It explains key concepts such as database objects, tables, queries, forms, and reports, along with their applications and benefits. The chapter also provides step-by-step instructions for creating and managing databases, including setting relationships between tables and performing queries.

Uploaded by

HYPERLINK CYBER
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Chapter Seven Database Management Systems (1)

Chapter Seven covers Database Management Systems, focusing on MS Access as a tool for storing and managing data. It explains key concepts such as database objects, tables, queries, forms, and reports, along with their applications and benefits. The chapter also provides step-by-step instructions for creating and managing databases, including setting relationships between tables and performing queries.

Uploaded by

HYPERLINK CYBER
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

CHAPTER SEVEN

DATABASE MANAGEMENT SYSTEMS

At the end of the chapter the learner shall be able to;


 Explain the different database terms
 Open and use an existing database
 Design and create a simple database
 Save database objects with appropriate names
 Create simple queries
 Design input forms
 Design output reports

These are software that allow records to be entered in the system and to be
retrieved in a specified format. Examples are Ms Access, Paradox, Dbase, FoxPro,
Sybase.
From the above examples, we shall look at Ms Access.

7.1 MS ACCESS
MS Access is a database tool used to store, maintain and use a collection of
information that is organized to serve a specific purpose.

A database is a collection of related information organized to serve a specific


purpose.

Benefits of using database to store information


1. Fast retrieval of information i.e. data is easier to find.
2. Easy to maintain accurate and up to date data.
3. Easy to analyze and make summary reports on the stored data.
4. Easy to protect your data from unauthorized access.
5. Information can be accessed in many ways.

Database objects
Tables, Queries, Forms, Reports, Macros, Modules.

Tables
Collection of data about a specific subject e.g. customers, employees e.t.c.
In a table, data is organized in fields (columns) and records (rows)
A table consists of:
(a) Field names
(b) Data types
(c) Description

(a) Field name: - these are column headings for the table being created.
(b) Data types: - the attribute of a field that determines the type of data it can
hold e.g. text, Numeric, Currency etc.
(c) Description: - This column is optional but can be used to give a detailed of
the field name.

Primary key: - This is a field that is used to uniquely identify each record
stored in a table.

Queries

A query is a type of database search. It enables you to retrieve data that has met
conditions you specify, indicating data from tables.
The word „query‟ literally means „to ask‟. Access queries provide a way of asking
about your data. When you design a query, you identify the fields to be included
and the records to be retrieved from one or more tables.
You can as well update or delete multiple records at the same time, perform built
in or custom calculations on your data.

Forms

They are used for adding new data, editing or displaying existing data. This data
can be in a table or a query. Information entered directly in a form will appear in
Tables automatically.

Reports

The desired result of any database is to provide information in the form of


reports. You can print reports from tables or queries in any desired format.
Reports are used to summarize and display data from your database. It
displays the most up-to-date information.

Modules
They are collection of codes using Access Basic programming language. If
programming is necessary, you can write modules.
Database definitions
1. Field: This is any piece of information in a database e.g. Names, Age, Birth
date.
2. Record: It is a collection of several related fields.
3. Database File: This is a collection of several records.

Applications of databases
1. Educational applications: Preparing students‟ reports, class schedules.
2. Retail applications: This may include sales projections and Quotas,
Market analysis e.t.c.
3. Legal applications: This may include client information and case
schedules.
4. Financial applications: This may include stock market forecasting and
end of year financial reports.

PLANNING REQUIREMENTS
In order to plan an efficient database you need to ask yourself some
questions, these include.

1. What information do I need to keep track on?


2. What is my hardware and software capability?
3. Who will be using the database?
4. What are the projected future database needs?
Using the example of student records database, let us design, implement and use
Access as a database manager.

The subject/object here is a student and the suggested field names could be;
i) Student‟s name
ii) Student‟s registration number
iii) Student‟s address
iv) Parent‟s name
v) Age
vi) Sex
vii) Course taken
viii) Subjects
ix) Hours a subject takes
x) The lecturer
xi) Lecture‟s rate per hour
xii) Tuition fee
xiii) Course duration
xiv) Date of admission
xv) Amount paid

All the above listed is information about one object – student. There is need
however to limit the list to the subject area only.

Therefore the next stage you ask question (s) like:


 Do I want to store information about lecture‟s records or student‟s?
 If I want the student‟s records, should I include fee payments records,
timetable or
examination records?

Let us assume we wish to store student fee payment records only. This will
reduce above list to the following.

i) Student‟s name
ii) Student‟s registration number
iii) Student‟s address
iv) Course taken
v) Age
vi) Sex
vii) Date of admission
viii) Amount paid

7.2 WORKING WITH ACCESS 2000


Starting Access
1. Click start button and move to programs.
2. Move to Ms access and click.
3. The resulting dialog box prompts you to create a new database using
either blank database, database wizard or existing database.
4. Click „blank database, option since you are creating a new one. To
open an existing one, click the appropriate option.
5. The „file new database‟ window appears. Enter the name of the
database you want to create i.e. (Macarl student record system) and
click Create.
6. A database window appears. It is blank since there are no tables,
queries, forms, and reports.

NB: The database name (Macarl student record system) is displayed on the title
bar of the database window.
7.3 WORKING WITH TABLES
1. Click new (after clicking the tables tab)
2. „A new table‟ window appears. You can create a new table with the
different options listed.
3. Select the design view and click Ok.
4. The „table window‟ appears with field name, data type and description
columns (as discussed in tables earlier)
5. In the Field name, type the first field i.e. assuming we are creating a
table on students, one suggested field could be Student name.
Therefore, type Student name.
6. Click data type column and select the data type, (in this case text)
7. Click the description column and describe the field you have just
made. However it is optional and could be skipped.
8. Define all other student‟s detail fields by repeating steps 5-7.
9. Close the table and respond affirmatively to „save changes‟ dialog box.
Save the table as „students‟
NB: your database now has one table object.
DATA TYPE USE EXAMPLE

Text (Default) text or combination Stephen, Mary, KAZ


of text & numbers as well as 078w KQ2534
numbers that don‟t require
calculations such as phone
numbers. The default size is
50 characters but up to 225
characters can be stored.
Memo Lengthy text or combination Notes and descriptions
of text and numbers. Can
store up to 64,000 characters
Number Numerical data used in 6634,76731,890987,33,978
mathematical calculations,
except that involving money.
Date and time Dates and times values for the 2-jan, 17/8/90, 09:55AM
years 100 through 9999 4-march-1789
Currency Monetary values $5689,ksh9873, £5637

Auto number A unique sequential


(incremented by 1) number or
random number assigned by
Ms Access whenever a record
is added. AutoNumber cannot
be updated
Yes/No Yes or No values or fields
contains only one or two
values (true/false, yes /no, on
off)
OLE object Graphics and objects such that
Ms Excel spreadsheets,
sounds can be embedded to
Access

A unique field is required in every table. This is an identification key like the
national ID card that identifies each person individually. The unique key is
referred to as primary key in Access. It is useful when you want to avoid
entering duplicated records.
If what you design does not have a unique field, Access lets you include a
special field called AutoNumber which contains sequential or random numbers
that Access automatically generates as you add new records.
Setting a primary key
1. In the table design view, click inside the key you want to define as the primary
key.
2. Click edit from the menu, move to primary key and click.

N/B: If Access has already taken AutoNumber as the primary key, delete the
record by choosing it from the border and pressing delete key from the
keyboard.

Using the data sheet view and the design view

1.Select the table icon by clicking on it once.


2.In the database window, click open
3.The table is open displaying all the field without any record
4.At this juncture, you can add records in your table
5.In case you want to change the a field name, click view from the menu bar
6.Click design view, highlight the field you want to rename and type the new
name.

N/B:
 Datasheet view allows you to add records while you modify the table in
design view.
 You can rename a field in data sheet view by double clicking the field and
typing a new name

To create a table using a wizard


1) Click on the tables tab.
2) Click new.
3) Select table wizard.
4) Follow screen instruction

Sorting records in the table

 Sorting helps to quickly locate the highest or the lowest value in a list E.g.
you can sort to know who has paid the highest amount.
 It also helps arranging data in order of priority.

Procedure
1) Position the cursor in the field you want to sort.
2) To sort in ascending or descending, click records from the menu bar.
3) Move to sort and choose as desired.

Insert, Delete or Rename a column


 To insert a new column to the left of the current column, click column on
the insert menu.
 To rename a column, double click its heading and then type the name
desired.
 To delete a column, click the column heading to select it and then click
Delete Column on the Edit menu.

7.4 RELATIONSHIPS
After setting up different tables for each subject in a database, there is need to let
access know how to bring the information back together. The first step in this
process is to define relationships between the tables. After that, queries, forms,
reports can be used to display the information from all the tables at once.

A relationship is an association established between common fields in two tables.


It can be one-to-one, one-to-many or many-to-many relationship. A relationship
works by matching data in key fields usually a field with the same name in both
tables.

A one-to-one relationship
In a one-to-one relationship, each record in Table A can only have one matching
record in Table B and each record in Table B can have only one matching record
in Table B.

A one-to-many relationship
A one-to-many relationship is the most common type of relationship. In a one-to-
many relationship, a record in Table A can have many matching records in Table
B, but a record in Table B has only one matching record in Table A.

A many-to-many relationship
In a many-to-many relationship, a record in Table A can have many matching
records in Table B, and a record in Table B can have many matching records in
Table A. This type of relationship is only possible by defining a third table (called
a junction table) whose primary key consists of two fields, the foreign keys from
both Tables A and B. A many to many relationship is really two one-to-many
relationships with a third table.
7.5 WORKING WITH QUERIES

Creating a query
Query is a database search. It enables you retrieve data that meets certain criteria.
You can use a query to create a table, a report or a form. When you have a
frequently asked query, you can save it so that each time you need the
information, you just run the query instead of opening the table.

Creating a select query


1. In the database window, click the query tab.
2. Click the „New‟ button and then select design view.
3. Click OK.
4. The show table dialog box appears. In this dialog box, you select the table(s)
that you want to base your query on.
5. Select the table and click Add.
6. Click close to close the dialog box and get to the query window.
7. Place the cursor in the row for „field‟ and click to chose the field(s) you want in
your query.
8. To view the output, click on the „RUN‟ button on the query design toolbar.
.

Saving a query
1. Close the query box by clicking „X‟ button
2. Click yes when prompted to save the query.
3. Type the name of the query in the „save as‟ dialog box. In our case „students
balance s‟
4. Click Ok

Creating an update query


This is used when you want to make changes to a group of records in one or more
tables all at once. It changes all specified records at once to reflect the correct
information
For example: when you wish to raise the fee of an amount paid in your database by
10%.

Procedure
1.Create a new query in the design view.
2. Select the table that you want to update records.
3. Add the field/s you want to update in our case „amount paid‟
4. Click „query „ from the menu bar, click „update query‟. This changes the query
from a select query to an update query.
The ‘update to’ row is added.
5. Select the field(s) to be updated (In this case amount paid)
6. In the „update to‟ cell, type in the expression that you will use to update
information in your table.

Example: You may decide to raise the fees by 1000,therefore you type [amount
paid]+1000 in the „update to‟ row of the amount paid field.
7. Run the query.
8. A warning appears informing you that the action cannot be reversed.
9. Click Yes to update the records.
10. Close the query and save the changes.

NB: An update query does not open the records when double clicked, Instead you
should open the table that you run the update query on to view the results.

A query that meets a given criteria


1. Open the table you want to query.
2. In the database window, click the query tab.
3. Choose the table(s) that you want to query, in the show table dialog box, click
add and then close.
4. In the field area, select the field(s) to be included in your query E.g. you can
select „student‟s name‟ and „amount paid‟ fields.
5. In the criteria row, type the criteria you want to base your query on e.g. if you
are querying for all the students who have paid over Ksh2000, type >Ksh2000
under the „amount paid‟ field.
6. Click the run button „!‟ on the toolbar.
7. Save the changes you have made.

Creating a Delete query


A delete query removes records you specify e.g. you can remove outdated records

1. Open the table that you want to query.


2. Click the queries tab.
3. Click new then design view.
4. Add the table you want to query, then close.
5. Click the query menu, choose and click delete query. Ms Access automatically
adds a Delete row.
6. Select the field you want delete records from. Choose the criteria of the records
e.g. <01/10/1999
7. Click the run button „! ‘
8. A dialog box appears warning you about running the query. Click yes to delete
then close the query.
9. Save the query.

Creating a Total Query


1. Create a new query in design view and add the table to be used for the query.
2. Select the fields to appear in the query.
3. In the view menu, click „totals‟ or click „Σ‟ from the query design toolbar.
4. The total row appears in the grid. The words „group by‟ appear under each field
selected.
5. You need to specify the field to be used for grouping and the fields to be used for
totals (calculations). For fields to be used for grouping, select „group by‟ in the
total row.
6. For fields to be used for totals, select a type of calculations e.g. count, sum,
average e.t.c
7. Run the query.

TYPES OF TOTALS
Types of Calculations Used to calculate
Sum The total values in a field
Average The average values of a field
Minimum (Min) The lowest value in a field
Maximum (Max) The highest value in a field
Count The number of values in a field
StDev The standard deviation of values in a field
Var The variance of values in a field
First The field value from the first record in a table or a
query
Last The field value from the last record in a table or a
query

Creating tables using a Make Table Query


When you create a table using a query, the primary key and other field
properties are not inherited. They have to be set afresh.

1. Create a new query or use an existing one.


2. On the query menu, click on the „Make-Table‟ option.
3. The „Make Table‟ dialog box appears. In the „Table Name‟ type the name
of the table you want to create, or click the one you want to replace from
the drop down menu.
4. Click “Current Database” to put the new table in the open database, or
“Another Database” and type the name of the database you want to put
the new table in.
5. Click Ok.

Creating a Parameter query

A parameter query is a query that when run displays its own dialog box
prompting you for information, such as criteria for retrieving records or a value
you want to insert in a field. You can design the query to prompt you for more
than one piece of information; for example, you can design it to prompt you for
two dates. Microsoft Access can then retrieve all records that fall between those
two dates.

To prompt the user for one or more characters to search for, and then find
records that begin with or contain the characters the user specifies, create a
parameter query that uses the LIKE operator and the wildcard symbol (*). For
example.

For a field that displays dates, you can display the prompts "Type the beginning
date:" and "Type the ending date:" to specify a range of values.
Procedure

1 .In the database window, click the query tab.


button and then select design view.
Click OK.
4. The show table dialog box appears. In this dialog box, you select the
table(s) that you want to base your query on.
5. Select the table and click Add.
6. Click close to close the dialog box and get to the query window.
7. Place the cursor in the row for „field‟ and click to chose the field(s) you
want in your query.
8. In the field's Criteria cell, type Between [Type the beginning date:] And
[Type the ending date:].
9. Click the run button „!‟ on the toolbar.
10. Save the changes you have made.

Searching for words that begin with a specified letter.


1 .In the database window, click the query tab.
2. Click the „New‟ button and then select design view.
3. Click OK.
4. The show table dialog box appears. In this dialog box, you select the
table(s) that you want to base your query on.
5. Select the table and click Add.
6. Click close to close the dialog box and get to the query window.
7. Place the cursor in the row for „field‟ and click to chose the field(s) you
want in your query.
8. In the field's Criteria cell, type
LIKE [Enter the first character to search by:] & "*"

9. Click the run button „!‟ on the toolbar.


10. Save the changes you have made.

Searching for words that contain a specified character.


1 .In the database window, click the query tab.
2. Click the „New‟ button and then select design view.
3. Click OK.
4. The show table dialog box appears. In this dialog box, you select the
table(s) that you want to base your query on.
5. Select the table and click Add.
6. Click close to close the dialog box and get to the query window.
7. Place the cursor in the row for „field‟ and click to chose the field(s) you
want in your query.
8. In the field's Criteria cell, type
LIKE "*" & [Enter any character to search by:] & "*"

9. Click the run button „!‟ on the toolbar.


10. Save the changes you have made.

7.6 FORMS

Working with forms


A form is basically a way of displaying data, record by record. It is the most
convenient object in which a non-experienced user of Access can enter records.
Any record entered using a form is automatically entered into the table. In forms,
you can edit, sort, filter, add/delete records etc.

To create a form using wizard


(a) In database window, click the forms tab.
(b) Click new.
(c) In the new form dialog box, click the wizard you want .
(d) Click the name of the table or query that includes the data you want to base
your form on.
(e) Click Ok

To create a form using tabular /columnar Autoform

a) In the database window, click on forms tab


b) In the new form dialog box click, tabular/columnar Autoform.
c) Click the name of the table or query that includes the data you want to
base your form on.
d) Click Ok

(Object linking and Embedding)


O.L.E : its an object such as the Ms- word document, MS –Excel spreadsheet,
graphics, sound or other binary data linked to or embedded in a MS-Access
table.
Access allows you to accompany your database with graphical objects e.g.
you can have a customers photo as one of the items in his records. You can have
the picture of the products you have on sale etc.

Procedure

1) In the database window, click the tables tab then click new or use an
existing table.
2) Click design view then Ok
3) Designate one of the field for the O.L.E. The field name could be photo,
picture etc. For its data type, select O.L.E. objects.
4) Close the table and save the changes.
5) Open the table.
6) Right click the O.L.E fields(s) then insert object.
7) From the object type list, select a category i.e. Microsoft clip gallery then
click Ok.
8) Select a clip then click insert.

NB/ The object will always be seen whenever you open a form based on the
table or query that has the O.L.E field.
7.7 REPORTS
Reports are used to analyze data or present it in a certain way in print. A report
could be that which groups data and calculates totals and another different data
formatted for printing mailing tables.

To create A Report using Wizard


You can create a report on your own or you can have Ms-Access create one for
you .The wizard speeds up the process since it does all the basic work for you. A
wizard promotes you for information and creates a report based on your
answers. You can also customize a table in design vie\w.

Procedures

1) In the database window, click the report tab.


2) Click new.
3) In the new report dialog box, click the wizard that you want to use. A
description of the wizard appears on the left side of the dialog box.
4) Click the table or the query that contains the data you want to base your
report on.
5) Click Ok.
6) Follow the directions in the wizard dialog boxes.

To create a report using a Columnar/ Tabular Autoform

1) In the database window, click the reports tab.


2) Click New.
3) In the New Report dialog box, click either Columnar or Tabular
Autoform.
4) Click the table or the queries that contain the data you want to base your
report on.
5) Click Ok.
7.8 Chapter Review Exercise
Prepare a database table and assign appropriate data types to hold
the following data and define a primary key
Name Course DATE OF SEX FEES(Kshs.)
BITH
Kilonzo David Muthami B. Ed 31/01/92 Male 54,000
Mumbi Irene Wangui M. Ed 06/10/87 Female 60,000
Mwangi Muriithi M. Ed 21/06/93 Male 54,000
Simon Kinyanjui BBIT 16/09/97 Male 62,000
Muuki Agneta Kalekye B. Ed 19/04/93 Female 60,000
Wang'ombe Grace BBIT 17/01/88 Female 54,000
Kiramana Paul M. Ed 25/04/90 Male 19,000
Gatwiri Everlyn B. Ed 11/11/92 Female 60,000
Ruth Wangeci BBIT 31/01/92 Female 16,000
Harrison Mundia B. Ed 2/01/89 Male 22,000
Musyoka Ruth B. Ed 31/01/92 Female 36,000
Mwenda Sylivia BBIT 19/08/94 Female 41,000
Reuben Gichana M. Ed 11/05/92 Male 56,000
Mutio Mary Mwikali B. Ed 31/12/91 Female 60,000
Karanja Kelvin BBM 26/11/92 Male 60,000

Required
1. Create a data entry form in design view and apply your own
design in the form
2. Enter the above records using the form above
3. The semesters fees is 60,000 Kshs. Produce a list of
students who have cleared the fees
4. Produce a list of Female students taking a course in education
5. Produce a list of students who were born before the year 1990
6. Product a report that will show the current students
grouping them by their respective courses
7. Prepare a report showing a list of students who have cleared their fees
8. Prepare a macro that will open no 3 above and open the report on 7
above.

You might also like