Learning Guide: Tour Service Level III
Learning Guide: Tour Service Level III
Learning Guide
Tour Service Level III
Unit of CompetenCe: Design and Update Databases
1
Information Sheet #1 LO1: Design Database
Introduction
This learning guide is developed to provide you the necessary information regarding the
following content coverage and topics:
Introduction to database
Database Design Principles
Database Software Functions
This learning Guide will also assist you to attain the learning outcome stated in the cover page.
Specifically, upon completion of this Learning Guide, you will able to:
Learning Activities
2
Definition of Database:-
From this definition of Database, it is important to understand each part of this definition.
A database is Self-describing
This implies database contains, in addition to the user source data, a description of its own
structure. This description is called a Data Dictionary (also called a metadata).
Database
Database includes:-Files of user data, Description of itself in
the metadata, indexes that are used to represent relationships among the data and Application
Metadata (the structure of data entry form, or report).
3
Basically Commercial (Such as Oracle, DB2, Microsoft SQL Server etc) will cost money
where as Non- commercial (Mini SQL, MYSQL, embedded Java DB) are “free” or at
least open source. They are developed in different ways and come with different levels of
support. If you want extra support you are able to buy a support contract even with open
source.
4
Gather all of the types of information you might want to record in the database, such as
product name and order number.
Divide your information items into major entities or subjects, such as Products or Orders.
Each subject then becomes a table.
Decide what information you want to store in each table. Each item becomes a field, and
is displayed as a column in the table. For example, an Employees table might include
fields such as Last Name and Hire Date.
Choose each table’s primary key. The primary key is a column that is used to uniquely
identify each row. An example might be Product ID or Order ID.
Look at each table and decide how the data in one table is related to the data in other
tables. Add fields to tables or create new tables to clarify the relationships, as necessary.
Analyze your design for errors. Create the tables and add a few records of sample data.
See if you can get the results you want from your tables. Make adjustments to the design,
as needed.
Apply the data normalization rules to see if your tables are structured correctly. Make
adjustments to the tables, as needed.
Example:-
Highline College is a small liberal arts college in the Midwest. Its student’s activities department
sponsors intramural athletic leagues, but it has a problem of keeping a track of the athletic
equipment that has been checked out to various team captains.
5
Operation Sheet #1 Create a Simple Database
Design the possible database for the above college to keep track of data
Solution
Keeping track of the athletic equipment that has been checked out to various team
captains.
Step 2) Information Required
The following information are required to keep track of athletic equipments that has been
checked out.
CaptainName , Phone, Street, City, State, Zip, Quantity, Description, Quantity , DateOut, DateIn
Step3) Divide the information in to tables
Here we have two Entities:
CAPTAIN and ITEM
Thus we need two tables i,e
ITEM table and CAPTAIN table
Step4) turn information into Columns
ITEM( Quantity, Description, DateIut, DateIn)
CAPTAIN(CaptainName, Phone, Street, City, Zip)
Each table should include a column or set of columns that uniquely identifies each row stored in
the table. This is often a unique identification number, such as an Captain_ID or a serial number.
In database terminology, this information is called the primary key of the table. Access uses
primary key fields to quickly associate data from multiple tables and bring the data together for
you.
If you already have a unique identifier for a table, such as a product number that uniquely
identifies each product in your catalog, you can use that identifier as the table’s primary key —
but only if the values in this column will always be different for each record.
You cannot have duplicate values in a primary key. For example, don’t use people’s
names as a primary key, because names are not unique. You could easily have two people
with the same name in the same table.
A primary key must always have a value. If a column's value can become unassigned or
unknown (a missing value) at some point, it can't be used as a component in a primary key.
6
You should always choose a primary key whose value will not change. In a database that uses
more than one table, a table’s primary key can be used as a reference in other tables. If the
primary key changes, the change must also be applied everywhere the key is referenced. Using a
primary key that will not change reduces the chance that the primary key might become out of
sync with other tables that reference it.
Often, an arbitrary unique number is used as the primary key. For example, you might assign
each order a unique order number. The order number's only purpose is to identify an order. Once
assigned, it never changes.
If you don’t have in mind a column or set of columns that might make a good primary key,
consider using a column that has the AutoNumber data type. When you use the AutoNumber
data type, Access automatically assigns a value for you. Such an identifier is factless; it contains
no factual information describing the row that it represents. Factless identifiers are ideal for use
as a primary key because they do not change. A primary key that contains facts about a row — a
telephone number or a customer name, for example — is more likely to change, because the
factual information itself might change
Accordingly, We need a primary key that uniquely identifies CAPTAIN table and another
primary key that uniquely identifies ITEM table.
Captain_ID for CAPTAIN table
Item_ID for ITEM table are used as primary keys
Thus the tables become
ITEM( ITEM_ID, Quantity, Description, DateIut, DateIn)
CAPTAIN(CAPTAIN_ID, CaptainName, Phone, Street, City, Zip)
The relationship between these two tables is as follows: One row of CAPTAIN relates to many
rows of ITEM, but a row of ITEM relates to one, and only one, row of CAPTAIN(1:N)
For the table shown above, there is no way to tell which row of CAPTAIN relates to which rows
of ITEM. Therefore, to show that relationship, we add CAPTAIN_ID to ITEM.
7
Information Sheet #2 LO2: Develop Database
When you start Office Access 2007 by clicking the Windows Start button or a desktop shortcut
(but not when you click on a database), the Getting Started with Microsoft Office Access page
appears. This page shows what you can do to get started in Office Access 2007.
8
For example, you can create a new blank database, create a database from a template, or open a
recent database (if you have opened some databases before). You can also go directly to
Microsoft Office Online to learn more about 2007 Microsoft Office system and Office Access
2007, or you can click the Microsoft Office Button and use the menu to open a existing
database.
2. On the Getting Started with Microsoft Office Access page, under New Blank
Database, click Blank Database.
3. In the Blank Database pane, in the File Name box, type a file name or use the one that
is provided for you.
4. Click Create.
The new database is created, and a new table is opened in Datasheet view.
Office Access 2007 provides a number of templates with the product, and you can download
more from Microsoft Office Online. What is a template? In the context of Office Access 2007, it
is a predesigned database complete with professionally designed tables, forms, and reports.
Templates give you a big head start when you create a new database.
Based on the database design the following database objects can be created
9
Reports allow you to print data based on queries/tables that you have
created
A table contains data about a particular subject, such as employees or products. Each record in a
table contains information about one item, such as a particular employee. A record is made up of
fields, such as name, address and telephone number. A record is also commonly called a row,
and a field is also commonly called a column.
1) Record or records
2) Field or column
Your database can contain many tables, each storing information about a different subject. Each
table can contain many fields of different types, including text, numbers, dates, and pictures.
The following list shows some common examples of tables you might create.
A customers table that lists your company’s customers and their addresses
A catalog of products you sell, including prices and pictures for each item
A tasks table that tracks tasks and due dates
An inventory of equipment or stock on hand
You should plan and design your database carefully to ensure its correctness and to avoid having
to make too many changes later. For information about planning and designing your database,
see the article Database design basics.
10
Create a new table
A simple database, such as a contact list, might use only a single table. Many databases,
however, use several tables. When you create a new database, you create a new file on your
computer that acts as a container for all of the objects in your database, including your tables.
You can create a table by creating a new database, by inserting a table into an existing database,
or by importing or linking to a table from another data source — such as a Microsoft Office
Excel 2007 workbook, a Microsoft Office Word 2007 document, a text file, or another database.
When you create a new blank database, a new empty table is automatically inserted for you. You
can then enter data to start defining your fields.
2. In the File Name box, type a file name. To change the location, click the folder icon to
browse.
3. Click Create.
The new database is opened, and a new table named Table1 is created and opened in
Datasheet view.
11
A new table is inserted in the database and the table is opened in Datasheet view.
The following table describes the data types available for fields in Office Access 2007.
12
that each value stored includes both a
date component and a time component.
Lookup Wizard Not actually a data type; instead, this Table or query based: The
invokes the Lookup Wizard. size of the bound column.
Use to start the Lookup Wizard so you Value based: The size of
can create a field that uses a combo the Text field used to store
box to look up a value in another table, the value
query or list of values.
NOTE:-For phone numbers, part numbers, and other numbers that you don’t intend to use for
mathematical calculations, you should select the Text data type, instead of the Number data type.
For the Text and Number data types, you can specify the field size or data type more specifically
by setting the FieldSize property.
14
Operation Sheet #5 Entering Data in a Table
onto a datasheet from the Field List pane. When you create a relationship between tables, the
common fields are not required to have the same names, although it is often the case that they do.
15
Rather, those fields must have the same data type. If the primary key field is an AutoNumber
field, however, the foreign key field can be a Number field if the FieldSize property of both
fields is the same. For example, you can match an AutoNumber field and a Number field if the
FieldSize property of both fields is Long Integer. When both common fields are Number fields,
4. If you have not yet defined any relationships, the Show Table dialog box automatically
appears. If it does not appear, on the Design tab, in the Relationships group, click Show
Table.
The Show Table dialog box displays all of the tables and queries in the database. To see
only tables, click Tables. To see only queries, click Queries. To see both tables and
16
5. Select one or more tables or queries and then click Add. When you have finished adding
6. Drag a field (typically the primary key) from one table to the common field (the foreign
key) in the other table. To drag multiple fields, press the CTRL key, click each field, and
7. Verify that the field names shown are the common fields for the relationship. If a field
name is incorrect, click the field name and select a new field from the list.
To enforce referential integrity for this relationship, select the Enforce Referential
Integrity check box. For more information about referential integrity, see the
8. Click Create.
The relationship line is drawn between the two tables. If you selected the Enforce
Referential Integrity check box, the line appears thicker at each end. In addition, again
only if you selected the Enforce Referential Integrity check box, the number 1 appears
over the thick portion of the line on one side of the relationship, and the infinity symbol
(∞) appears over the thick portion of the line on the other side.
17
NOTES
primary key and foreign key fields) must have a unique index. This means the
Indexed property for these fields should be set to Yes (No Duplicates). If both fields
To create a one-to-many relationship The field on the "one" side (typically the
primary key) of the relationship must have a unique index. This means the Indexed
property for this field should be set to Yes (No Duplicates). The field on the "many"
side should not have a unique index. It can have an index, but it must allow
duplicates. This means the Indexed property for this field should be set to either No,
or Yes (Duplicates OK). When one field has a unique index and the other does not,
18
In Office Access 2007, you can add a field to an existing table that is open in Datasheet view by
dragging it from the Field List pane. The Field List pane shows fields available in related tables
and also fields available in other tables. When you drag a field from an "other" (unrelated) table
and then complete the Lookup Wizard, a new one-to-many relationship is automatically created
between the table in the Field List pane and the table to which you dragged the field. This
relationship, created by Access, does not enforce referential integrity by default. To enforce
referential integrity, you must edit the relationship. See the section Change a table relationship
3. In the Navigation pane, right-click the table to which you want to add the field and create
On the Datasheet tab, in the Fields & Columns group, click Add Existing Fields.
19
The Field List pane shows all of the other tables in your database, grouped into categories.
When you work with a table in Datasheet view, Access displays fields in either of two categories
in the Field List pane: Fields available in related tables and Fields available in other tables.
The first category lists all of the tables that have a relationship with the table you are currently
working with. The second category lists all of the tables with which your table does not have a
relationship.
In the Field List pane, when you click the plus sign (+) next to a table name, you see a list of all
the fields available in that table. To add a field to your table, drag the field that you want from
Add a field and create a relationship from the Field List pane
1. On the Datasheet tab, in the Fields & Columns group, click Add Existing Fields.
2. Under Fields available in other tables, click the plus sign (+) next to a table name to
3. Drag the field that you want from the Field List pane to the table that is open in
Datasheet view.
20
The Lookup Wizard starts.
When you drag a field from an "other" (unrelated) table and then complete the Lookup Wizard, a
new one-to-many relationship is automatically created between the table in the Field List and the
table to which you dragged the field. This relationship, created by Access, does not enforce
referential integrity by default. To enforce referential integrity, you must edit the relationship.
21
115 Muhammad Yasin M 25 4831 HRM
116 Ephrem Ayle M 28 1450 HRM
117 Ibrahim Kedir M 30 800 HRM
118 Dejene Bayle M 27 2500 HRM
119 Million Kassa M 28 1900 HRM
200 Yohannes Wedajo M 25 2100 HRM
Instruction
8. logo(any picture)
10. Add 4 buttons and rename with Print, Delete record, Add record ,search record
22
Information Sheet #2 LO3: DEVELOP QUERIES, FORMS AND REPORTS
Introduction
This learning guide is developed to provide you the necessary information regarding the
following content coverage and topics:
This learning Guide will also assist you to attain the learning outcome stated in the cover page.
Specifically, upon completion of this Learning Guide, you will able to:
Learning Activities
CREATING QUERIES
23
You use Queries to view, change, and analyze data in different ways. You can also use them as a
To Create a Query:
4) Select the table that you would like to base your Query on
5) Click Add
The table(s) will now be displayed in the upper part of the Query Design Screen by boxes
7) Double click on the field names in the field list window which you would like to include in
the Query
In order to control which records are displayed, you must define criteria in a Query. The most
common type of Query is the Select Records Query which will be discussed below.
1) Position your cursor in the criteria row in the field for which you wish to define the criteria for
24
Position your cursor in the criteria row of the City field
• Type Edison
3) Click Forms
You are able to navigate using the navigation arrows at the bottom of the form.
Note: The form feeds the table. If you edit a record on the form, or create a
25
new record, that data will be passed to the table it is associated with.
1) Click the View button on the Ribbon to switch from Layout View to Form View
2) Enter the data for each field in the record, pressing the Enter key to move to the next field
3) Press Enter after you have entered data for the last field
EXERCISE:
Check the update on your table after entering data using form
2.3) Reports
Reports can be based on tables or queries and can be made with the Report Wizard.
26
To Create a Report Using the Report Wizard:
3) Select the table or query upon which the report will be based
4) Select the fields that you want to include on the report by double clicking on them
5) Click Next
6) If you would like to add grouping to your report, select the field you wish to group by double
7) Click Next
9) Click Next
27
You count data by using a totals query instead of a Total row when you need to count some or all
of the records returned by a query. For example, you can count the number of sales transactions,
or the number of transactions in a single city.
Typically, you use a totals query instead of a Total row when you need to use the resulting value
in another part of your database, such as a report.
2. In the Show Table dialog box, double-click the table that you want to use in your query,
and then click Close.
The table appears in a window in the upper section of the query designer.
3. Double-click the fields that you want to use in the query, and make sure you include the
field that you want to count. You can count fields of most data types, the exception being
fields that contain complex, repeating scalar data, such as a field of multivalued lists.
The Total row appears in the design grid and Group By appears in the row for each
field in the query.
5. In the Total row, click the field that you want to count and select Count from the
resulting list.
28
Operation Sheet #4 Count Records in a Group or Category
2. In the Show Table dialog box, double-click the table or tables that you want to use in
your query, and then click Close.
The table or tables appear in a window in the upper section of the query designer.
3. Double-click the field that contains your category data, and also the field that contains
the values that you want to count. Your query cannot contain other descriptive fields.
The Total row appears in the design grid and Group By appears in the row for each
field in the query.
5. In the Total row, click the field that you want to count and select Count from the
resulting list.
The following table lists and describes the aggregate functions that Access provides for use in
the Total row and in queries. Remember that Access provides more aggregate functions for
29
queries than it does for the Total row. Also, if you work with an Access project (an Access front
end connected to a Microsoft SQL Server database), you can use the larger set of aggregate
functions that SQL Server provides. For more information about that set of functions, see
Microsoft SQL Server Books Online.
Sum Adds the items in a column. Works only Number, Decimal, Currency
on numeric and currency data.
Count Counts the number of items in a All data types except those
column. containing complex repeating
scalar data, such as a column of
multivalued lists.
Maximum Returns the item with the highest value. Number, Decimal, Currency,
For text data, the highest value is the Date/Time
last alphabetic value and Access ignores
case. The function ignores null values.
Minimum Returns the item with the lowest value. Number, Decimal, Currency,
For text data, the lowest value is the Date/Time
first alphabetic value and Access
ignores case. The function ignores null
values.
Standard Measures how widely the values are Number, Decimal, Currency
Deviation dispersed from an average value (a
mean).
30
totals in a datasheet.
31
The result of a query is called a record set. A record set can be sorted, printed or filtered in the
3) Click OK
32
202 1549 15 65
203 4789 14 65
301 4859 10 65
302 7896 12 65
303 1478 10 65
Create the following tables: save the table as Item List Table
Item Item Type Quantity Cost per Total VAT Transport cost Net
ID unit cost income
200 Dell desktop pc 25 15000
201 Toshiba A665 14 14550
202 Toshiba L555 16 16000
203 Toshiba C655 18 11000
204 Scanner 50 5450
205 HP printer 2022 41 5000
206 HP printer 4055 41 8450
207 Accer Desk top 80 9500
208 HP Laptop 78 15000
209 Server pc 1 120000
300 HP Mini Laptop 12 7000
301 DVD 855 20
1. Create Query which calculated the following fields
Total cost=Quantity * Cost per unit
VAT=15 of Total cost
Transport cost 1.2 % of total cost
Net income=Total cost-VAT
2. Create a query which displays Item ID, Item Type and Total cost in Query design
3. Create a query which displays Item ID, Item Type, VAT, Transport cost in Query design
4. Create a query which displays Item ID, Item Type ,Transport cost And Net income in Query design
5. Create a query which displays Item ID and Item Type and quaintly in Query design
33
Information Sheet #3 LO4: TEST AND FINALIZE DATABASE
3) Use database
After creating the table, queries, forms and reports, we can store and access the database as we
need
To Print a Report
1) Open the report by double clicking on the object in the Navigation Pane
3) Click OK
34
Self check Test#3 Use Database
35