0% found this document useful (0 votes)
17 views23 pages

DB Principles Lecture 5&6

The document provides an overview of databases and database management systems (DBMS), defining a database as an organized collection of data that can be easily accessed and managed. It outlines the components of a DBMS, including software, hardware, data, procedures, database access language, and users, while also discussing the advantages and types of DBMS. Additionally, it introduces Microsoft Access as a DBMS tool, detailing its components and steps for designing and creating databases.

Uploaded by

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

DB Principles Lecture 5&6

The document provides an overview of databases and database management systems (DBMS), defining a database as an organized collection of data that can be easily accessed and managed. It outlines the components of a DBMS, including software, hardware, data, procedures, database access language, and users, while also discussing the advantages and types of DBMS. Additionally, it introduces Microsoft Access as a DBMS tool, detailing its components and steps for designing and creating databases.

Uploaded by

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

Databases and Database Systems

1. Introduction

A database can be summarily described as a repository for data. This makes


clear that building databases is really a continuation of a human activity that
has existed since writing began; it can be applied to the result of any
bookkeeping or recording activity that occurred long before the advent of the
computer era. However, this description is too vague for some of our
purposes, and we refine it as we go along.

2. Definition

There a many professional definitions about database. A database is a


collection of data that is organized so that its contents can easily be
accessed, managed, and updated. A database is just what the name implies,
a base collection of data. The data is organized in some manner so that the
information contained within the database can be easily retrieved. Some of
the simple databases that you might be familiar with are things like phone
books or student records.

3. Database Management Systems

 A database management system (DBMS) is an aggregate of data,


hardware, software, Procedures, Database Access Language
and users that help an enterprise manage its operational data. The main
function of a DBMS is to provide efficient and reliable methods of data
retrieval to many users.

3.1. Components of Database Management System

A database management system (DBMS) consists of several components.


Each component plays very important role in the database management
system environment. The major components of database management
system are:
 Software
 Hardware
 Data
 Procedures
 Database Access Language
 Users

Software
The main component of a DBMS is the software. It is the set of programs
used to handle the database and to control and manage the overall
computerized database
1. DBMS software itself, is the most important software component
in the overall system
2. Operating system including network software being used in
network, to share the data of database among multiple users.
3. Application programs developed in programming languages such
as C++, Visual Basic that are used to to access database in database
management system. Each program contains statements that request
the DBMS to perform operation on database. The operations may
include retrieving, updating, deleting data etc . The application
program may be conventional or online workstations or terminals.
Hardware

Hardware consists of a set of physical electronic devices such as computers


(together with associated I/O devices like disk drives), storage devices, I/O
channels, electromechanical devices that make interface between computers
and the real world systems etc, and so on. It is impossible to implement the
DBMS without the hardware devices, In a network, a powerful computer with
high data processing speed and a storage device with large storage capacity
is required as database server.
Data

Data is the most important component of the DBMS. The main purpose of
DBMS is to process the data. In DBMS, databases are defined, constructed
and then data is stored, updated and retrieved to and from the databases.
The database contains both the actual (or operational) data and the
metadata (data about data or description about data).

Procedures
Procedures refer to the instructions and rules that help to design the
database and to use the DBMS. The users that operate and manage the
DBMS require documented procedures on hot use or run the database
management system. These may include.
 Procedure to install the new DBMS.
 To log on to the DBMS.
 To use the DBMS or application program.
 To make backup copies of database.
 To change the structure of database.
 To generate the reports of data retrieved from database.

Database Access Language


The database access language is used to access the data to and from the
database. The users use the database access language to enter new data,
change the existing data in database and to retrieve required data from
databases. The user write a set of appropriate commands in a database
access language and submits these to the DBMS. The DBMS translates the
user commands and sends it to a specific part of the DBMS called the
Database Jet Engine. The database engine generates a set of results
according to the commands submitted by user, converts these into a user
readable form called an Inquiry Report and then displays them on the
screen. The administrators may also use the database access language to
create and maintain the databases.
The most popular database access language is SQL (Structured Query
Language). Relational databases are required to have a database query
language.

Users
The users are the people who manage the databases and perform different
operations on the databases in the database system.There are three kinds of
people who play different roles in database system

 Application Programmers
 Database Administrators
 End-Users

