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

DATABASES

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

DATABASES

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 23

TOPIC 5.

1 DATABASES

Specific Objectives:

By the end of the sub- module unit, the trainer should be able to:

a) Explain Database concepts

b) Describe database design concepts

c) Describe database objects

d) Explain the procedure of printing database objects.

5.1.1 Database concepts:

Definition of a database

A database is a collection of related data in such a way that it reduces


data redundancy and inconsistence by minimizing isolated files in
which the same data is repeated.

It is managed by the management Database Management System


(DBMS).

Advantages of using database:

1. It reduces data reduces data redundancy

2. Eliminates duplication to data

3. It saves a lot of time in searching for information

4. reduces the cost of storage


Disadvantages of databases

1. It requires a lot of time at the first time of constructing

2. it requires use of a computer

3. it requires a computer knowledge

5.1.2 Database models:

It is the arrangement of the data.

1. Relational Database model

It is based on data in rows and columns (tables). Two-


dimensional tables. Each table contains data on an entity and its
attributes. An example is Microsoft Access for desktop systems.

2. Hierarchical database model

Arranges data from top to bottom

3. Network database model

5.1.3 Database design concepts:

Referential integrity

Are rules the ensure that relationships between coupled tables remain consistent

Relationships

This is an association between two or more tables.

Before you come up with a database several considerations need to be taken into account so that
one can develop a good database.
What is good database design?

Certain principles guide the database design process. The first principle is that duplicate
information (also called redundant data) is bad, because it wastes space and increases the
likelihood of errors and inconsistencies. The second principle is that the correctness and
completeness of information is important. If your database contains incorrect information, any
reports that pull information from the database will also contain incorrect information. As a
result, any decisions you make that are based on those reports will then be misinformed.

A good database design is, therefore, one that:

Divides your information into subject-based tables to reduce redundant data.

Provides Access with the information it requires to join the information in the tables
together as needed.

Helps support and ensure the accuracy and integrity of your information.

Accommodates your data processing and reporting needs.

The design process

The design process consists of the following steps:


Determine the purpose of your database
This helps prepare you for the remaining steps.
Find and organize the information required
Gather all of the types of information you might want to record in the database, such as
product name and order number.
Divide the information into tables
Divide your information items into major entities or subjects, such as Products or Orders.
Each subject then becomes a table.
Turn information items into columns
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.
Specify primary keys
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.
Set up the table relationships
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.
Refine your design
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 normalization rules
Apply the data normalization rules to see if your tables are structured correctly. Make
adjustments to the tables, as needed.

5.1.4 Database objects

A database is a collection of information that is related. Access allows you to manage your
information in one database file. Within Access there are four major objects: Tables, Queries,
Forms and Reports.

Tables – store data in rows and columns. In a table, each row is a record, and each record
consists of one or more fields

Forms – function as user-friendly interfaces for working with data

Reports – print and summarize data

Queries – extract subsets of data from one or more tables, allowing you to view exactly the data
you want

Macros – add functionality to database objects and are often used to automate certain database
tasks

Modules – also add functionality to a database, and are stored collections of Visual Basic for
Applications (VBA) programming language statements and procedures
5.2.0 Entering Data in a Table

1. In Datasheet View, start typing the data into the table by pressing the tab key to move to
the next cell
2. When you have completed the record (row), press Enter
3. You can also click on the New record icon on the Home tab in the Records group or at the
bottom of the table

Navigating in a Table
Use the arrows at the bottom of the table to navigate among records.

Sorting Records in a Table


1. Position your cursor in the field that you wish to sort by clicking on any record in the table
2. Click either the Sort Ascending or Sort Descending icon on the Home tab in the Sort &
Filter group
5.2.1 Table manipulations:

(i) To insert a row:

Steps:

Open table in design

Click in a row above which you want to insert a row

Design menu

Insert rows

To delete a row:

Steps:

Open the table in design view (Using the above dialog box),

Click the row you want to delete

Design menu

Delete rows

To change the row height:

Open table in datasheet view

Select the rows

Home menu
More

Row height (dialog box)

Type the new height

Ok

5.3 Creating a Database

1. Start Access
2. Click on Blank desktop database
3. Under File Name type a name for the database
4. To change the location of where to store the database, click the folder icon and select a
location
5. Click Create
Access opens in a new table in Datasheet View.
Creating a Table

A table is a collection of data about a specific topic, such as employee information, products or
customers. The first step in creating a table is entering the fields and data types. This can be done
in either Datasheet View or Design View but it is recommended to set up the table in Design
View

To Create a Table in Design View:


1. Click on the Create tab
2. Click on Table
3. Switch over to Design View on the Home tab
4. If prompted to save the table, enter a name and click on OK
5. Type the field names and select the appropriate data type for each field
6. Continue until all fields are added
Note: The order that you enter the field names is the order the fields will appear in the table.

Understanding Views
There are multiple ways to view a database object. The two views for tables are Design View
and
Datasheet View.
 Design View is used to set the data types, insert or delete fields, and set the Primary Key
 Datasheet View is used to enter and view the data for the records
Switching Between Design View and Datasheet View:
Click the View arrow on the Home tab and click on either Datasheet View or Design View

Understanding Fields and Their Data Types


