Sie sind auf Seite 1von 29

Introduction to Databases

Mr. Kwao Lazarus


(BSc, Computer Science, MSc .Informatics)

What is a Database?
In its simplest form, a database can be
defined as
Collection of related data

More appropriate definition although would


be
A shared collection of logically related
data, and a description of this data,
designed to meet the information needs
of an organisation

What is a Database Management


System (DBMS)

A software system that enables


users to define, create, maintain,
and control access to the database
It also interacts with the users
application programs and the
database.
Typically, a DBMS provides the
following facilities:

What is a Database Management


System (DBMS) contd.

Data Definition Language (DDL) - this allows one to define the


database and also specify the data structures and the constraints
on the data to be stored in the database
Data Manipulation Language (DML) this allows users to insert,
update, delete and retrieve data from the database. The DML also
offers a facility called the query language which enables users to
perform actions on specific portions of the database. The most
commonly of these is the Structured Query Language (SQL) but
details of these is beyond our scope
The DBMS also provides a controlled access to the database
which includes:
A security system which prevents unauthorised users
accessing the database
An integrity system which maintains the consistency of the
stored data
A concurrency control system which allows shared access of
the database
A recovery control system purposely for restoring the
database to a previous consistent state following a hardware
or software failure
A use-accessible catalog, which contains descriptions of the
data in the database

Components of the DBMS Environment


The main components are:

Hardware this is required for the DBMS to run. Can be a Personal


Computer (PC), a mainframe or networked computers

Software this comprises of the DBMS software itself and the application
programs together with the operating system, including network software
if its being used on a network.

Data perhaps the most important from the end users point of view. The
data always acts as a bridge between the machine components and the
human components and consist of both the operational data and the
metadata.

Procedures refers to the instructions and rules that govern the design
and the use of the database. May include

Logging on to the database

Using a particular DBMS facility

Starting and stopping the database

Making backup copies of the database and

How to handle both software and hardware failures and

Changing the structure of the database

People refers to the people who are really involved in the design and
administration of the database. Key personalities involved here are the
Database Administrators, Database Designers, Application Developers and
End-Users

Examples of DBMS
The most popular ones include:
Microsoft SQL Server and Microsoft
Access from Microsoft Corporation.
(Well be using Microsoft Access for
our database implementation)
Oracle from Oracle Corporation
MySQL which is open source
DB2 from IBM and a host of others.

Other related database definitions

Database Application Simply a


program that interacts with a
database at some point in its
execution
Database System a collection of
application programs that interact
with the database along with a
Database Management System
(DBMS) and the database itself

Why use a database?


Various ways of record keeping include:
Manual system of using a notebook for
record keeping as well as file folder.
Early computer record keeping includes
the traditional file system where a flat
file is created for each department/unit
and data kept.

Some of the main problems with the two


systems above are
difficult to locate a record especially when the
data grows big
Leads to lots of redundancies when records
are related

Why use a database contd.


Improve system is the use of Databases which offers the
following:

Storing Information - First, a database enables you to


store larger amounts of information than a flat file. A
computer database can handle thousands of records.
Retrieving Information - Second, a database allows you to
retrieve your information more efficiently, more flexibly, and
more creatively.
Manipulating Information - Third, a database can
manipulate the information it contains. For example, if you
had fields that contained prices and fields that contained
quantities of inventory parts, a database can multiply the two
fields together to calculate costs.

Applications of Databases in our dayto-day life

Purchases from the supermarket


Booking a holiday at the travel
agent
Withdrawing from your bank
account
Using the local library
Renting a video and a host of others

Database Terminologies

Database Schema - Databases are designed to offer an organized


mechanism for storing, managing, and retrieving information. A
database schema defines the objects that are represented in the
database and the structural description of the facts that are held in
that database.
Database Models - A database model describes the database
schema as per the stated requirements. These models are also called
data models. There are three types of models. These are:

Relational Model

Hierarchical Model

Network Model
(Details of these is beyond our scope)

Relational Database Management System - A Relational Database


Management System facilitates the organization, storage, access,
security, and integrity of data and eliminates data redundancy. It
stores the data in a set of tables each of which contains a unique
identifier. Typical examples of RDBMS software include Oracle,
Microsoft SQL Server, Sybase, PostgreSQL, MySQL, etc.

Database Terminologies contd.

Normalization - Normalization may be defined as the process of designing the