Application Programmers

The people who write application programs in programming languages (such


as Visual Basic, Java, or C++) to interact with databases are called
Application Programmer.

Database Administrators

A person who is responsible for managing the overall database management


system is called database administrator or simply DBA.

End-Users

The end-users are the people who interact with database management
system to perform different operations on database such as retrieving,
updating, inserting, deleting data etc.
3.2. Advantages of Database Management Systems

The database management system has promising potential advantages:-

3.2.1. Integrity can be enforced

Integrity of data means that data in database is always accurate, such


that incorrect information cannot be stored in database.

3.2.2. Controlling Redundancy

In file system, each application has its own private files, which cannot
be shared between multiple applications.

3.2.3. Inconsistency can be avoided

When the same data is duplicated and changes are made at one site,
which is not propagated to the other site, it gives rise to inconsistency
and the two entries regarding the same data will not agree.

3.2.4. Data can be shared:

A certain data from a certain office can be shared by multiple


applications in centralized DBMS.

3.2.5. Restricting unauthorized access

When multiple users share a database, it is likely that some users will
not be authorized to access all information or to do some activities in
the database.

3.3. Types of DBMS

Database Management is a software system that uses a standard method


and running queries with some of them designed for the oversight and
proper control of databases.

There are four structural types of database management systems:

a) Hierarchical databases.
b) Network databases.
c) Relational databases.
d) Object-oriented databases

3.3.1. Hierarchical database


In a hierarchical database, records contain information about their
groups of parent/child relationships, just like as a tree structure.

3.3.2. Network database

A network database looks more like a interconnected network of


records.

In network databases, children are called members and parents are


called occupier. The difference between each child or member can
have more than one parent.

3.3.3. Relational
Databases:

In relational databases, the relationship between data files is relational.


Hierarchical and network databases require the user to pass a
hierarchy in order to access needed data. These databases connect to
the data in different files by using common data numbers or a key
field. Data in relational databases is stored in different access control
tables, each having a key field that mainly identifies each row. In the
relational databases are more reliable than either the hierarchical or
network database structures.

3.3.4. Object-Oriented Databases

This approach is the analogical of the application and database


development into a constant data model and language environment.
Applications require less code, use more natural data modeling, and
code bases are easier to maintain. Object developers can write
complete database applications with a decent amount of additional
effort.

3.4. CommonDatabase Management Systems Software

There is a lot of DBMS systems software available in the market. But in


this book only the most used ones will be discussed.

3.4.1. Microsoft Access

Microsoft Access is a computer application used to create and manage


computer-based databases on desktop computers and/or on connected
computers (a network). Microsoft Access can be used for personal
information management (PIM), in a small business to organize and
manage data, or in an enterprise to communicate with servers.

3.4.2. Oracle Database

Oracle Database (commonly referred to as Oracle RDBMS or simply


as Oracle) is an object-relational database management
system produced and marketed by Oracle Corporation.

The system is built around a relational database framework in which


data objects may be directly accessed by users (or an application front
end) through structured query language (SQL). Oracle is fully scalable
relational database architecture and is often used by global
enterprises, which manage and process data across wide and local
area networks. The Oracle database has its own network component to
allow communications across networks.

3.4.3. MySQL

MySQL is the most widely used relational database management


system (RDBMS)and most widely used open-source RDBMS.
The SQL acronym stands for Structured Query Language.
The MySQL development project has made its source code available
under the terms of the GNU General Public License, as well as under a
variety of proprietary agreements.

4. Introduction to Microsoft Databases

Microsoft Access is a database management tool that enables one to have


good command of data collected. The programme enable one to retrieve,
soft, summarizes and report results speedily and effectively. It can combine
data from various files creating relationships and can make data entry more
efficient and accurate.

4.1. The main components of Microsoft Access Database

Microsoft Access enables one to manage all important information from a


single database file. Within a database file can find and use the following
components or elements:

a) Tableis a collection of related information that is organized in columns


(fields) that describe an entity (record). In the most basic sense, an
entity is a person, place, thing, or idea.

