You are on page 1of 19

INFORMATION

TECHNOLOGY SUPPORT
SERVICE
Level II

LEARNING GUIDE # 1
Unit of Competence: Operate Database Application
Module Title: Operating Database
Application
LG Code: EIS ITS2 LO1 01
TTLM Code: EIS ITS2 TTLM 0511

LO 1 Create database objects


This learning guide was developed to provide you the necessary information regarding the following
content coverage and topics –

 Opening and designing DB application and principles


 Creating DB objects

This guide will also assist you to attain the learning outcome stated in the cover page. Specifically,
upon completion of this Learning Guide, you will be able to –

 Open and design database application incorporating basic design principles


 Create database object according to database usage, as well as user requirements
 Modify database object as required
 Add and modify data in a table according to information requirements
 Add, modify and delete records as required
 Save and compile database objects
Introduction
Database
What is database?

A database can best be described as a way of storing large amounts of


information. The data can be retrieved and we can even ask questions of the data and
get answers.
What is database explain?

A database is an organized collection of structured information, or data, typically stored


electronically in a computer system. A database is usually controlled by a database management system
(DBMS).
For example you may want to know how many Students enrolled in every
occupational level.

MS Access is the one family of Microsoft office used to store and manage data
MS Access is a database management tool that enables one to store
relevant data. This also has the capabilities to retrieve, sort, summarize
and report results immediately and effectively. It can combine data from
various files (tables) through creating relationships, and can make data
entry more efficient and accurate through the use of forms.

Microsoft Access (MS Access) enables one to manage all important


information from a single database file. Within the file, one can use the different
objects:

 Tables - A table is a collection of data about a specific topic, such as products


or suppliers. Using a separate table for each topic means that you store that data
only once. This results in a more efficient database and fewer data-entry errors.

 Queries - You use queries to view, change, and analyze data in different ways.
You can also use them as a source of records for forms, reports, and data access
pages.

 Forms - A form is a type of a database object that is primarily used to enter or


display data in a database. You can also use a form as a switchboard that opens
other forms and reports in the database, or as a custom dialog box that accepts
user input and carries out an action based on the input.
 Reports - A report is an effective way to present your data in a printed format.
Because you have control over the size and appearance of everything on a
report, you can display the information the way you want to see it

 Modules - A module is essentially a collection of declarations, statements, and


procedures stored together as one named unit to organize your Microsoft Visual
Basic code. Microsoft Access has two types of modules: standard modules and
class modules.

 Data access pages - A data access page is a special type of Web page designed
for viewing and working with data from the Internet or an intranet— data that is
stored in a Microsoft Access database or a Microsoft SQL Server database. The
data access page may also include data from other sources, such as Microsoft
Excel.

In MS Access, data is stored once in one table, but can be viewed from multiple
locations. When the data is updated in a Table, Query or Form, it is automatically
updated everywhere it appears.

Establishment of Ms Access database


All MS Access databases files are saved with extension .mdb or accdb. A
database should have a separate table for every major subject, such as Students
records, Students grades, etc..
Database has an entity and entity also has different attributes.

Example School is a database

Student is an entity or table.

Student id (SID), Name, Sex, Age, and Department are attributes or field or column
or data.

 S01, Melat, Female, 18, IT is Record - Row - Information

Practice

1. Start MS Access

Start---------- all programs----------Microsoft office ---------- MS access


2. Create Database

Type the database name.

Example School
3. Create table
Table is an entity of database.
Example in School database there is many entity or table like Student,
department, Teacher, Register
How to create table?

Click Create tab--------- click table.

Then Right click on table (on left side table) --------- Design view ------- type
the name of the table.

Give table name as Student.


Before we proceed to creating your first table, we need to know first the
basic components of a table:
 Meta Data – Database Structure
 Field – Column – Data
 Fieldname
 Record - Row - Information

4. Field – Column – Data


Student columns are Student id (SID), FirstName, LastName, Age,
Sex, and department.
Data type means the behavior or type of data.
Example
 ID-----Auto Number
 Name------text
 Age ------number
 Salary -----Currency
 Birth date ----Date/ Time

5. Record - Row - Information


Record information based on the following table

Table:-Student

SID FirstName LastName Age Sex Department


1 Melat Hailu 18 F ICT
2 Solomon Cherenet 20 M Accounting
3 Hayat Ahmed 19 F Marketing
4 Lemisa Abera 19 M ICT
Save

Right click on table……. Open.

Basic Database Concept: In studying MS Access, it is but necessary to understand some basic
elements of a database before proceeding to it.

Database Elements:

 Data are raw facts. It tells the truth about something;a person, a place, an object, etc.
Example:
(1) “Robel” is a data.“Noel” is my name, so it tells something about a person. “Robel” is a
Name
Name Robel

(2) “Male” is Robel’s gender. So it tells something about “Robel”. Noel is Male.
Gender
Male
 Information is a collection of data (raw facts) which is contained in