structure of the database in a way which will reduce redundancy and facilitate easy
data manipulation and better performance. It is a process that breaks down data into
record groups for faster and more efficient data processing. The most common forms of
normalization applied to databases are called the normal forms. Database normalization
is available in the following four levels:

First Normal Form

Second Normal Form

Third Normal Form and

Boyce Codd Normal Form


(Details of these is beyond our scope)
Tuple - A tuple is a collection of one or more attributes. It is a row of information in a
database table that is constructed over a given database schema. It should be noted
that a tuple usually represents some object and its associated data. Further, a relation
is defined as a set of n-tuples.
Views - A view is a logical table that contains the result set of a query. Unlike an
ordinary table in the database, a view is a virtual table and its contents change as and
when the data in the database table changes.

Constraints - A constraint is used to restrict the type of data that can be stored in a
database table. Hence, they facilitate implementing business rules into the database. A
primary key constraint as an example, does not allow any row to contain a duplicate
value.
Indexes - In a relational database an index is a copy of part of a table that is used to
speed up data retrieval in a database

Database Terminologies contd.

Entity a distinct object (a person, place, thing, concept or event) in the


organisation that is to be represented in the database

Attribute attributes either identify or describe entities

A relationship an association between entities

Relation - A relation is a link between two tables and is defined as a set of


tuples all of which have the same attributes. The following are the types of
relations that can exist:

One-to-many

Many-to-many

One-to-one

Tables - A table is a collection of data about a specific topic, such as staff or


students. Tables consist of rows and columns

Fields - A field is an attribute pertaining to an entity, and it is organized as a


column in a database table.

Records - In a database, a record (sometimes called a row ) is a group of fields


within a table that are relevant to a specific entity

Database Terminologies contd.


Keys

Primary Key - A primary key is responsible for uniquely identifying a


particular record belonging to a specific entity. It is the unique
identifier for each row of a database table.
Unique Key - A unique key is an attribute which is unique for that
column of the table. A unique key unlike a primary key may or may
not be null. Note that a primary key or candidate key should always
be a unique key, but the reverse is not always true.
Composite Key - A candidate key is a unique identifier that enforces
the rule that no tuple will be duplicated. A Composite key is composed
of a number of attributes that together maintain the uniqueness.
Foreign Key - A foreign key is a reference to another key in a
different table and is used to declare referential integrity constraints.
These are actually integrity constraints which enforce that the
principle "value of the attribute set is drawn from a candidate key in
another relation."
Nulls - A Null represents an unknown or a missing value. It is
important to understand that a null value does not mean a zero of a
text string of one or more blank spaces.

Database Design
Done through a series of techniques
First specify your Requirements Analysis

This includes what you want to achieve from


your database
The type of data, their sizes, the reports to
generate etc. are all defined here

Some key database design principles are


to be followed and these involve data
modeling; identifying data objects and
relationships, adding attributes, primary
and foreign keys, and lastly adding data
integrity rules.

Database Design contd.

The requirements are gathered by working with


end users of the Organization to get the
information needed. This information can be
gathered in several ways: reviewing existing
documents reports, forms etc.; interviews with
end users individuals or groups; review of
existing automated system and its documentation
if there is one.
The collection of this information enables one to
identify the data objects and classified them as
entities, attributes or relationships. Names are
then assigned to these objects and they are then
modeled using the Entity-Relationship (ER)
diagram.

Database Design contd.


Data Types and Sizes
Date types names varies from one DBMS to another
Notable data types involve

String, text, character for storing alpha-numeric


characters
Numbers grouped into integers, floating point
numbers, currency etc. for storing integers and
decimals depending on ones specification
Boolean for storing Yes/No decision
Date/Time - for storing dates/times of events
Picture for storing pictures and other objects

Data sizes for string, numbers, date/time normally


varies the designer must specify these. But that of
boolean and pictures are normally fixed

Database Design contd.


Example of an E-R
Diagram
The picture on our
right shows an E-R
Diagram about 2
Entities Person and
City with their
respective Attributes
Name and
Population and the
Relationship between
them Lives in

Database Implementation

Done by using a chosen DBMS after one


has finished his/her design on paper
Were going to use Microsoft Access 2007
for our implementations
There may be variations depending on the
version of MS Office suite you use at your
place but the good news is one can
always convert to other versions

Database Implementation contd.


Starting Microsoft Access
Click Start

Point to All Programs