b) A query is a request for data results, for action on data, or for both.
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.
c) A form is a database object that you can use to create a user interface
for a database application. A "bound" form is one that is directly
connected to a data source such as a table or query, and can be used
to enter, edit, or display data from that data source.
d) A report is an object in Microsoft Access that is used to display and
print your data in an organized manner.

5. Steps required to Design Database

Before starting to create a database, there are some crucial information


and particulars have to be organized.

a) Identify the purpose of your database.


What type of information are you trying to store and retrieve from
your database? Each database should be set up for a specific
purpose. For example if you’re keeping track of donations, you need
to plan and design a database that can store related data such as
donors and events as well.

b) Determine the tables you need


Each table should focus on one topic and should store only the data
related to that topic.

c) Breakdown the tables into fields and Data Types


The fields in a table should relate to the subject of the table. For
example, if you are about to store information related to students,
you might have a field like “Student Admission Number”.

Also, you have to consider the type of data that you plan to put in
each field. Some common types are Text, Integer, Currency, and
Date/Time.

d) Determine the Relationships


Joining or relating the tables to one another will allow you to view
information from multiple tables at the same time. After you define
relationships between the tables, you have to flexibly bring the data
from multiple tables together in a query, form or report.

6. Creating Microsoft Access Database

Make sure you have installed Microsoft Office package in your computer,
because Microsoft Access is provided with the package. After opening your
program, there are two ways to create your Database file:-

a) Create from a Blank Database choice allows you to create your own
database from scratch.
b) Create from
also offers templates from various
categories, that you can download.
These templates provide the design
and structure of the database, so
you just enter the data.
6.1. Create a blank database
a) On the File tab, click New, and then click Blank Database
b) In the right pane, under Blank Database, type a file name in the File
Name box. To change the location of the file from the default,
click Browse for a location to put your database (next to the File
Name box), browse to the new location, and then click OK
c) Click Create.

6.2. Working with Tables

Before we engage our self on working with tables, there is a very


important issue to discuss, and that is a field data type.

Every field in a table has properties. These properties define the field's
characteristics and behavior. The most important property for a field is its
data type. A field's data type determines what kind of data it can store.
For example, a field whose data type is Text can store data that consists
of either text or numerical characters, but a field whose data type is
Number can store only numerical data.

Below table shows the commonly used data types in Microsoft Access

Data Types
Data Type Use Notes
Text Alphanumeric data. Use .
for text and for numbers
that are not used in
mathematical
calculations. Use for
names, addresses, and
other relatively short
pieces of text. Can store
up to 255 characters.
Memo Long text. Use for long
pieces of text, such as
notes and long
descriptions. Can store
up to 64,000 characters.
Number Numeric data. Use for If you are
numbers you want to working with
use in mathematical currency, use
calculations. the currency
type.
Date/Time Use for dates and times.
Currency Use for currency. Prevents
rounding
during
calculation.
AutoNumbe Unique sequential
r numbers or random
numbers automatically
inserted when you
create a record. Use to
create a primary key.
Yes/No Logical data. Use when
only one of two values is
valid. Yes/No,
True/False, etc.
Hyperlink Use to store hyperlinks.
Attachment Use to store
attachments.
OLE Object Use to attach an OLE
object such as a Word
document, Excel
spreadsheet, or
PowerPoint
presentation.
6.2.1. Primary Key

A primary key is a special relational database table column (or


combination of columns) designated to uniquely identify all table
records.

A primary key’s main features are:


a) It must contain a unique value for each row of data.
b) It cannot contain null values.

A primary key is either an existing table column or a column that is


specifically generated by the database according to a defined
sequence

6.2.2. Working with a table created with a database

When you create a new database it comes with an empty table named
Table. Using this table you can add new fields, rename the fields and
even change their data types.

6.2.3. To add a new Fields, change data type and saving a


table

a) Click on “Click to Add” then choose the data type


b) Type the name of your new field

c) If you want to change a field name, just double click the name
and type a new name
d) If you want to save the table with a different name, once you
have finish to with the field names, close the form and the
computer will prompt you with an option to save the table

7. Creating Tables
There are two different ways to create tables, using a new blank table button
and blank table from design view.

7.1. Create a table using a new blank table button

a) Open your database


b) Choose Create Menu
c) Then click on Table button
d) A new table will appear on you window with a
single field labelled “ID”
e) From here you can add new fields and give them names or you can
switch a table into table design view