1 file (table in Access)
Example:
IDNumber LName FName Mname Gender Bday Address
MOE-0001 Zelalem Robel Abel Male 11-05-1978 Aratkilo
(this is an information about a person named “Noel”)

Example of a table (file):


IDNumber LName FName Mname Gender Bday Address
MOE-0001 Zelalem Robel Abel Male 11-05-1978 Aratkilo
MOE-0002 Panganiban Mark Perez Male 11-05-1978 Magadanga
File MOE-0003 Cerna Patrick Santos Male 11-05-1978 Aratkilo
MOE-0004 Hipolito Valder Cruz Male 11-05-1978 Sidiskilo
MOE-0005 Ohmy Diana Antonio Female 11-05-1978 Aratkilo

Naming Convention
Is manner of naming files and variables. Having a poor naming convention can only add
confusion, so it's important that you start with a good scheme, and think about what the scheme will
mean to you. Here are the three things to consider in establishing a naming convention:

1. Does my convention make sense to me?  


 Is must be simple and understandable to you.
2. Will my convention make sense to other people? 
 Time will come that other people will look into your database program, so they must
able to understand it.
3. Can I be consistent in implementing and enforcing my convention? 
 All throughout my database work, your naming convention must not change.

General 
Here are some basic simple rules when it comes to the name of any object in a database
(including the name of the database itself): 
 Do not use spaces in object names. It might seem tempting and cute to have a view named
"Sales By Quarter," but this is a nightmare to deal with programmatically. Instead write it as
“SalesByQuarter” or “SalesByQtr” or “QtrlySales”
 Avoid using reserved words.This is easier said than done, as there is a very large list of
current and future reserved words to check against. Example: do not name your file as
“Date” because “Date” is a reserve word in Ms Access.
 Do not use dashes in database names.Dash “-“ was often recognized by a computer as an
operator (subtraction), so instead of naming your object as “Quarterly-Sales” better name it
as QuarterlySales” or better use underscore instead of a dash“Quarterly_Sales”.
 Start object names with a letter.I see table named "2005_Sales" and columns and columns
named "1", "2," "3," and so on (to represent months). Ms Access might treat it as a number
and not as a filename.
 Keep names short but meaningful.This is self-explanatory and fairly logical,"SlQ" is too
short. “SalesFiguresForCompanyByFiscalQuarter" is just silly. 

Tables may be created by either:


 Table wizard
 Design view
Creating Tables using design view
Creation of a table by design view is a user customized way of making data storage tables.
Each field in the design view of a table corresponds to a column in the datasheet view of atable.

Designing a table involves:

 Entering unique names of the columns of the table in the “field name” column of the