Field - an element of a table that contains a specific item of information, such as a last name.
Field’s Data Type - determines what kind of data the field can store.
Format Use to display
Short Text Alphanumeric data (names, titles, etc.) - up to 255 characters
Long Text Large amounts of alphanumeric data: sentences and paragraphs – 64,000 characters
Number Numeric data
Date/Time Dates and times
Currency Monetary values
AutoNumber Unique value generated by Access for each new record
Yes/No Yes and No values and fields that contain only one of two values
Pictures, graphs, or other ActiveX objects from another Windows-based
OLE Object
application
Hyperlink A link address to a document or file on the Internet
You can attach files such as pictures, documents, spreadsheets, or charts; each
Attachment field can contain an unlimited number of attachments per record, up to
Attachment
the
storage limit of the size of a database file.
You can create an expression that uses data from one or more fields. You can
Calculated
designate different result data types from the expression.
Displays either a list of values that is retrieved from a table or query, or a set of
values
Lookup that you specified when you created the field. The Lookup Wizard starts and you
Wizard can
create a Lookup field. The data type of a Lookup field is either text or number,
depending on the choices that you make in the wizard.
Setting a 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. When creating a new table, Access automatically creates
a field “ID” with the autonumber data type, and assigns this as the Primary Key.

To Set a Primary Key:


1. In Design View, position your cursor in the field you wish to set as the Primary Key
2. Click the Primary Key button on the toolbar
3. Save the table

5.4 Creating Queries

A query is an object that is used to extract records that fulfil a specified question or criteria. It is
also used to do calculations.

There are many types of queries:

(i) Select query:

It is the most common type of query. It retrieves data from one or more tables and display the
results in a datasheet where you can update the records (with some restrictions). You can also
use a select query to group records and do calculations.

(ii) Parameter query:


It is a query that when run display its dialog box prompting user for information, such as criteria
for retrieving records, or a value you want to insert in a field. Are also handy when used as the
basis for forms, reports and access pages.

(iii) Crosstab queries:

Are used to calculate and restructure data for easier analysis of data.

(iv) Action queries:

An action query is a query that makes changes to or moves many records in just one operation.

a) Delete query: this deletes a group of records from one or more tables

b) Update query : makes a lot of changes to a group of records

c) Append query : adds a group of records in one or more tables.

d) Make-table queries: creates a new query from all or part of the data in the table.

Ways of creating a query

i) Query Design

Creates a new blank query in design view. You can use show table dialog box to add tables or
queries.

(ii) Query wizard;

As with any wizard, the query wizard will prompt user with step by step process, supply fields
from tables and any information necessary until the query is created.

To Create a Query using query design:

1. Click on the Create tab


2. Click on Query Design in the Queries group
3. Select the table that you would like to base your query on
4. Click Add
5. Repeat steps 3 and 4 until all tables are added
6. Close the Show Table window

The table(s) will now be displayed in the upper part of the Query Design Screen by boxes
containing the tables’ fields.
7. Double-click on the field names in the field list window which you would like to include in
the query

Defining Criteria 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.

To Define Criteria for Your Query:


1. Position your cursor in the criteria row in the field for which you wish to define the criteria for
2. Type the criteria
Example: To find all Excel courses:
3. Position your cursor in the criteria row of the Course ID field
4. Type Excel (Access adds the quote marks to the criteria automatically when you tab to the
next column)

5. Click the Run Query button

To Save the Query:


1. Click the Save icon
2. Enter a name for the query
3. Click OK

5.4 Creating a Form


A form is a database object that is used to enter or display one record at a time. It will display a
given record in a given format and good arrangement.

Ways of creating a form:

i) Direct method:

Here all the fields in a given table are used to create the form. It is a very rigid method of
creating a form.

Steps:

Open the table or query on which you are basing the form
Click on the Create tab
Click on Form in the Forms group
A form is created and opens in Layout View.

ii) Blank Form:

It allows the user to select fields from different tables. It solves the problem of rigid in direct
method. The tables must have a relationship.

Steps:
Create menu

Blank Form

Click on show tales

Select on the first table, double click on the field

Select next table, double click on the field

iii) Form Design

This is creating a form from scratch where you enter new fields. It is not based on any table. It is
the most flexible way of creating a form.

Steps:

Create menu

Form design

Click text box

Drag to create a box to contain field and data

Type field name

Open it in form view to type data

Limitation: you can only print the form direct, you cannot store data.
iv) Form Wizard:

Gives steps to follow, user answer questions, supply data required.

Steps:

Create menu

Form wizard

Select table/query

Select fields

Select layout of the form

Select style or autoformat to use

Type the title of the form

Finish.
Advantage: it can be used to construct a form having fields from different tables.

The tables however must have a relationship.

Different Views:
Form View – this view allows you to view, create and edit records

Layout View - this view is similar to Design View but is more visually-oriented in that each
control displays real data. As a result, this is a very useful view for setting the size of controls
or performing many other tasks that affect the visual appearance and usability of the form.

Design View - this view gives you a more detailed view of the structure of the form. You can
see the header, detail, and footer sections for the form. You cannot see the underlying data
while you are making design changes.
5.5 Creating Reports

Reports can be based on tables or queries.


To Create a Report:
1. Open the table or query on which you are basing the report
2. Click on the Create tab
3. Click on Report in the Reports group
A report is created in Layout View.

Different Views:

Print Preview – allows you see what the report would look like on a printed piece of paper

Report View – allows you to see the data without having to display it in Print Preview

Layout View – allows you make design changes while browsing your data

Design View - gives you a more detailed view of the structure of your report
5.6 Procedure of printing database objects:

To print a table

Open the table in datasheet view

File menu

Print (dialog box )

Provide details

Ok
To print a form:

Open the form in form view

File menu

Print (dialog box)

Provide the print details

Ok

To print reports

Select the report

File menu

Print (dialog box)


Provide the details

Ok

You might also like