7.2. Create a table using blank table from design view

a) Open you database


b) Choose Create menu
c) Then click on design view button
d) A table design view will be opened
e) Then add table fields and specify their datatypes
f) Set a Primary key field

7.3. Entering Data in a Table

a) Click in a field and type your content, then press enter

7.4. Creating Forms

As we have mentioned that form is a type of database object that


primarily used to enter or display data in the database. Most forms bound
to one or more table and queries. A form data source refers to the fields
in an underlying table of query.

Characteristics of a form are:-


a) Focus on one record at a time
b) Can display fields from more than one table
c) Can also display pictures and other objects
d) Can contain button know as macros for opening , printing and other
activities

Data entry form can be created through Form wizard or design view. Once
a table with fields is available it is easy to create a form using wizard.

7.4.1. Creating a form using Form wizard

a) On the Create tab, in the Forms group, click Form Wizard.


b) Follow the directions on the pages of the Form Wizard.

Note :

If you want to include fields from multiple tables and queries on


your form, do not click next or Finish after you select the fields from
the first table or query on the first page of the Form Wizard. Instead,
repeat the steps to select a table or query, and click any additional
fields that you want to include on the form. Then click next or Finish
continuing.

c) On the last page of the wizard, click Finish.

7.4.2. Creating a form using Blank Form tool

This can be a very quick way to build a form, especially if you plan to
put only a few fields on your form.
a) On the Create tab, in the Forms group, click Blank Form.

Access opens a blank form in Layout view, and displays the Field
List pane.

b) In the Field List pane, click the plus sign (+) next to the table or
tables that contain the fields that you want to see on the form.
c) To add a field to the form, double-click it or drag it onto the form.
d) Use the tools in the Header/Footer group on the Design tab to add a
logo, title, or the date and time to the form.

7.5. Creating Queries

As it was mentioned earlier, a query is a deliver item in a database meant


to answer specific questions that related to the information in the
database. Queries are handy during the process.

Queries can be used to finds data that’s meet a certain condition that you
specify.

There are two ways to create a query, using query wizard and query
design view.

7.5.1. Create a query using query wizard

a) Click create button


b) Then choose query wizard
c)
d) The query wizard dialogue box will be displayed

e) Then, choose simple query wizard and click Ok


f) You will be ask to specify which table or query can provide fields
for your new query
g) After selecting a table or query, you may decide if to include the
entire field available in a selected table or query.

h) Then click ok
i) Write the name for your query and click finish

7.5.2. Creating a Query in Design View


Most of the queries described may be created using a query wizard.
However, design view is useful for creating more complex queries and
for revising existing queries.

a) Locate the Other area of the Create ribbon.


b) Click on the button labeled Query Design.

c) The Show Table window will appear

d) Click on the Tables to get


the list of tables or click on
Query to get the list of Queries
e) Click to select a name of the table or query you wish to use.
f) Click on the button labeled Add.
g) Repeat these steps until you have selected all tables.
h) The tables you selected will appear at the top of the query window.
i) There are two ways to add selected fields in a new query, by
dragging a field from a table list to a field and clicking a drop down
arrow in the Field and select a field name you want
j) On the Design ribbon, click on the button labeled Run.

7.5.3. Creating a Parameter Query

Parameter queries are interactive filters that allow you to specify a


different filter criterion every time you open up the query. You can
design the query to prompt you for more than one piece of
information; for example, you can design the query to prompt you for
two dates. Access will then retrieve all records that fall between those
two dates.

a) Open up an existing query in Design view.


b) Decide which field you wish to use in your filter.
c) In the design grid, click in the field’s Criteria cell.

If your parameter query requires an operator, type that operator in


the Criteria cell Complete your filter expression by inserting a
parameter label in square brackets. Every time you run your
query, you will be asked to provide this parameter.

d) Continue to add criteria in the appropriate fields to complete your


query.
e) Right-click on the query’s tab at the top and click Save.
f) From the Design ribbon, go to the Results area and click on the
Run button to test your query.
g) The Enter Parameter Value window will appear for each criterion
that has to be specified.

h) Enter the numeric value you wish to use in your filter.


i) Click on the button labeled OK.