design view. Names of fields and objects in Microsoft Access can be up to 64characters long. They
can include any combination of letters, numbers, spaces, andspecial characters except a period (.), an
exclamation point (!), an accent grave (`), andbrackets ([ ]). They also can't begin with leading spaces
 Primary Key is the unique identification of one record. It will not allow a duplication of the
Primary Key thus make it unique. Define a Primary Key field (You don't have to define a primary
key, but it's usually a good idea. If you don't define a primary key, Microsoft Access asks if you want
Access to create one for you when you save the table)
Example ID

Data Types

When creating a table, one will need to specify what kinds of data are to be stored in this
field.

The different kinds of MsAccess2003 data types are:

 Text: allows for the storage of any kind of data, characters, digits and special
characters. It has a defect length of 50 characters with a maximum length of 255. It is
normally used to store data such as names, addresses, or any number not used in
calculations, like telephone numbers or zip codes.

 Memo: is used for texts of more than 255 characters such as comments or
explanations. It has a maximum length of 65.536 characters. Access recommends that
to store formatted text or large documents, rather to create an OLE Object field than a
Memo field.

In Access2003 it is possible to arrange or group in a Memo field, but Access only uses
the first 255 characters when it arranges or groups in a Memo field.

 Byte, Integer and Long Integer allow the storage of numbers without decimals;
the types Single, Double and Decimal allow decimals; the type Replication ID is
used for auto-numerical codes in replication databases.

 Date/Time: for the introduction of date and time from the year 100 to 9999.

 Currency: For monetary values and numerical data used in mathematical calculations
in which the data involved contains between one and four decimals. The accuracy is
up to 15 digits to the left of the decimal separator and up to 4 digits to the right of the
same.

 Access recommends the use of Currency type to avoid the rounding off of
numbers in calculus. A Currency field has an accuracy of up to 15 digits to the left of
the decimal separator and 4 digits to the right. A Currency field occupies 8 bytes of
space on disc.

 Autonumber: a unique sequential number (increasing one by one), or an aleatory


number that Access assigns every time it adds a new record to a table. Auto-number
fields cannot be updated.

 Yes/No:Yes and No values, and fields that contain one of two values (Yes/No,
True/False or Activated / Dis activated).

 OLE Object: an object such as a Microsoft Excel spreadsheet, a Microsoft Word


document, graphics, images, sounds, or other binaries.

 Hyperlink: text or a combination of text and numbers stored as text and used as
a hyperlink address. A Hyperlink is a text or graphic that you click to go to a file,
a location in a file, a web page on the Internet, or a web page on an
intranet.umber: for numerical data used in mathematical calculations. Within the
number type we are able to specify the size property of the field. The types Byte,
Integer and Long Integer allow the storage of numbers without decimals; the types
Single, Double and Decimal allow decimals; the type Replication ID is used for auto
numerical codes in replication databases.

Practice/ Exercise

Create Database Name as School

Create Table

1. Student with field name SID, FullName, Age, Sex, Department, Grade

2. Teacher with field name TID, FullName, Department

3. Department with field name DID, DepartmentName

4. Course with field name Ccode, CourseName

Example

SID FullName, Age Sex Department Grade

1 Woinshet Berihanu Zelalem 18 Female ICT Level 2


LO 1 MS Access - Query Data
A query is a request for data results, and for action on data. You can use a query to answer a
simple question, to perform calculations, to combine data from different tables, or even to
add, change, or delete table data.
 As tables grow in size they can have hundreds of thousands of records, which makes it
impossible for the user to pick out specific records from that table.

 With a query you can apply a filter to the table's data, so that you only get the
information that you want.

 Queries that you use to retrieve data from a table or to make calculations are called
select queries.

 Queries that add, change, or delete data are called action queries.

 You can also use a query to supply data for a form or report.

 In a well-designed database, the data that you want to present by using a form or
report is often located in several different tables.

 The tricky part of queries is that you must understand how to construct one before you
can actually use them.

Create Select Query


If you want to review data from only certain fields in a table, or review data from multiple tables
simultaneously or maybe just see the databased on certain criteria, you can use the Select query. Let us now
look into a simple example in which we will create a simple query which will retrieve information from
tblEmployees table. Open the database and click on the Create tab.

Click Query Design.


In the Tables tab, on the Show Table dialog, double-click the tblEmployees table and then Close the dialog
box.

In the tblEmployees table, double-click all those fields which you want to see as result of the query. Add
these fields to the query design grid as shown in the following screenshot.
Now click Run on the Design tab, then click Run.

The query runs, and displays only data in those field which is specified in the query.

In MS Access and other DBMS systems, queries can do a lot more than just displaying
data, but they can actually perform various actions on the data in your database.
 Action queries are queries that can add, change, or delete multiple records at one time.

 The added benefit is that you can preview the query results in Access before you run it.

 Microsoft Access provides 4 different types of Action Queries −

 Append

 Update

 Delete

 Make-table
 An action query cannot be undone. You should consider making a backup of any tables that you will
update by using an update query.

Create an Append Query


You can use an Append Query to retrieve data from one or more tables and add that data to another table.
Let us create a new table in which we will add data from the tblEmployees table. This will be temporary
table for demo purpose.

Let us call it TempEmployees and this contains the fields as shown in the following screenshot.
In the Tables tab, on the Show Table dialog box, double-click on the tblEmployees table and then close the
dialog box. Double-click on the field you want to be displayed.

Let us run your query to display the data first.


Now let us go back to Query design and select the Append button.

In the Query Type, select the Append option button. This will display the following dialog box.

Select the table name from the drop-down list and click Ok.
In the Query grid, you can see that in the Append To row all the field are selected by default except
Address1. This because that Address1 field is not available in the TempEmployee table. So, we need to
select the field from the drop-down list.

Let us look into the Address field.


Let us now run your query and you will see the following confirmation message.

Click Yes to confirm your action.

When you open the TempEmployee table, you will see all the data is added from the tblEmployees to the
TempEmployee table.
Relationships
Defining Relationships
A relationship works by matching data in key columns usually columns with the same name in both the
tables. In most cases, the relationship matches the primary key from one table, which provides a unique
identifier for each row, with an entry in the foreign key in the other table. There are three types of
relationships between tables. The type of relationship that is created depends on how the related columns
are defined.

Let us now look into the three types of relationships −

One-to-Many Relationships
A one-to-many relationship is the most common type of relationship. In this type of relationship, a row in
table A can have many matching rows in table B, but a row in table B can have only one matching row in
table A.

For example, the Customers and Orders tables have a one-to-many relationship: each customer can place
many orders, but each order comes from only one customer.

Many-to-Many Relationships
In a many-to-many relationship, a row in table A can have many matching rows in table B, and vice versa.

You create such a relationship by defining a third table, called a junction table, whose primary key consists of
the foreign keys from both table A and table B.

For example, the Customers table and the Cookies table have a many-to-many relationship that is defined by
a one-to-many relationship from each of these tables to the Orders table.

One-to-One Relationships
In a one-to-one relationship, a row in table A can have no more than one matching row in table B, and vice
versa. A one-to-one relationship is created if both the related columns are primary keys or have unique
constraints.

This type of relationship is not common because most information related in this way would be all in one
table. You might use a one-to-one relationship to −

 Divide a table into many columns.


 Isolate part of a table for security reasons.
 Store data that is short-lived and could be easily deleted by simply deleting the table.
 Store information that applies only to a subset of the main table.

You might also like