Point to Microsoft
Office and then point
to Microsoft Access
2007
This is shown in the
picture on your right

Database Implementation contd.

Click Microsoft Access


2007
This brings the
window shown in the
picture on your right
This enables one to do
two things:

Create a new Access


Database
Open an existing
database

Click on Blank
Database icon

Database Implementation contd.

This brings another


window that enables
one to create the new
database
Type a name for your
database and click
Create button which
opens the Microsoft
Access program
shown on the next
slide

Database Implementation contd.

Objects in Microsoft Access

Table: an organized collection


of rows and columns used to
store field data
Query: used to view, change,
or organize data
Form: a graphical object that
displays data from a table or a
query in an easy-to-use format
Report: used to present data
in a printed format
Macro: a set of one or more
actions that are used to
automate common tasks such
as opening a form or printing a
report
Module: a collection of Visual
Basic for Application
programming components that
are stored together as a unit

Objects in Microsoft Access contd.

In Ms Access, the database objects are stored in a single


database file with a .mdb extension
Since tables are used to store field and record information,
you must create at least one table before you create any
other object
Hence, tables are the primary objects in a database
Since queries allow you to organize and view data in
different ways, a query is always based upon one or more
tables
Working with records in a row-and-column format is often
tedious. For this reason, forms are used to make a table or
query more accessible
Forms are based upon tables and queries, users interact with
forms directly
Forms are designed to

make data access and maintenance easy


prevent users from making destructive changes to table data

Reports enables users to format and present their records in


a more appropriate manner and also allows one to print the
data to have hard copies

Database Implementation Contd.

Please we will continue the


implementation of our databases in
Microsoft Word tutorials from here.

Resources

Bruce Momjian (January 2003): Why Use a Database? [Online]:


http://postgresql.mirrors-rus.net/files/documentation/books/aw_pgsql/writing_apps/node1.html
Charles W. Neville, Charles W. Neville, with modification by Leith Chan
and Vicky Wong, A Quick Microsoft Access 2003 Tutorial, [ online]:
personalpages.manchester.ac.uk/staff/G.Nenadic/COMP67321/Main_A_Qui
ck_Microsoft_Access_2003_Tutorial.pdf

Database Terminology, [Online]: http://www.sumit.nl/cursus/dbdesign/english/intro030.php3

Databasics: A Database Dictionary, [Online]:


http://www.geekgirls.com/database_dictionary.htm

Goran Tomida, Why and When to Use a Database, [Online]: http://earticles.info/e/a/title/Why-and-When-to-Use-a-Database/

Idowu(Id) Adewale, Introduction to Databases, [online]:


http://cpsc.ucalgary.ca/~adewale

Resources contd.

Joydip Kanjilal, Relational Database Management Systems - Concepts and


Terminologies, [online]:
http://aspalliance.com/1211_Relational_Database_Management_Systems_
_Concepts_and_Terminologies

Microsoft Access 2000, Microsoft Office, [Online]:


http://www.bcschools.net/staff/AccessHelp.htm

Microsoft Access 2003 Tutorials, [online]:


www.bgsu.edu/downloads/cio/file17751.pdf

Mike Chapple, Entity Relationship Diagram, [online]:


http://databases.about.com/cs/specificproducts/g/er.htm

murray.t@lynchburg.edu, Creating a Database Using Access 2003 for


Windows 2000/Me/2003, [online]:
http://www.officetutorials.com/accesstutorials.htm
Null Values in a Database,
[Online]:http://www.databasedev.co.uk/null_values_defined.html

Resources contd.

Record, [Online]:
http://searchoracle.techtarget.com/sDefinition/0,,sid41_gci212878,00
.html
Richard Holowczak, Zicklin School of Business - Baruch College, City
University of New York, Microsoft Access Tutorial, [Online]:
http://cisnet.baruch.cuny.edu/holowczak/classes/2200/access/access
all.html

Thomas Benner, MACinTUTOR, Why Use a Database?, [Online]:


http://www.masteradobe.com/MasterAdobe_MACinTUTOR/Why_Data
base.html
Thomas Connolly, Carolyn Begg, Database Systems A Practical
Approach to Design, Implementation, and Management, Fourth
Edition
Zhi Liu, Introduction to Microsoft Access 2003 , [online],
http://www.ischool.utexas.edu/technology/tutorials/office/access03/

Das könnte Ihnen auch gefallen