8. Creating table relationships

One of the major advantages of databases such as Microsoft Access is their


ability to maintain relationships between different data tables. The power of
a database makes it possible to correlate data in many ways and ensure the
consistency (or referential integrity) of this data from table to table.

In a database, relationships are how your tables "talk" to each other. If your
tables don't talk, you can't get answers from your data. You create
relationships by including a field from one table as a field in a related table.

a) The field you include is called a primary key. Each of the tables in your
database has a primary key, and you include it as a new field in another
table to create a relationship with that other table.

b) When you share a primary key, the new field in the second table is called
a foreign key.

8.1. Creating relationship

a) First open up your database. In order to create or modify any


relationships in your database, you need to switch to the relationships
view.
b) So click on the Database
Tools tab on the new Access
2007 ribbon and click on
the Relationships button.
c) Since there aren’t any existing relationships, Access will open
theRelationships View together with the Show Table dialog box.

d) Select the tables and add


them to the relationships view
window.
e) Go ahead and select each table that relates to the other tables and
click Add.
f) Once you are done selecting and adding all the tables, go ahead click
on the Close button.
g) Creating a one-to-one relationship between tables, you drag a primary
key field from one table and drop it into the other table to create a
foreign key.
h) After this, the Edit Relationships windows will appear. You may want to
check the box next to Enforce referential Integrity to verify the
contents of the table during data entry.

i) Go ahead and click on the Createbutton.

9. Creating Reports

Reports are a way of displaying and printing information from your database.
Developers often use Reports to display the results of a Query, which is what
we are going to do next.

Like other Access database objects, there a number of ways to create an


Access reports.

9.1. Creating report using report wizard


a) Begin by selecting the Create tab on the Access Ribbon.
b) Then click Report Wizard from the Reports group to open the pop up
window.
c) The first page of the Report Wizard is almost identical to that of the
Form Wizard. On this page we will select a Query or Table as the data
source for the Report.
d) Then select all fields from Query or Table by clicking the arrow or
double arrow to the right of the text box labelled available fields.
e) Click next to go to the second page of the wizard.

f) On the grouping levels, click next


g) Records Sort order, click arrow to select a field to sort and choose
Ascending or Descending
h) click next
i) Report layout. There are various lay out options, but in our case we
shall keep to the default setting of Tabular.
j) For style, select Access 2007 from the list and click next.
k) Write a name for your report and then click FINISH.

10. Microsoft Access Practice


10.1. Exercise 1:
a) Create a Database file call it your name Database, eg Andrew
Database.
b) Use the database to create the following tables, you are supposed to
specify the primary key field and data type for each field
Table 1:
- StudentID
- FirstName
- MiddleName
- LastName
- Sex
- Age
- Address
- PhoneNumber
Call a table StudentsTbl

c) Use the above table to enter the following records

StudentID FirstNam MiddleNam LastNam se Ag Address PhoneNumbe


e e e x e r
1 Rashid Issa Hemed M 31 Box 231 0713-231455
2 Richard Mabishi M 28 Box 355 0613-664521
3 Ester Kulwa Bahati F 19 Box 12 0784-342155
4 George H. Victor M 22 Box 725 0778-435266
5 Amida Hassan Ulaya F 31 Box 879 0717-546322
6 Linda Walter Francis F 24 Box 0 0654-675543
7 Nabisha Chacha Xavier M 36 Box 72 022 223426
8 Huruma Nassor Mwinyi F 23 Box 217 0713-241124
9 Zuberi Haji Nangai M 32 Box 906 0652-345122
10 Kiduka John Kiduka M 41 Box 639 0745-324411
d) Create another table with the following fields
- DepartmentID
- DepartmentName
Call a table DepartmentTbl

e) Use the above table to enter the following records

DepartmentID Department
1 Civil Engineering
2 Mechanical Engineering
3 Computer Studies
4 Telecommunication Engineering

f) Create another table with the following fields


- CourseID
- CourseName
- Award
- YearsOfStudy
Call a table CourseTbl

g) Use the above table to enter the following records

CourseID CourseName YearsOfStudy


1 Mining Engineering 2
2 Communication Systems 3
3 Mechatronics 3
4 Multimedia 2

You might also like