You are on page 1of 61

ICS 2206 - Database system

Lesson 3: Database models


3.1. Introduction
These are a variety of ways used to organize data within a database. A
database model specifes the rules according to which data are structured
and the associated operations that are permitted. It may also be seen as a
technique for the formal description of data structure, usage constraints and
operations. The facilities available vary from one database to another. Each
!"# maintains a particular database model.
3.2. Lesson objectives
!y the end of this lesson, the learner will be able to$
escribe database model
escribe hierarchical database models
escribe networ% database model
&elational database model
'b(ect oriented database models
3.3. Lesson outline
This lesson is organized as follows
).*. Introduction
).+. ,esson ob(ectives
).). ,esson outline
).-. .ierarchical database model
)./. 0etwor% database model
).1. 'b(ect oriented database model
).2. &elational database model
).3. &evision questions
).4. #ummary
).*5. #uggested reading
3.. !ierarc"ical database model.
A hierarchical database model consists of a collection of records that are connected
to each other through lin%s 6pointers7.The records e8hibit parent child relationship. A
parent record can have several child records but a child record can only have a
ma8imum of one parent record. This model is suitable for homogenous data.
&ecord access in this model must follow a defnite path from the root. The
resultant structure resembles an inverted tree.
#dvanta$es o% "ierarc"ical model
9i:. ata can be retrieved easily
9ii:. ata integrity is easier to manage
Dra&bac's o% t"e "ierarc"ical model
1
&ecord A
&ecord ! &ecord ; &ecord
&ecord E &ecord <
9iii:. =sers must be familiar with the database structure
9iv:. There is data redundancy
3.(. )et&or' Database *odel
This model is similar to hierarchical model. The records e8hibit parent child
relationship where a parent record can be related to several child records
and a child record can have lin%s to more than one parent record. The
multiple lin%ages in this model allow the networ% database model to be very
>e8ible. This model is suitable for homogenous data. &ecord access does not
have to follow defnite path.
#dvanta$es o% a net&or' database model
9i:. !ecause it has the many?many relationship, networ% database model can
easily be accessed in any table record in the database
9ii:. <or more comple8 data, it is easier to use because of the multiple
relationship founded among its data
9iii:. Easier to navigate and search for information because of its >e8ibility
Disadvanta$e o% a )et&or' Database *odel
9i:. i@cult conceptualize and design
9ii:. i@culties with alterations of the database because when information
entered can alter the entire database
9iii:. .ardware and software overhead
3.6. +bject oriented database model
In this model, both data and their relationships are contained in a single
structure called ob(ect. 'b(ects with similar characteristics will form a class.
In this model the database is modeled in form of ob(ects and the
relationships. A class is an entity that has a well?defned role in the
application domain, as well as state, behavior and identity. An ob(ect is an
instance of a class. The state of an ob(ect refers to the attribute types
6properties7 and values. The behavior of an ob(ect refers to how an ob(ect
2
&ecord
A
&ecord

&ecord
!
&ecord
;
&ecord
E
&ecord
<
Class,na
me#
Attribute
*a
Attribute
+a
Attribute
)a
'peration*
a
'peration
+a
Class,na
me-
Attribute
*b
Attribute
+b
Attribute
)b
'peration*
b
'peration
+b
Class,na
meC
Attribute
*c
Attribute
+c
Attribute
)c
'peration*
c
'peration
+c
1..*
1..1
1..*
1..2
acts and reacts 6methods7. !ehavior is e8pressed through operations that
can be performed on the ob(ect.
#dvanta$es o% object oriented model
9i:. ,ess programming eAort because of inheritance, re?use and
e8tensibility of code.
9ii:. ata and methods are bound together.
9iii:. Improved communication between users, analysts, designer, and
programmers
9iv:. Increased consistency in analysis and design
9v:. E8plicit representation of commonality among system
components
9vi:. &eusability of analysis, design, and programming results
Disadvanta$es o% object oriented model
9i:. #chema change 6creating, updating.7 can be comple8 since it involves
a system wide recompile.
9ii:. ,ac% of agreed upon standard.
9iii:. ,ac% of universal query language
9iv:. ,anguage dependence$ tied to a specifc language.
9v:. ,ac%s wide acceptance by industry.
3... /elational database model
This database model is based on mathematical concepts of sets and
mappings.
"appings$ Bhich can be many?to?many, one?to?one and one?to?many.
=sing these concepts a relation is modeled as a table with rows and
columns.
Croperties of a relation include$
Dalues are atomic
Each row is unique
;olumn values are of the same %ind
The sequence of columns is insignifcant
The sequence of rows is insignifcant
Each column has a unique name
;ertain felds may be designated as %eys, which mean that searches for
specifc values of that feld will use inde8ing to speed them up.
#dvanta$es o% relational database model
9i:. Any changes in table structure do not aAect data access or application
programs.
9ii:. Tabular view improves conceptual simplicity, thereby promoting
easier database design, implementation, management and use.
3
&ecord A
&ecord !
&ecord ;
&ecord E
&ecord <
&ecord .
9iii:. Ad hoc query capability is based on #F,.
9iv:. Bidely accepted in many enterprises.
Disadvanta$es o% relational database model
9i:. &equires s%ills to conceptualize and design.
9ii:. atabase integrity must be ensured during the design and
implementation.
9iii:. Ta%es time and eAort to design.
9iv:. The &!"# require hardware and software.
3.0. /evision 1uestions
9a:. iscuss the following database models, under the following sub topics.
9i:. .ierarchical
9ii:. &elational
9iii:. 0etwor%
9b:. escribe three advantages and three disadvantages of ob(ect oriented model.
9c:. ;ompare and contrast hierarchical and networ% database model.
3.2. Summary
In this lesson you have learnt about four database model$ hierarchical,
networ%, ob(ect oriented and relational model. <or each model we
have learnt its wea%nesses and strengths.
3.10. Su$$ested readin$
9*:. #ilberschatz A. and et al 6+55*7, atabase #ystem ;oncepts, "cEraw?
.ill.
9+:. Earcia?"olina .. and et al 6+5557, atabase #ystem$ The complete
!oo%, Crentice .all.
9):. Elmasri &. and 0avathe #6+5557, <undamentals of atabase #ystem,
Addison Besley.
9-:. ;onollyG !egg, atabase #ystem$ a practical approach to design,
implementation and management, Crentice .all.
Lesson : Database arc"itecture and data inde3endence
.1. Introduction
In our previous topic we discussed various database models$ hierarchical
model, networ% model, relational model and fnally ob(ect oriented model. In
this lesson we will discuss database architecture and data independence.
.2. 4o3ic objectives
!y the end of this topic you will be able to$
iscuss the three levels of database architecture
escribe the two types of data independence
.3. Lesson outline
This topic has been organized as follows$
-.*. Introduction
-.+. ,esson ob(ectives
-.). ,esson outline
4
-.-. atabase architecture
-./. ata independence
-.1. &evision questions
-.2. #ummary
-.3. #uggested reading
.. Database #rc"itecture
The architecture of a system defnes its structure in terms of components,
function of each component and interrelationships and interactions between
those components.
The database architecture defnes the structure of a database systems
consisting of three levels of abstractions proposed by A0#I CA&;.
#)SI S5#/C 6 #merican )ational Standard Institute Standard 5lanning #nd
/equirements Committee7 proposed a standard three level approach to
database design.
a7 Diew level 6E8ternal level7
b7 ,ogical level 6;onceptual level7
c7 Chysical level 6Internal level7
This three ,evel architecture has the aim of enabling users to access the
same data but with a personalized view of it. The separation of the internal
level from the e8ternal level means that users do not need to %now how the
data is physically stored in the database. This level separation also allows
the atabase Administrator 6!A7 to change the database storage structures
without aAecting the usersH views.
a6 78ternal Level 9:ie& level6
This level describes the part of the database that is relevant to a particular
user. Application programs are found on this level. It is the highest level of
abstraction of database.
b6 Lo$ical vie& 9Conce3tual Level6
This level describes what data is stored within the whole database and how
the data is inter?related. The database E&s are found in this level. It is
therefore a representation of the entire information content of the database
in a form that is somewhat abstract in comparison with the way in which the
data is physically stored.
c6 5"ysical level 9Internal Level6
This level describes how the database is physically represented on the
computer system. It describes how the data is actually stored in the
database and on the computer hardware. It is the lowest level of abstraction.
.(. Data inde3endence
ata independence is a form of database management that %eeps data
separated from all programs that ma%e use of the data. ata independence
ensures that the data cannot be redefned or reorganized by any of the
programs that ma%e use of the data. In this manner, the data remains
accessible, but is also stable and cannot be corrupted by the applications
using it. There are two types of data independence.
a6 Lo$ical data inde3endence.
5
This is the ability to change the logical schemaIconceptual level without
changing the e8ternal schemaIview level or application programs. It ma%es it
possible to change the structure of the data independently of modifying the
applications or programs that ma%e use of the data. There is no need to
rewrite current applications as part of the process of adding to or removing
data from then system.
b6 5"ysical data inde3endence.
This is the ability to change the physical schemaIinternal level without
changing the logical schemaIconceptual level. This approach has to do with
altering the organization or storage procedures related to the data, rather
than modifying the data itself. Accomplishing this shift in fle organization or
the inde8ing strategy used for the data does not require any modifcation to
the e8ternal structure of the applications, meaning that users of the
applications are not li%ely to notice any diAerence at all in the function of
their programs.

.6. /evision 1uestions
6
End users
Stored
database
View level View
LEVEL
Logical level
Physical level
Physical data
independence
Logical data
independence
9a:. escribe the three levels of database architecture.
9b:. iscuss the logical and physical data independence.
9c:. iscuss the concept of data independence and e8plain its importance
in a database environment.
9d:. To address the issue of data independence, the A0#I?#CA&; three?level
architecture was proposed. ;ompare and contrast the three levels of this
model.
... Summary
In this lesson we have learnt about database architectureJ model which
provides the basis for understanding the functionality of a database system.
Three levels of abstraction in thise model were discussed? user level view,
conceptual view and internal level
.0. Su$$estions %or %urt"er readin$
9*:. #ilberschatz A. and et al 6+55*7, atabase #ystem ;oncepts, "cEraw?
.ill.
9+:. Earcia?"olina .. and et al 6+5557, atabase #ystem$ The complete
!oo%, Crentice .all.
9):. Elmasri &. and 0avathe #6+5557, <undamentals of atabase #ystem,
Addison Besley.
9-:. ;onollyG !egg, atabase #ystem$ a practical approach to design,
implementation and management, Crentice .all.
5!" http$IIwww.cs.virginia.eduIKsonI11+.pd@lesI11+.+.pdf
Lesson (: Conce3tual database desi$n
(.1. Introduction
In our previous lesson, we discussed database architecture and data
independence. In this lesson you will learn conceptual database design.
(.2. Lesson objectives
!y the end of this lesson you will be able to$
efne conceptual database design
escribe the activities involved in conceptual database design
iAerentiate between generalization and specialization
(.3. Lesson outline
This lesson is presented as follows$
/.*. Introduction
/.+. ,esson ob(ectives
/.). ,esson outline
/.-. efnition of conceptual design
/./. Activities of conceptual design
/.1. Types of entities
/.2. Eeneralization and specialization
/.3. Identifcation of relationships
/.4. !uilding conceptual data model
/.*5. <eatures of a conceptual data model
#
/.**. &evision questions
/.*+. #ummary
/.*). #uggested reading
(.. De;nition o% conce3tual desi$n
This is the process of constructing an abstract model of data to be included
in the database. This model should be independent of any database
management system 6!"#7 and other physical considerations.
(.(. #ctivities o% conce3tual desi$n
a7 Identifcation of entities
b7 Identifcation of relationships
c7 ;onstruction of conceptual data model.
a7 Identify entities
It is a thing or ob(ect of importance about which data must be
captured.
To identify entities in the requirements, map nouns to entities
atabase entities appear in a data model as a rectangle with a title.
The title 6in upper case7 is the name of the entity.
(.6. 4y3es o% entities
i. <ea' entity: This is an entity that does not have su@cient attributes
to form a primary %ey 6unique identifer7. The e8istence of a wea% entity is
indicated by a double rectangle in the E& diagram.
ii. Stron$ entity: This is an entity that has a primary %ey 6unique
identifer7.
S4/+)= 7)4I4>
iii. /ecursive 7ntity: This is an entity in which a relationship can e8ist
between occurrences of the same entity. This occurs in a unary relationship.
<or instance, a doctor can be a 3atient. They are represented as follows$
iv. Com3osite 7ntity: This is an entity created to resolve "any to "any
relationship to one?to?many. It is also referred to as a brid$e entity. !ridge
entity is composed of the primary %eys of each of the entities to be
connected. A composite entity is represented by a diamond shape within a
rectangle in an E& iagram.
(... =enerali?ation and s3eciali?ation
=enerali?ation: The process of defning a more general entity type from a
set of more specialized entity types. !'TT'"?=C approach. =sing this
approach the designer can begin with subtypes and combine them to form a
supertype.
$
D+C4+/

Trea
t
<7#@ 7)4I4>
S3eciali?ation: The process of defning one or more subtypes of the
supertype and forming supertypeIsubtype relationships. T'C?'B0
approach. =sing this approach the designer can begin with supertype and
then derive more specialized sub types.
(.0. Identi;cation o% relations"i3s
A relationship is a meaningful association between entity types.
;lassifying relationships$
i. egree
ii. ;ardinality
iii. 'ptionality
AiB. Classi;cation accordin$ to de$ree
De$ree$ This refers to the number of entity types participating in a
relationship. E8amples$
=nary 6recursive7 relationship$ This is a relationship where only one
entity type participates in a relationship.
!inary relationship$ In this relationship, two entity types participate in a
relationship.
Ternary relationship$ In this relationship, three entity types participate
in a relationship.
L
n?ary relationship$ In this relationship n entity types participate in a
relationship.
AiiB. Classi;cation accordin$ to cardinality9connectivity6
In a relationship, cardinality refers to the number of entity occurrences
involved in the relationship. Also defned as minimum and ma8imum number
of entity occurrences that can participate in a relationship.
%
;ar !us ,orry

:7!ICL
7

Dehicle
C#/ -CS
L+//>

DOCTOR

T
re
at

DOCTOR

DOCTOR

T
re
at

PATIENT

PRESCRIPTI
ON
PHARMICST


Is
s
u
e
PATIENT
E8amples
'ne?to?one relationship 6*$*7$ Each entity occurrence in entity type A
can only have one matching entity occurrence in entity type ! and vice
versa.
'ne?to?many relationship6*$m7$ An entity occurrence in entity type A
can have several a matching entity occurrences in entity type !, but
each entity occurrence in entity type ! can only have a ma8imum of
one entity occurrences in entity type A.
"any?to?many relationship 6m$n7$ An entity occurrence in entity type A
can have several matching entity occurrences in entity type ! and vice
versa.
AiiiB. Classi;cation accordin$ to o3tionality 93artici3ation6
'ptionality refers to the minimum number of entities in a relationship. ;an
be mandatory or o3tional. E8amples
"andatory$ There must be an entity occurrence participating in the
relationship
'ptionality$ There may be an entity occurrence participating in the
relationship. To show optionality, put a circle or M5H at the Moptional endH of
the relationship.
(.2. -uildin$ conce3tual data model
The data model that results after conceptual design is called conceptual data
model
;hoose a notation and design the data model. E8amples of notations are
chenNs notation , &ein3/ notation, ;rowNs foot notation and IE<*O notations.
"ost of the diAerences concern how relationships are specifed and how
attributes are shown. In almost all variations, entities are depicted as
rectangles with either pointed or rounded corners. The entity name appears
inside. &elationships can be displayed as diamonds or can be simply line
segments between two entities. <or &elationships, there is need to convey
relationship name, degree, cardinality and optionality where necessary. Any
notation selected must be used consistently.
1&
a1
a2
a3
a4
b1
b2
b3
b4
a1
a2
a3
a4
b1
b2
b3
b4
a1
a2
a3
a4
b1
b2
b3
b4
C"enDs notation Cro&Ds %oot /ein0( ID7E1F
/elations"i3
)ame: isplayed
(ust inside the
relationship
diamond.
Cardinality: The
cardinality is
indicated by placing
the appropriate
numbers beside the
entities using the
format 68,y7, which
represent the
minimum and
ma8imum value,
respectively.
+3tionality:
"andatory
participation
indicated by oneI
two line6s7 lin%ing
the entity to the
diamond ne8t to
mandatory end.
'ptional
participation
indicated by a circle
near optional end.
/elations"i3
name:
&elationships
name indicated
ne8t to entity
above or below
the lin%.
Cardinality:
;rowHs feet are
used to show a
many side of a
relationship. A
single line
indicates a one
side of the
relationship.
+3tionality:
'ptional
participation is
shown with an
open circle ne8t to
optional end.
"andatory
participation is
shown with two
vertical lines.
/elations"i
3 name:
&elationships
name indicated
ne8t to
relationship
diamond.
Cardinality:
0ot shown
e8cept the
connectivity.
+3tionality
: 'ptional
participation is
shown with an
open circle ne8t
to optional end.
"andatory
participation is
shown with
continuous lin%
line ne8t to
mandatory end.
/elations"
i3 name:
&elationships
name indicated
ne8t to
relationship
diamond.
Cardinality
: 0ot shown
e8cept the
connectivity.
+3tionality
: 'ptional
participation is
shown with an
open circle
ne8t to
optional end.
"andatory
participation is
shown with
continuous lin%
line ne8t to
mandatory
end.
78am3le 1: C"enDs notation
The above model will be read as follows$
Each ';T'& must treat one or more CATIE0T#. Each patient must be
treated by a doctor. Each CATIE0T may ta%e one or more "EI;ATI'0#. Each
"EI;ATI'0 is given to one CATIE0T.
78am3le2: Cro&Ds %oot notation.
11






'
()*+), P-+.E/+
'E(.*-+.)/


tr
ea
t

011
'2

011
12


ta
3e
s

0&1
/2

011
12






1


1






/
()*+),
P-+.E/+
'E(.*-+.)/
+reat +a3es
The above model will be read as follows$
Each ';T'& must treat one or more CATIE0T#. Each patient must be
treated by a doctor. Each CATIE0T may ta%e one or more "EI;ATI'0#. Each
"EI;ATI'0 is given to one CATIE0T.
(.10. Eeatures o% conce3tual data model
The features of the conceptual data model include$
9i:. Important entities and the relationships among them.
9ii:. 0o attribute is specifed.
9iii:. 0o primary %ey is specifed.
78am3le: A supplier receives orders for products. A #=CC,IE& may receive
one or more '&E&#. Each one or more '&E&# must be send to the
#=CC,IE&. Each order consists of one or several products. !ut each C&'=;T
is belonging to one '&E&.
<igure *$ ;onceptual data model
<rom the fgure above, the conceptual data model is the entities that
describe the data and the relationships between those entities.
(.11. /evision 1uestions
9a:. iscuss the diAerences in the following data modelling notations.
9i:. ;hen
9ii:. IE<*O
9iii:. &ein3/
9iv:. ;rowNs foot
9b:. escribe the process of conceptual database design.
9c:. escribe how database designers use specialization and generalization
during conceptual database design.
9d:. A relationship can be defned as a meaningful association between
entity types. escribe ways of classifying relationships during database
design.
(.12. Summary
In this lesson we have learnt conceptual database design. This is the frst
phase of database design that involves activities such as identifcation of
entities, identifcation of relationships between the entities and fnally
constructing a conceptual data model.
(.13. Su$$ested readin$
9*:. #ilberschatz A. and et al 6+55*7, atabase #ystem ;oncepts, "cEraw?
.ill.
9+:. Earcia?"olina .. and et al 6+5557, atabase #ystem$ The complete
!oo%, Crentice .all.
12
'&E&
#=CC,IE&
C&'=;T
,eceives
has
9):. Elmasri &. and 0avathe #6+5557, <undamentals of atabase #ystem,
Addison Besley.
9-:. ;onollyG !egg, atabase #ystem$ a practical approach to design,
implementation and management, Crentice .all.
Lesson 6: Lo$ical database desi$n
6.1. Introduction
In our previous lesson, we learnt about conceptual database design. In this
lesson, you will learn about logical database design$ the activities involved
and how to construct a logical database model.
6.2. Lesson objectives
!y the end of this lesson you will be able to$
escribe the process of constructing a logical data model
escribe the activities involved in logical database design
escribe normalization
6.3. Lesson outline
This lesson is presented as follows$
1.*. Introduction
1.+. ,esson ob(ectives
1.). ,esson outline
1.-. efnition
1./. ,ogical design activities
1.1. Types of attributes
1.2. atabase normalization
1.3. ;onstructing logical data model
1.4. <eatures of a logical data model
1.*5. ,ogical data model versus conceptual data model
1.**. &evision questions
1.*+. #ummary
1.*). #uggested reading
6.. De;nition
The process of constructing a database based on specifc database
management system 6!"#7 and database model. <or e8ample a relational
atabase model. It considers how the data are represented using the
structures oAered by the !"#.
6.(. Lo$ical desi$n activities
,ogical database design consists of the following steps
#elect database model.
"ap Entity?&elationship iagrams6from conceptual data model
into logical model7
Identify the attributes
0ormalize database
esign the E& 6logical data model7 and validate with the users.
9i:. Selectin$ database model
13
A database model is a collection of conce3ts and rules for the description
of the structure of the database. #ome of the models one can choose are >at
fle database, hierarchical, networ%, relational and ob(ect oriented.
9ii:. *a3 7ntity-/elations"i3 Dia$rams
Identify all the entities and relationships as captured in conceptual data
model.
9iii:. Identify attributes
Attributes are e8plicit values such as a 1uality or c"aracteristic associated
with someone or something 9entity6.They represent c"aracteristics or
values about a database relation 6an entity7
6.6. 4y3es o% attributes
i. @ey attributes: Attributes which uniquely identify an instance of an
entity 6identifer7. These attributes are distinct for each individual entity.
<or e8ample a student 0umber or ;ar registration number etc.
ii. )on 'ey attributes: These are attributes which describe a non?unique
characteristics of an entity instance 6descriptors7. E8amples year, color,
model.
iii. /e1uired attributes$ These are attributes which must have a value or a
value must be %nown for each entity occurrence. E8ample employee
number.
iv. +3tional attributes$ These are attributes which could have a value or a
value may be %nown for each entity occurrence. E8ample an employeeJ
employees spouse is optional since not every employee will have a
spouse.
v. Com3osite attributes$ These are attributes which can be divided into
smaller subparts. These subparts represent basic attributes with
independent meanings of their own. <or e8ample, ta%e 0ame attributes.
Be can divide it into sub?parts li%e <irstPname, "iddlePname, and
,astPname.
vi. Sim3le attribute$ This is an attribute that cannot be divided into
subparts. It is therefore said to be sim3le or atomic attribute. <or
e8ample, 7m3loyee )umber is a simple attribute. #$e of a person is a
simple attribute.
vii. Sin$le-valued attribute$ It is an attribute that can have single value at
a particular instance of time. <or instance, a person cannot have more
than one age value.
viii. *ulti-valued attribute: It is an attribute that can have more t"an one
value at one time. <or instance, a person can have more than one degree
at one time, therefore attribute degree is said to be a multi?valued
attribute.
i8. Stored attribute$ An attribute that supplies a value to the related
attribute.
8. Derived attribute$ An attribute whose value is derived from a stored
attribute. These attributes are usually created by a formula or certain
14
operation on other attributes. E8ample$ #$eG ACurrent-yearB-
Ayear,o%,birt"B
8i. Candidate @ey$ An attribute or set of attributes that uniquely identifes
individual occurrences of an entity type.
8ii. 5rimary @ey: An attribute that is used to identify an entity type.e.g.
entity type student can be identifed by student number.
8iii. Com3osite @ey: A candidate %ey that consists of two or more attributes.
e.g. DoterIQ0ationalIQCassportI
6... )ormali?ation o% t"e database
ata is organized into database tables by using normal forms rules or
conditions. These rules help to ma%e a good database design. =sually, data
is organized using frst, second and third normal forms. 0ormalization will be
discussed at length in lesson 2.
!egin with a list of all of the felds that must appear in the database.
o not include computed felds
Rou can get this information from a printed document used by the system
e.g. reports.
Additional attributes besides those for the entities described on the
document can be added to the database.
6.0. Constructin$ t"e lo$ical data model
In this step we use the normalized forms and standard notations to draw the
E&. #uch notations include &ein4/, IE<l*O, ;hen, ;rowNs foot among
others.
C"en Cro&Ds Eoot /ein0( ID7EI1F
Entity
&elationship
line
&elationship
'ptional
symbol
'ne6*7
symbol
*
"any6"7
symbol
"
;omposite
entity
Bea% entity
A logical data model describes the data in as much detail as possible,
without regard to how they will be physically implemented in the database. A
logical data model is used to e8plore the domain concepts, and their
relationships, of the problem. This could be done for the scope of a single
15
pro(ect or for the entire enterprise. The logical data model depict the logical
entity types, typically referred to simply as entity types, the data attributes
describing those entities, and the relationships between the entities.
6.2. Eeatures o% a lo$ical data model
Includes all entities and relationships among them.
All attributes for each entity are specifed.
The primary %ey for each entity is specifed.
<oreign %eys 6%eys identifying the relationship between diAerent
entities7 are specifed.
0ormalization occurs at this level.
<igure$ ,ogical ata model using crowNs foot.
6.10. Lo$ical data model versus Conce3tual data model
In a logical data model, primary %eys are present, whereas in a conceptual
data model, no primary %ey is present.
In a logical data model, all attributes are specifed within an entity. 0o
attributes are specifed in a conceptual data model.
&elationships between entities are specifed using primary %eys and foreign
%eys in a logical data model. In a conceptual data model, the relationships
are simply stated, not specifed, so we simply %now that two entities are
related, but we do not specify what attributes are used for this relationship.
6.11. /evision 1uestions
9a:. efne the following attributes as used in relational database
design.
"ulti?valued attribute
;omposite attribute
erived attribute
9b:. Identify at least three attributes for each of the following entities
below and choose one of your attributes as the identifer for the
entities.
;ustomer.
'rganization.
9c:. escribe the activities involved in logical database design.
16
#=CC,IE&
#upplierI
6CS7

#uppler0ame
Address
#treet
'&E&
'rderI 6CS7
'rder0ame

ateCrepared
#treet
#upplierI6<S7
C&'=;T
CroductI
6CS7

Croduct0ame
Fuantity

'rderI6<S7

9d:. 'utline the features of a logical data model
9e:. ;ompare and contrast the conceptual data model and logical
data model.
6.12. Summary
In this lesson you have learnt that logical database design is a process
consisting of a number of tas%s$ selecting a suitable database model,
mapping conceptual data model to logical model, identifcation of attributes,
normalization and fnally construction of a logical data model. In our ne8t
lesson we discuss normalization.
6.13. Su$$ested readin$
9*:. #ilberschatz A. and et al 6+55*7, atabase #ystem ;oncepts, "cEraw?
.ill.
9+:. Earcia?"olina .. and et al 6+5557, atabase #ystem$ The complete
!oo%, Crentice .all.
9):. Elmasri &. and 0avathe #6+5557, <undamentals of atabase #ystem,
Addison Besley.
9-:. ;onollyG !egg, atabase #ystem$ a practical approach to design,
implementation and management, Crentice .all.
Lesson .: Database normali?ation
..1. Introduction
In our last lesson you learnt logical database design. 'ne of the activities involved
in logical design is normalization. In this lesson therefore, our focus will be on
normalization. Rou will learn about data anomalies, reasons for normalization and
steps for normalization.
..2. Lesson objectives
!y the end of this lesson, you will be e8pected to$
escribe the three data anomalies
escribe the normal forms
Eiven a case normalize up to third normal form
..3. Lesson outline
This lesson will be presented in the following format.
2.*. Introduction
2.+. ,esson ob(ectives
2.). ,esson outline
2.-. 'verview
2./. efnitions
2.1. &easons for normalization
2.2. ata anomalies
2.3. atabase normalization steps
2.4. &evision questions
1#
2.*5. #ummary
2.**. #uggested reading
... +vervie&
0ormalization or database normalization is a process used to organize the
data into tabular format 6database tables7. A good database design includes
the normalization. Bithout normalization a database system may slow,
ine@cient and might not produce the e8pected result. 0ormalization reduces
the data redundancy and inconsistent data dependency. Be organize the
data into database tables by using normal forms rules or conditions.
..(. De;nitions
)ormali?ation
0ormalization is the process of removing redundant data from the tables in
order to improve storage e@ciency, data integrity and scalability.
0ormalization wor%s through series of steps called normal forms.
Eunctional de3endency
Implies that if A and ! are attributes 6columns7of a table, ! is fully
functionally dependent on A if value of A determines the value of !.<or
e8ample, voterI determines voter0ame e.g.
5artial Eunctional De3endency
Implies that if A and ! are attributes of a table , ! is partially dependent on
A if there is some attribute that can be removed from A and yet the
dependency still holds. ;onsider a case of
DoterI,Doter0ationalI,Doter0ame,;onstituency all being attributes in a
table.The voterI value can only determine the value of constituency6Cartial
dependency7.
4ransitive Eunctional De3endency
A condition where if A,! and ; are attributes of a table and further that A is
the only %ey attribute then if value of A determines value of ! and value of
! detemines value of ;, then we say ; is Transitively dependent on A via
!.This means a non %ey attribute6;7 is depending on another non %ey
attribute6!7.<or e8ample If DoterI, ;onstituency, Collstation are all attributes
of a table voter. Then Collstation depends on constituency which in turn
depends on DoterI. Collstation is therefore functionally dependent on
DoterI via constituency. This is a transitive dependency.
Cn-)ormali?ed %orm 9C)E6
It is a relation that contains one or more repeating groups.
,ist all the data elements.
The resultant is an un?normalized form.
..6. /easons %or normali?ation
A number of reasons can be e8plained$
1$
DoterI
Doter0ame
To ma%e it feasible to represent any relation in the database.
To increase speed and >e8ibility of queries 6easier to search7.
To free relations from anomalies.
To reduce the need of restructuring the relations whenever new data
types are introduced6scalability7
To avoid repetitive entries 6data redundancy7.
.... Data anomalies
&elations that have redundant data may have problems called anomalies,
which are classifed as.
i. Insertion anomalies
ii. eletion anomalies
iii. =pdate anomalies
AiB. C3date anomaly
The same information appears on multiple rowsJ therefore updates to the
relation may result in logical inconsistencies.If the update is not carried
through successfully to all the rows, then the relation is left in an inconsistent
state.<or e8ample if sender0o T) was actually supposed to be TTimothy
"a%uaT then the user must update all the records where T) appears so that
the table is consistent.
78am3le
!ara'a Courier services
Sender)
o
Sender Descri3tion Date /eci3ient
41 "unyalo "utua "agazine **I4I+5*+ Sasyo%a "unyalo
42 Eze%iel 'duor "agazine **I4I+5*+ Eerald 'duor
43 Timothy Bafula "agazine *+I4I+5*+ Uanet Be%esa
43 Timothy Bafula ,aptop *-I4I+5*+ Ahmed Amin
41 "unyalo "utua "agazine **I*5I+5*+ Sasyo%a "unyalo
4 <red Sariu%i ,etter *)I**I+5*+ Tom "aina
43 Timothy Bafula ,aptop *-I**I+5*+ Ahmed Amin
41 "unyalo "utua "agazine **I*+I+5*+ Sasyo%a "unyalo
43 Timothy Bafula ,aptop *-I*+I+5*+ Ahmed Amin
41 "unyalo "utua "agazine *2I*+I+5*+ Sasyo%a "unyalo
AiiB. Insertion anomaly
This anomaly causes an inability to add information to the database due to a
lac% of some related value.<or e8ample, to insert details of a new sender say
T&ichard "uriu%iT the user must enter sender0o value else the system will
not allow those details into the system.
AiiiB. Delete anomaly
"ay occur when the deletion of data representing certain facts results into
deletion of data representing completely diAerent data.<or e8ample if the
user deletes third row containing sender0o, then details containing
sender,description,date and recipient in that row will be lost as well.
1%
..0. )ormali?ation ste3s
ata is organized into database tables by using normal forms rules or
conditions. These rules help to ma%e a good database design. Eenerally we
organize the data up to third normal form. Be rarely use the fourth and ffth
normal forms.
!egin with a list of all of the felds that must appear in the database.
Thin% of this as one big table.
o not include computed felds
Rou can get this information from a printed document used by the system
e.g. reports.
Additional attributes besides those for the entities described on the
document can be added to the database.
AiB. Eirst )ormal 9E)E6:
It is a relation in which the intersection of each row and column contains one
and only one value 6atomic values7. 0o repeating groups are allowed.
Ste3s
&emove repeating groups
;reate separate tables for each group of related data and identify
each row with a primary %ey.
AiiB. Second )ormal Eorm 9S)E6
It is a relation that is in frst normal form and where every non?primary?%ey
attribute is fully functionally dependent on the primary %ey. 0o partial
dependencies are allowed.
Ste3s:
Ensure that the table is in the frst normal form.
&emove partial dependencies and put the partially dependent
attributes in a separate table.
AiiiB. 4"ird )ormal Eorm94)E6
A relation that is in frst and second normal form, and in which no non?
primary?%ey attribute is transitively dependent on the primary %ey.
Ste3s:
Ensure that the table is in the second normal form.
&emove transitive dependencies and create relationship between
newly created table with their predecessors using foreign %eys.
78am3le:
;onsider the report below about customer rental information. 0ormalize this
report to third normal form.
2&
Solution:
!egin by listing all of the felds that must appear in the database. This will
result into a big table. 0otice the report title , page number and its date are
not necessary since they do not necessary reside in the database. This
produces an unnormalized form.
Customer
-)o
Customer-
)ame
5ro3erty-
)o
5ro3erty-
address
/ent-
start
/ent-
Einis"
/ent +&ner-
)o
+&ner-
)ame
;u5)- Uohn
"wendwa
CE- !'O *+)
0&!
*?5+?
+5*5
*?5+?+5*+ *+5555 ;5*+) "ary
"utia
;u5)- Uohn
"wendwa
CE*1 !o8 *+
Thi%a
+?5+?
+554
+?5+?+5*) +55555 ;541 "ariana
'uma
Eirst normal %orm
#eparate repeating groups into new Tables.
&epeating groups are felds that may be repeated several times for one
documentIentity
;reate a new table containing the repeating data
In this case ;ustomerP0ame is repeated and must be removed and placed
in a new relation.
5/+57/4>
Customer)o 5ro3erty)o 5ro3ert#ddres
s
/entstar
t
/ent;nis" /ent +&ner)o +&ner)ame
;u5)- CE- !o8 *+) 0&! *?5+?
+5*5
*?5+?+5*+ *+55
55
;5*+) "ary "utia
;u5)- CE*1 !o8 *+ Thi%a +?5+?
+554
+?5+?+5*) +555
55
;541 "ary 'uma
CCS4+*7/
Customer)o Customer)ame
;=5)- Uohn "wendwa
Second normal %orm
21
=sed where the table has composite %ey. All partially dependent attributes
are removed and placed in a new table. A copy of the primary %ey is used to
identify the attributes in this new table. In this case there are three %ey
attributes in the original table6Croperty?0o,;ustomer?0o,'wner?0o7.
'wner0ame only depends on 'wner0o6Cartial dependency7. This attribute is
removed together with a copy of the %ey 'wner?0o.
5/+57/4>
Customer)
o
5ro3erty)o 5ro3ert#ddres
s
/entstar
t
/ent;nis" /ent +&ner)o
;u5)- CE- !o8 *+) 0&! *?5+?
+5*5
*?5+?+5*+ *+55
55
;5*+)
;u5)- CE*1 !o8 *+ Thi%a +?5+?
+554
+?5+?+5*) +555
55
;541
CCS4+*7/
Customer)
o
Customer)a
me
;=5)- Uohn "wendwa
+<)7/
+&ner)o +&ner)ame
;5*+) "ary "utia
;541 "ary 'uma
4"ird normal %orm
In this step, remove transitive dependencies. Transitive dependency is a type
of functional dependency where an attribute is functionally dependent on an
attribute other than the primary %ey. Thus its value is only indirectly
determined by the primary %ey.
;reate a separate table containing the attribute and the felds that are
functionally dependent on it. Seep a copy of the %ey attribute in the original
table.
In this case rent6Amount7 is transitively dependent on the rentPstart and
rentPfnish.
&emove this attribute create a primary to identify its value e.g. &entP0o. The
copy of this %ey must remain in the original table.
5/+57/4>
Customer
)o
5ro3erty
)o
+&ner)o 5ro3ert#ddre
ss
/entstart /ent;nis" /ent)o
;u5)- CE- ;5*+) !o8 *+) 0&! *?5+?+5*5 *?5+?+5*+ &*
;u5)- CE*1 ;541 !o8 *+ Thi%a +?5+?+554 +?5+?+5*) &+
CCS4+*7/
Customer)
o
Customer)a
me
;=5)- Uohn "wendwa
+<)7/
+&ner)o +&ner)ame
;5*+) "ary "utia
;541 "ary 'uma
/7)4
/ent)o /ent
&* *+5555
&+ +55555
22
..2. /evision 1uestions
9a:. 0ormalize the following invoice to third normal form.
9b:. The following report is how an ine8perienced database developer might
create a table. Rour mission is to get into )
rd
0ormal <orm.
*aina *usic stores
7mail: mains"Hmain.co.'e
*ovie issuance re3ort

Custome
r ID
Last
)am
e
*ovie
ID
*ovie 4itle :endor 4y3e
C"ec' +ut
Date
/eturn Date
*55* !arns *5*
"ovie *
A;" A;T *I*I+5
5+
*I+I+55+
*55* !arns *5+
"ovie +
A;" ;'" *I*I+5
5+
*I+I+55+
*55* !arns *5)
"ovie )
A;" &A *I*I+5
5+
*I/I+55+
*55* !arns *5-
"ovie -
A;" &A *I*I+5
5+
*I1I+55+
*55* !arns *5/
"ovie /
A;" &A *I*I+5
5+
23
ABC& co
a!" #$#4%%4
E&a'(" )u*'+tec,.co.-e
INVOICE
#5&"&&
IN.OICE N/MBER"
21&&45
PROD/CT N/MBER"
1&2546
PROD/CT NAME"
4lash (is3
.ENDOR NAME"
5upiter +echnologies
0/ANTIT1"
3
PROD/CT
PRICE"
21
st
"4ebruary"2&13 DATE"
*aina *usic stores
7mail: mains"Hmain.co.'e
*ovie issuance re3ort

Custome
r ID
Last
)am
e
*ovie
ID
*ovie 4itle :endor 4y3e
C"ec' +ut
Date
/eturn Date
*55* !arns *51
"ovie1
!! &A *I*I+5
5+
*55* !arns *52
"ovie2
!! ;'" *I*I+5
5+
*55* !arns *53
"ovie3
A;" ;'" *I*I+5
5+
*55* !arns *54 "ovie4 A;" ;'"
9c:. To %eep trac% of o@ce furniture, computers, printers, and so on, the
<oundTech company uses the following table structure. 0ormalize this table
to T.0.<
#ttribute name Sam3le value
Item,)umber +)44445
Item,Descri3tio
n
.C es%Uet 115c printer
/oom)o )++
/oom)ame I;T
-uildin$)ame !iashara Towers
9d:. 0ormalize the sales order below to third normal form.
9e:. 0ormalize the table below used to store students and advisor
information to third normal form.
24
student)
o
#dvisor)
o
#dvisor)a
me
#dvisor/o
om
Class
1
Class
2
**I5+-)- 5*+4 Senga T;)?)) !IT* IT)
*+I5+)-/ 5*+3 Ban(i%u T;)?)- IT- !IT*
9f:. efne the term normalization with respect to logical design. 9+
"ar%s:
9g:. escribe three anomalies that are associated with bad database
design. 91 "ar%s:
9h:. =se the form below to normalize it to third normal form
..10. Summary
In this lesson you have learnt database normalization. Three normal forms
were discussed here. The frst, second and third normal forms. The ob(ective
of the frst normal form is to divide the =0< data into tables and assign a
primary %ey to each table. The ob(ective of the second normal form is to ta%e
data that is partially dependent on the primary %ey and enter that data into
another table. <inally, the ob(ective of the third normal is to remove data that
is not dependent on the primary %ey and place it in a new table.
..11. Su$$ested readin$
9*:. #ilberschatz A. and et al 6+55*7, atabase #ystem ;oncepts, "cEraw?
.ill.
9+:. Earcia?"olina .. and et al 6+5557, atabase #ystem$ The complete
!oo%, Crentice .all.
9):. Elmasri &. and 0avathe #6+5557, <undamentals of atabase #ystem,
Addison Besley.
9-:. ;onollyG !egg, atabase #ystem$ a practical approach to design,
implementation and management, Crentice .all.
Lesson 0: Database mana$ement systems
0.1. Introduction
In our previous lesson you learnt about database normalization. In this lesson
you will learnt about database management systems 9!"#:$ components of
a !"#, functions of a !"#, functions of !"#, selection of !"# and
e8amples of !"#.
0.2. Lesson objectives
!y the end of this lesson you will be able to$
escribe various components of a !"#
escribe the procedure of !"# selection
;ompare various !"# products
0.3. Lesson outline
This lesson is organized as follows$
3.*. Introduction
3.+. ,esson ob(ectives
3.). ,esson outline
25
3.-. !"# components
3./. ;omponents of atabase manager
3.1. !"# products
3.2. <unctions of !"#
3.3. &evision questions
3.4. #ummary
3.*5. #uggested reading
0.. D-*S com3onents
A !"# is a software pac%age that carries out many diAerent tas%s such as
provision of facilities to enable the user to access and modify information in
the database. atabase management system is composed of fve ma(or
components namely ", compiler, Fuery processor, , compiler, database
manager and fle manager.
9a:. D*L 5re com3iler$ ", pre compiler converts ", statements embedded
in an application program to normal procedural calls in the host language. It
interacts with the query processor in order to generate the appropriate code.
9b:. DDL com3iler$ , compiler converts , statements into a set of tables
containing metadata tables V which are in a form that can be used by other
components of the !"#. These are stored in system catalog or data dictionary.
9c:. Eile mana$er$ "anages the allocation of space on dis% storage.
9d:. Iuery 3rocessor: &esponsible for receiving query language statements and
changing to a form the !"# can understand. It has two parts $ 6i7 parser 6ii7
query optimizer.
AeB. 5"ysical database
i. Data ;les: these store the database itself .
ii. Catalo$J Data dictionary: stores the metadata about the structure of
the database. The data dictionary is heavily used and great emphasis
needs to be placed on developing a good design and e@cient
implementation of the dictionary.
b7 Database mana$er$ It is the interface bIw low?level data, application programs
and queries. It enforces constraints to maintain the consistency and integrity of
the data as well as its security. It synchronizes the concurrent access. It also
perform bac%up and recovery operations.
26
Eeneral users
Fuery Application
programs

#ystem
calls
atabase
schema

'b(ect
code of
program
",
compiler
Fuery
processor
,
compiler

atabase
manager
<ile
manager
ata
fles
ata
dictionary
Application programmers #ophisticated users
atabase
adm
Ei$ure 2: D-*S com3onents
0.(. 4"e com3onents o% database mana$er:
9i:. #ut"ori?ation Control: ;hec%s that the user has necessary
authorization to carry out the required function.
9ii:. Command 5rocessor: ;onverts commands to a logical
sequence of steps.
9iii:. Inte$rity C"ec'er$ ;hec%s the requested operation satisfes
all necessary integrity constraints such as %ey constraints.
9iv:. Iuery +3timi?er: E8amines the query language statements
and tries to choose the best and most e@cient way to e8ecuting the
query. <actors considered V ;C= time, dis% time, networ% time, sorting
methods and scanning methods.
9v:. 4ransaction *ana$er: The transaction manager maintains
tables of authorization concurrency. #upervises the data transactions
that are carried out between the database manager and fle manager.
9vi:. Sc"eduler: It controls the relative order in which transaction
operations are e8ecuted.
9vii:. /ecovery *ana$er: Ensures that the database remains in a
consistent state in the presence of failures. &esponsible for transaction
commit and abort.
9viii:. -uKer *ana$er: &esponsible for the transfer of data between
main memory and secondary storage.
2#
Ei$ure 3: Database mana$er com3onents
0.6. D-*S 5roducts
AaB. *icroso%t SIL Server
"icrosoft #F, #erver is a relational database management system produced
by "icrosoft. It supports "icrosoftHs version of #tructured Fuery ,anguage
6#F,7. "icrosoft #F, #erver is a comprehensive database platform providing
enterprise?class data management with integrated business intelligence 6!I7
tools. The "icrosoft #oft #F, #erver database engine provides secure,
reliable storage for both relational and structured data, enabling to build and
manage highly available, performing data applications. "s #F, #erver
combines the best in analysis, reporting, integration, and notifcation. This
enables building and deployment of cost?eAective !I solutions .It has close
integration with "icrosoft Disual #tudio, the "icrosoft '@ce #ystem, and a
suite of new development tools, including the !usiness Intelligence
evelopment #tudio.
AbB. +racle
'racle database server is an ob(ect?relational database management
systemJ this is the frst database designed for enterprise grid computing. The
'racle grid architecture pools large numbers of servers, storage, and
2$
Crogram
ob(ect code
Fuery
processor
;atalog
manager
Authorization
control
Integrity
chec%er
;ommand
processor
Fuery optimizer
Transaction
manager
#cheduler
!uAer
manager
&ecovery
manager
Access
methods
<ile manager
#ystem
buAers
atabase G system catalog
networ%s into a >e8ible, on?demand computing resource for enterprise
computing needs.
'racle atabase provides a high degree of self?management ? automating
routine !A tas%s and reducing comple8ity of space, memory, and resource
administration.
'racle has a number of products and features that provide high availability
in cases of unplanned downtime or planned downtime. These include <ast?
#tart <ault &ecovery, &eal Application ;lusters, &ecovery "anager 6&"A07,
bac%up and recovery solutions, 'racle <lashbac%, partitioning, 'racle ata
Euard, ,og"iner, multiple8ed redo log fles, online reorganization. These can
be used in various combinations to meet specifc high availability needs.
AcB. *ySIL
"y#F, is a multithreaded, multi?user, #F, 6#tructured Fuery ,anguage7
atabase "anagement #ystem 6!"#7 with an estimated si8 million
installations. "y#F, A! ma%es "y#F, available as free software under the
E0= Eeneral Cublic ,icense 6EC,7, but they also sell it under traditional
commercial licensing arrangements for cases where the intended use is
incompatible with use of the EC,. There are ACIs available that allow
applications written in numerous programming languages to access "y#F,
databases, including$ ;, ;QQ, ;W, EiAel, #malltal%, Uava, ,isp, Cerl, C.C,
Cython, &uby e.t.c. each of these using a specifc ACI. An '!; interface
called "y'!; allows additional programming languages that support the
'!; interface to communicate with a "y#F, database.
AdB. 5ost$reSIL
Costgre#F, is a free ob(ect?relational database server 6database
management system7, released under a >e8ible !#?style license. It oAers
an alternative to other open?source database systems 6such as "y#F, and
<irebird7, as well as to proprietary systems such as 'racle, #ybase, I!"Hs !+
and "icrosoft #F, #erver. #imilar to other open?source pro(ects such as
Apache and ,inu8, Costgre#F, is not controlled by any single company, but
relies on a community of global developers and companies to develop it.
AeB. D-2
The !+ is I!"Hs family of information management software products. !+
=niversal atabase 6!+ =!7 is a relational database management system
that delivers a >e8ible and cost?eAective database platform to build robust
on demand business applications. !+ =! further leverages resources with
broad support for open standards and popular development platforms li%e
U+EE and "icrosoft .0ET. The !+ =! family also includes solutions tailored
for specifc needs li%e business intelligence and advanced tooling.
I!" and !+ are frequently at or near the top of the TC;?; 6',TC7 and TC;?.
6data warehousing7 industry benchmar%s published on the transaction
processing councilHs website.
!+, li%e 'racle, can be administered from either the command?line or a E=I.
The command?line interface requires more %nowledge of the product but can
be more easily scripted and automated. The E=I is a multi?platform Uava
client that contains a variety of wizards suitable for novice users. !+ has
2%
ACIs for .0ET ;,I, Uava, Cython, Cerl, C.C, ;QQ, ;, &EOO, C,II, ;'!',, &CE,
<'&T&A0, and many other programming languages. !+ also supports
integration into the Eclipse and Disual #tudio .0ET integrated development
environments.
A%B. Sybase SIL
#ybase #F, #erver was the name of #ybase ;orporationHs primary relational
database management system product from *432 to *44/.
It was originally created for =0IO platforms in *432. In *433, #F, #erver for
'#I+ was codeveloped for the C; by #ybase, "icrosoft, and Ashton?Tate.
Ashton?Tate divested its interest and "icrosoft became the lead partner after
porting #F, #erver to Bindows 0T.
"icrosoft and #ybase sold and supported the product through version -.+*.
In *44) the codevelopment licensing agreement between "icrosoft and
#ybase ended and the companies parted ways while continuing to develop
their respective versions of the database management system.
In *44/, #ybase released #F, #erver **.5. Thereafter, it decided to better
diAerentiate its product from "icrosoft #F, #erver by renaming it to Adaptive
#erver Enterprise in versions **./ and beyond.
A$B. In%ormi8
Informi8 is a family of relational database management system products
from I!", acquired in +55* from a company 6also called Informi87 which
dates its origins bac% to *435.
The Informi8 !"# started from the pioneering Ingres system that also led to
#ybase and "icrosoft #F, #erver. <or a period during the *445s Informi8 was
the second most popular database system, after 'racle. #uccess did not last
very long, however, and by +555 a series of management blunders had
signifcantly wea%ened the company fnancially.
In +55* I!", prompted by a suggestion from Bal?"art 9*:, purchased
Informi8. I!" has long?term plans to merge Informi8 technology into !+,
though as of +55- it continues to release enhanced versions of the Informi8
product line. In early +55/, I!" released version *5 of Informi8 I#.
A"B. *icroso%t #ccess
"icrosoft Access is a relational database management system from
"icrosoft, pac%aged with "icrosoft '@ce Crofessional which combines the
relational "icrosoft Uet atabase Engine with a graphical user interface. It
can use data stored in AccessIUet, #F, #erver, 'racle, or any '!;?
compliant data container. It supports substantial ob(ect?oriented 6''7
techniques but falls short of being a fully '' development tool.
Access is widely used by small businesses to create ad hoc customized
systems for handling small tas%s. #ome professional application developers
use Access for rapid application development, especially for the creation of
prototypes and standalone applications that serve as tools for on?the?road
salesmen. Access does not scale well if data access is via a networ%, so
applications that are used by more than a handful of people tend to rely on a
;lient?#erver based solution such as 'racle, !+, "icrosoft #F, #erver,
Costgre#F,, "y#F,, or "a8!. .owever, an Access Xfront endX 6the forms,
3&
reports, queries and D! code7 can be used against a host of database
bac%ends, including Access itself, #F, #erver, 'racle, and any other '!;?
compliant product. This approach allows the developer to move a matured
applicationHs data to a more powerful server without sacrifcing the
development already in place.
0... Eunctions o% D*-S
atabase creation 6storing data in a defned database7 using data defnition
language
&etrieval 6query and reporting7 using data manipulation language.
=pdate 6;hanging the contents of the database7 using data manipulation
language.
Crogramming user facilities for system development.
atabase revision and restructuring using data manipulation language.
atabase integrity control using data defnition language
Cerformance "onitoring
;oncurrency controlJ controlling simultaneous access to the database
0.0. /evision 1uestions
9a:. =sing e8amples describe relational management systems 9&!"#:
9b:. escribe the steps for selecting a !"# product.
9c:. iscuss four components of database manager
9d:. #tate and e8plain any four factors considered when selecting a !"#
product.
0.2. Summary
In this lesson you have learnt about database management systems 9!"#:$
components of !"#, how to select !"# products and diAerent functions of
!"#.
0.10. Su$$ested readin$
9*:. #ilberschatz A. and et al 6+55*7, atabase #ystem ;oncepts, "cEraw?
.ill.
9+:. Earcia?"olina .. and et al 6+5557, atabase #ystem$ The complete
!oo%, Crentice .all.
9):. Elmasri &. and 0avathe #6+5557, <undamentals of atabase #ystem,
Addison Besley.
9-:. ;onollyG !egg, atabase #ystem$ a practical approach to design,
implementation and management, Crentice .all.
Lesson 2: 5"ysical database desi$n
2.1. Introduction
In the last lesson, you learnt database management systems 9!"#:.In this lesson
you will learn about physical database design$ selection !"#, selection of storage
devices, determining access methods, determination of database distribution,
construction of data dictionary and fnally construct physical data model.
2.2. Lesson objectives
!y the end of the lesson the learner will be able to$
iscuss the activities performed during database design
31
;ompare and contrast logical and physical data models
escribe the features of a physical data model.
2.3. Lesson outline
This lesson is organized as follows$
4.*. Introduction
4.+. ,esson ob(ectives
4.). ,esson outline
4.-. efnition
4./. Chysical database design activities
4.1. ,ogical versus physical data models
4.2 &evision questions
4.3. #ummary
4.4. #uggested reading
2.. De;nition
This is a process of constructing a model of information used in an organization
based on physical considerations li%e software and hardware. Chysical design is
concerned on how the database is organized as fles and what %ind of structures to
use for e@ciency of database processing
2.(. 5"ysical database desi$n activities
This phase includes a number of tas%s$
#elect !"#
#elect storage devices
etermine access methods
esign fles and inde8es
etermine database distribution
Croduce the physical model and validate with the users
AaB. Selection o% D-*S
A formal procedure is followed to select a suitable !"# product. A number of
factors must be ta%en into account when choosing a !"# product.
Eactors considered &"en selectin$ t"e D-*S
;osts
<eatures and Tools
=nderlying model
Cortability
!"# hardware requirements
#ecurity
=sability
*ain ste3s to selectin$ a D-*S:
efne terms of reference of study
#hortlist two or three products
Evaluate products
&ecommend selection and produce report.
AbB. Selection o% stora$e devices
At this stage, select a suitable secondary storage device. #ome of the factors
considered when selecting a storage devices$
#peed with which data can be accessed
32
;ost per unit of data
&eliability$ loss on power failure or system crash and physical failure of
the storage device
AcB. Determine access met"ods
In this step identify specifc structures and access methods for the data to
achieve optimum performance for the database system. The access method
depends on storage structure. #ome of the access methods are$
#equential
Inde8ed sequential
.ashing
AdB. Desi$n ;les and inde8es
This involves designing a set of tables and constraints on these tables from
the information given in logical data model. The tables are designed and
their feld properties specifed.
SC55LI7/ 4#-L7
Eield)ame Data
ty3e
Len$t"
#upplierI 0umber 3
#upplier0am
e
Te8t /5
Address Te8t /5
#treet Te8t /5
+/D7/ 4#-L7
Eield)ame Data
ty3e
Len$t"
'rderI Te8t /5
'rder0ame Te8t /5
ateprepare
d
ateITime
#upplierI 0umber 3
5/+DCC4 4#-L7
Eield)ame Data
ty3e
Len$t"
CroductI Te8t )5
Croduct0am
e
Te8t 15
Fuantity 0umber 3
'rderI Te8t /5
AeB. Determine database distribution
There is need to consider location and number of users when deciding the
database distribution. <or instance the database may single user database in
which case the database can be stored in a local computer, multiuser
database may stored in a dedicated server where users can access
simultaneously. If the users are not within the same location and the
33
organization has several branches in diAerent locations, then a distributed
database may be used.
A%B. Construction o% 3"ysical data model
Chysical data model represents how the model will be built in the database.
A physical database model shows all table structures, including column
name, column data type, column constraints, primary %ey, foreign %ey, and
relationships between tables.
A$B. Constructin$ 3"ysical data model
!uilding of physical data models is done as follows$
;onvert entities into tables.
;onvert relationships into foreign %eys.
;onvert attributes into columns.
<or each column, specify data type and column size.
Ei$ure: 5"ysical data model
Eeatures o% a 3"ysical data model include:
#pecifcation of all tables and columns.
<oreign %eys are used to identify relationships between tables.
e?normalization may occur based on user requirements.
Chysical considerations may cause the physical data model to be quite
diAerent from the logical data model.
/emar': Chysical data model will be diAerent for diAerent &!"#. <or
e8ample, data type for a column may be diAerent between "y#F, and #F,
#erver.
A"B. Construction o% data dictionary
ata dictionary 6or system catalog7 is a database about the database.The
contents of a data dictionary are usually referred to as metadata
Im3ortance o% data dictionaryL
Crovides a summary of the structure of the database.
<acilitates communication between users and database administrators
34
*
M

1
M
CS

<S
5/+DCC4
CroductI$ Te8t6)57
Croduct0ame$ Te8t6157
Fuantity$
0umber637
'rderI $
Te8t6/57
CS

<S
+/D7/
'rderI$ Te8t6/5
'rder0ame$ Te8t6/57
ateCrepared$ Te8t6/57
#upplierI $ 0umber
637
CS
SC55LI7/
#upplierI$
0umber637
#uppler0ame$
Te8t6/57
Address$
Te8t6/57
#treet$
Te8t6/57
Allows the !"# to manage the creation, access, and modifcation of
tables and their components.
.elps in system documentation.
;an be used for reference when designing the database.
4y3es o% data dictionaries:
9i:. Integrated data dictionary?Its integrated with the !"#. &elational
systems all have some form of integrated 6e.g., 'racle7.Integrated
is usually active, meaning it is automatically updated to re>ect changes in
the database
9ii:. A stand?alone data dictionary? is not directly lin%ed to the database and
must be updated manually.
4able #ttributes 5rimary
'ey
Eorei$n
'ey
Data ty3e Eield si?e /e1uired
5/+DCC4 CroductI Res 0o Te8t )5 Res
Croduct0ame 0o 0o Te8t 15 0o
Fuantity 0o 0o 0umber 3 0o
'rderI 0o Res Te8t /5 0o
SC55LI7/ #upplierI Res 0o 0umber 3 Res
#upplier0ame 0o 0o Te8t /5 0o
Address 0o 0o Te8t /5 0o
#treet 0o 0o Te8t /5 0o
+/D7/ 'rderI Res 0o Te8t /5 Res
'rder0ame 0o 0o Te8t /5 0o
ateCrepared 0o 0o Te8t /5 0o
#upplierI 0o Res Te8t )5 0o
Table$ ata dictionary
2.6. Lo$ical data model versus 5"ysical data model
;omparing the physical data model with the logical data model, we see the
main diAerences between the two$
Entity names are now table names.
Attributes are now column names.
ata type for each column is specifed. ata types can be diAerent
depending on the actual database being used.
2... /evision 1uestions
9a:. escribe the procedure for selecting a database management system
6!"#7.
9b:. ;ompare and contrast logical and physical data models.
9c:. escribe the process of physical database design.
9d:. !rie>y e8plain the following database storage devices.
9e:. E8plain the following database access methods.
9i:. .ash
9ii:. Inde8ed sequential access
9f:. escribe any three functions of a data dictionary
2.0. Summary
In this lesson you have learnt that physical database design involves a series of
activities$ selection of !"# and storage devices, choosing access methods,
designing fles and inde8es, determining database distribution, construction of
physical data model and a data dictionary.
35
2.2. Su$$ested readin$
9*:. #ilberschatz A. and et al 6+55*7, atabase #ystem ;oncepts, "cEraw?
.ill.
9+:. Earcia?"olina .. and et al 6+5557, atabase #ystem$ The complete
!oo%, Crentice .all.
9):. Elmasri &. and 0avathe #6+5557, <undamentals of atabase #ystem,
Addison Besley.
9-:. ;onollyG !egg, atabase #ystem$ a practical approach to design,
implementation and management, Crentice .all.
Lesson 10: Database transactions and concurrency control
10.1. Introduction
In our previous lesson we discussed physical database design. In our lesson
today, we will learn transaction management. Transaction management
deals with the problem of always %eeping the database in a consistent state
even when concurrent accesses and failures occur. The important point is
that the database should be consistent when the transaction terminates.
10.2. Lesson objectives
!y the end of this lesson, the learner will be able to$
=nderstand transaction basics$ defnition, A;I properties and transaction
states.
=nderstand the ob(ective and tools of concurrency control
=nderstand failure types and the tools used in recovery management
Eain insight about transaction design issues.
Appreciate the role of transaction management in the larger area of wor%>ow
management
10.3. Lesson outline
This lesson is structured as follows$
*5.*. Introduction
*5.+. ,esson ob(ectives
*5.). ,esson outline
*5.-. Transaction
*5./. Transaction properties
*5.1. Transaction states
*5.2. Transaction e8ecution
*5.3. Interference between concurrent transactions
*5.4. ;oncurrency control
*5.*5. ,oc% based protocols
*5.**. Types of loc%s
*5. *+. &evision questions
*5.*). #ummary
*5.*-. #uggested reading
10.. 4ransaction
36
A transaction is a series of operations carried out by a single user or
application program that must be treated as a logical unit of wor%. A
transaction transforms the database from one consistent state to another
consistent state.
78am3le
!egin
EOE;#F, =CATE #ales
#ET ;ostY;ostZ*.+
B.E&E <irst0ameYNUamesN
End
10.(. 4ransaction 3ro3erties
To ensure the integrity of data the four transaction properties must be fulflled by
any transaction.
9a:.#tomicity V This property ensures that for each transaction, either the eAects of
all or none of its operations remain when a transaction is completed
6committed or aborted respectively7. Transactions are never left partially
e8ecuted.
9b:.Consistency VThis property requires that every transaction must leave
the database in a consistent 6correct7 state, i.e., maintain the
predetermined integrity rules of the database. A transaction must
transform a database from one consistent state to another consistent
state.
9c:. Isolation ? Transactions cannot interfere with each other. Transactions
must behave as if they were e8ecuted in isolation.
9d:.Durability ? EAects of successful 6committed7 transactions must persist
through crashes. Typically achieved by recording the transactionHs eAects
and its commit event in a non?volatile memory.
10.6. 4ransaction states
9i:. #ctive$ This is the initial sate$ the transaction is in this state when it is
e8ecuting.
9ii:. 5artially committed$ The state after the last statement has been
e8ecuted.
9iii:. Committed: The state after successful completion.
9iv:. Eailed: #tate after discovery that a normal e8ecution is no longer
possible. ;an be as a result of logical error 6e.g. bad input7, system
error6e.g. deadloc%7 or system crash.
3#
10... 4ransaction e8ecutions.
Transaction e8ecutions can be classifed as$
a7 Serial e8ecution: Each operation within a transaction can be e8ecuted
atomically. T*NOONTn. This method produces best result but is slow.
b7 5arallel e8ecution$ #everal transactions e8ecuting simultaneously. Bhile it
improves the throughput, resource utilization and response time. !ut too
much parallelism can lead to wrong results.
10.0. Inter%erence bet&een concurrent transactions
There are many ways in which concurrently e8ecuting transactions can interfere
with one answer and so compromise the integrity and consistency of the
database.
a6 Lost 9buried6 u3date 3roblem
This problem occurs when a successfully completed update operation by one
transaction is overwritten by another transaction. ;onsider the e8ample below$
4ime 4ransaction
#
4ransaction
-
T* &ead & ?
T+ ? &ead &
T) Brite & ?
T- ? Brite &
Thus transaction ANs update is lost at time T- because transaction ! overwrites it
without even loo%ing at it 6Bithout reading &7.
78am3le: !an% balances
4ime 4ransaction # 4ransaction -
T* &etrieve &ecord ?
T+ ? &etrieve the same record
T) =pdate the record on the basis of
values read at T*
?
T- ? =pdate the record on the basis of
values read at T+
Solution to lost u3date 3roblem.
3$
S4#/4 4/#)S 7)D
4/#)S

#-+/4
C+**I4
/+LL-#C@
#bort

#ctive

5artially
committ
ed
Eail
#borte
d

Commit
ted
The lose of transaction ANs update is avoided by preventing transaction ! from
reading the value of & until after transaction ANs update has been completed. Thus
write loc% & at T*.
b6 Cncommitted de3endency 9Dirty read63roblem
This is a violation of the integrity constraints governing the database that arise
when two transactions are allowed to e8ecute concurrently without being
synchronized. 'ne of the transaction will read value being updated by another
transaction before it has been committed.
4im
e
4ransaction
#
4ransaction -
T* ? Brite &
T+ &ead & ?
T) ? &',,!A;S
78am3le: -an' balances.
4im
e
4ransaction # 4ransaction -
T* ? ;alculate discount as /[ for cost Ssh
*555
T+ &ead discount ?
T) ? &',,!A;S
Transaction A is operating on false assumption that discount 6 5.5/ O *5557 still
e8ists\ That is transaction A becomes dependent on uncommitted update at time
T+.
Solution to uncommitted de3endency 3roblem.
The problem is avoided by preventing transaction A from reading the value of &
until after the decision has been made to commit or abort transaction !Ns eAect.
Thus write loc% & at T*.
c6 Inconsistent analysis 9)on-re3eatable read6 3roblem.
Transactions that only read the database can obtain inaccurate results if they are
allowed to read partial results of incomplete transactions, which are simultaneously
updating the database.
;onsider two transactions A and ! operating on ban% account records. Transaction A
is transferring an amount *5 from account* to account).
Initially account*Y*55, account+Y/5 and account)Y+/.
4im
e
4ransactio
n #
4ransactio
n -
#cc1 #cc2 #cc3 Sum
T* &ead Acc* &ead Acc* *55 /5 +/ 5
T+ Acc*?*5 #umQAcc* *55 /5 +/ *55
T) Brite Acc* &ead Acc+ 45 /5 +/ *55
T- &ead Acc) #umQAcc+ 45 /5 +/ */5
T/ Acc)Q*5 ? 45 /5 )/ */5
T1 Brite Acc) ? 45 /5 )/ */5
T2 ;ommit &ead Acc) 45 /5 )/ *3/
T3 ? #umQAcc) 45 /5 )/ *3/
T4 ? ;ommit 45
0otice transaction ! produces an inconsistent analysis of *3/ instead of *2/\
Solution to inconsistent analysis 3roblem
3%
The inconsistent analysis problem can prevented by loc%ing the transaction doing
the analysis until the updates by transaction A are completed. i.e. &ead loc% & at T*.
d6 5"antom read
Chantom reads occur when an insert or delete action is performed against a
row that belongs to a range of rows being read by a transaction. The
transactionHs frst read of the range of rows shows a row that no longer e8ists
in the second or succeeding read, as a result of a deletion by a diAerent
transaction. #imilarly, as the result of an insert by a diAerent transaction, the
transactionHs second or succeeding read shows a row that did not e8ist in the
original read.
Initially
7m3)
o
7m3)ame
E55* Uames Seen
E5*+ Uanet Seen
E5*/ Uohn
"organ
E5+) "ary
Uohnson
Transaction ! selects all the records where name begins with U at T+.
Transaction A inserts a new record at T/.
Transaction A$ I0#E&T I0T' E"C,'REE 6Emp0o,Emp0ame7 DA,=E#
6]E55)N,NUanet Uac%sonN7
Transaction !$ #E,E;TZ <&'" E"C,'REE B.E&E Emp0ame ,ISE ]U[N
4ime 4ransaction
#
4ransaction -
T* &ead
6Employee7
&ead 6Employee7
T+ #elect records
T) Insert new
record
T- #elect records
T/
Solution to 3"antom reads
Chantom reads can be prevented by using serializable isolation level. This
level acquires range loc%s to prevent read, modifcation and insert operation
on other transaction until the frst transaction gets completed. Sey?range
loc%s protect a range of rows implicitly included in a record set being read by
a transaction while using the serializable transaction isolation level. The
serializable isolation level requires that any query e8ecuted during a
transaction must obtain the same set of rows every time it is e8ecuted
during the transaction. A %ey range loc% protects this requirement by
preventing other transactions from inserting new rows whose %eys would fall
in the range of %eys read by the serializable transaction. A %ey?range loc% is
placed on an inde8, specifying a beginning and ending %ey value. This loc%
bloc%s any attempt to insert, update, or delete any row with a %ey value that
4&
falls in the range because those operations would frst have to acquire a loc%
on the inde8.
10.2. Concurrency control
Sc"edule: It is a set of operations performed by transactions in the database. The
order in the schedule is very important.
A schedule consists of all or some of the following operations.
/ead986: "eans reading an item from the database.
<rite986: "eans writing value of 8 bac% to the database.
Commit: At the end of transaction, do all the changes.
#bort: iscard all the changes.
E8ample$ #uppose 4 N /N < and C represents transaction, &ead, write and commit
respectively.
;onsider two transactions T* and T+.
T*$ &*687, B*687, ;*687
T+$ &+687, B+687, ;+687
These transactions can be interleaved in any order and thus results diAer.
e.$. &*687,B*687, &+687,B+687,;*687;+687.
#uch a sequence of operations performed on the database by some transactions
T*LTn is referred to as a schedule. The transactions %eep continuously e8ecuting in
the database which means as transactions are coming, we are e8ecuting the read
and write operations relating to these transactions and committing or aborting the
transactions at the end of what they performed and the process continues.
Bhatever the operations, transactions must leave the database in a consistent
state.
78am3le$ ;onsider the two schedule below$
#aY9&*687,&+687,B*687,B+687,;*687,;+687:
;onsider 8Y*5, 8Y*5 after the read operations.
8Y/, 8Y*/ after write operations
8Y/, 8Y*/ after commit operations.
Thus after commit, the database will be inconsistent 6Their results may diAer7.
Serial sc"edule
A schedule where new transaction is only e8ecuted after earlier transaction has
completed. #erial schedule is always consistent.
T*$ Is consistent from start to fnish.
T+$ Is consistent from start to fnish.
This is possible if T* e8ecutes from start to fnish before T+ or vise versa.
#erial schedule is slow. !ut it is possible to e8ecute two or transactions concurrently
without interfering with each other.
71uivalent sc"edule
#chedule A and ! are said to be equivalent ifJ
T*LTn operations appear in both schedules.
'perations that are con>icting appear in the same order.
Seriali?able sc"edule
A schedule sa said to be serializable if we are able to transform its operations to
another schedule sb so that the new schedule is equivalent to original schedule .i.e.
con>icting operations if any are in the same order and sb is a serial schedule.
10.10. ConPictin$ o3erations
41
Two operations on the same data item con>ict if at least one of the operations is a
write.
4ransaction
#
4ransaction
-
ConPictQ
&ead687 &ead687 0o
Brite687 Brite687 Res
&ead687 Brite687 Res
Brite687 &ead687 Res
&ea687 &ead6y7 0o
Brite687 Brite6y7 0o
&ead6y7 Brite687 0o
Brite6y7 &ead687 0o
Seriali?ation o% concurrent transactions.
Crocess of managing the e8ecution of a set of transactions in such a way that their
concurrent e8ecution produces the same end result as if they were run serially. To
eliminate concurrency access problems and to implement atomicity, consistency,
and isolation we need two additional operations 6other than read and write7, which
are called ,oc% and =nloc%, and are applied on a data item.
10.11. Loc'--ased 5rotocols
A loc% is a mechanism to control concurrent access to a data item. A loc%ing
protocol is a set of rules followed by all transactions while requesting and
releasing loc%s. ,oc%ing protocols restrict the set of possible schedules. ata
items can be loc%ed in two modes$
78clusive 9F6 mode. ata item can be both read as well as written. O?loc%
is requested using loc%?O instruction.
S"ared 9S6 mode. ata item can only be read. #?loc% is requested using
loc%?# instruction. Transaction can proceed only after request is granted.
A transaction may be granted a loc% on an item if the requested loc% is
compatible with loc%s already held on the item by other transactions. Any
number of transactions can hold shared loc%s on an item, but if any
transaction holds an e8clusive on the item no other transaction may hold any
loc% on the item. If a loc% cannot be granted, the requesting transaction is
made to wait till all incompatible loc%s held by other transactions have been
released. The loc% is then granted.
Loc' 9F6: If a transaction T* applies ,oc% on data item O, then O is loc%ed
and it is not
available to any other transaction.
Cnloc' 9F6: T* =nloc%s O. Thus O becomes available to other transactions.
10.12. 4y3es o% a Loc'
a7 S"ared loc'$ A &ead operation does not change the value of a data
item. .ence a data item can be read by two diAerent transactions
simultaneously under share loc% mode. #o only to read a
data item T* will do$ Share lock (X), then Read (X), and fnally Unlock (X).
42
b7 78clusive loc'$ A write operation changes the value of the data item.
.ence two write
operations from two diAerent transactions or a write from T* and a read from
T+ are not
allowed. A data item can be modifed only under E8clusive loc%. To modify a
data item T* will
do$ Exclusive lock (X), then Write (X) and fnally Unlock (X).
Bhen these loc%s are applied, then a transaction must behave in a special
way. This special
behavior of a transaction is referred to as well-or!ed.
<ell-%ormed transaction$ A transaction is well? formed if it does not loc% a
loc%ed data item and it does not try to unloc% an unloc%ed data item.
10.13. /evision 1uestions
9a:. !rie>y e8plain the meaning of the A;I properties. .ow do
concurrency control and recovery management support the A;I
properties^
9b:. !rie>y e8plain the meaning of transparency as it relates to computer
processing. Bhy is transparency important for concurrency control and
recovery management^
9c:. Bhat costs are associated with concurrency control and recovery
management^ In what role, database administrator or database
programmer, would you assess these costs^
9d:. Bhat is the ob(ective of concurrency control^ .ow is the measure used
in the ob(ective related to waiting time^
9e:. Bhat is a loc%^ !rie>y e8plain the diAerences between shared 6#7 and
e8clusive 6O7 loc%s^
9f:.Bhat operations are performed by the loc% manager^
9g:. Bhat is a deadloc% and how do most !"#s handle deadloc%s^
10.1. Summary
To process transactions concurrently, the database server must e8ecute some
component statements of one transaction, then some from other transactions,
before continuing to process further operations from the frst. The order in which the
component operations of the various transactions are interleaved is called the
schedule.
Applying transactions concurrently in this manner can result in many possible
outcomes. #ometimes, the fnal state of the database also could have been
achieved had the transactions been e8ecuted sequentially, meaning that one
transaction was always completed in its entirety before the ne8t was started. A
schedule is called seriali?able whenever e8ecuting the transactions sequentially, in
some order, could have left the database in the same state as the actual schedule.
#erializability is the commonly accepted criterion for correctness. A serializable
schedule is accepted as correct because the database is not in>uenced by the
concurrent e8ecution of the transactions.
The isolation level aAects a transactionHs serializability. At isolation level ), all
schedules are serializable. The default setting is 5.
10.1(. Su$$ested readin$
43
9*:. "odern atabase "anagement 61th Edition7 UeArey A. .oAer, "ary !.
Crescott, <red &. "c<adden Crentice .allJ 1th edition 6+55+7.
9+:. atabase systems$ practical approach to design, implementation and
management T ;onnolly and ; !egg 6+55-7 Addison Besley 6+55-7.
9):. atabase esign$ ;oncepts and Implementation 6"cgrah?.ill ;omputer
#cience #eries7 Eio Biederhold "cEraw?.ill ;ollegeJ )rd edition 6*44+7
9-:. atabase #ystem ;oncepts Abraham #ilberschatz, et al "cEraw?.ill
#cienceIEngineeringI"athJ - edition 6+55*7.
9/:. atabase "anagement #ystems &aghu &ama%rishnan, et al "cEraw?
.ill ) edition 6+55+7.
91:. http$IIdc8.sybase.comI*+55IenIdbusageIcorrect.html
92:. "tt3:JJ&&&.slides"are.netJsi$nerJtransaction-mana$ement
93:. http$IImsdn.microsoft.comIen?
usIlibraryIms*4*+2+[+3vYsql.*5/[+4.asp8
Lesson 11: Database security and inte$rity
11.1. Introduction
In our previous lesson we learnt database maintenance. In this lesson we will
discuss database security and integrity. In this lesson we defne database security,
discuss the characteristics of database security. 0e8t we discuss database security
threats and counter measures. <inally, in this lesson we discuss various types of
database integrity.
11.2. Lesson objectives
!y the end of this lesson, the learner will be able to$
efne database security
Identify database security threats
escribe countermeasures to database security
Identify and describe various database integrity
11.3. Lesson outline
This lesson is organized as follows$
**.*. Introduction
**.+. ,esson ob(ectives
**.). ,esson outline
**.-. atabase security
**./. ;haracteristics of database security
**.1. atabase security threats
**.2. ;ountermeasures to database security
**.3. atabase integrity
**.4. Types of database integrity
**.*5. &evision questions
**.**. #ummary
**.*+. #uggested reading
11.. Database security
atabase security refers to the process of protecting the database against
unauthorized access to or modifcation of the database, denial of service to
authorized users and provision of service to authorized users. atabase security
44
also involves policing against unauthorized connectivity and distribution of
privileges. atabase security will also involve granting privileges for specifc
database access, revo%ing certain privileges from users, ta%ing measures to protect
other parts of the database such as underlying database fles.
11.(. C"aracteristics o% database security
There are three main characteristics of database security namely$
9a:. Con;dentiality$ This refers to protection against disclosure to
authorized parties
9b:. Inte$rity: This involves ensuring that data is not accidentally or
maliciously manipulated altered or corrupted.
9c:. #vailability$ This involves ensuring availability, reliability and
assurance of continuity of operation.
11.6. Database security t"reats
A database threat refers to anything that can compromise integrity, availability and
confdentiality of data. These threats occur due to the following factors.
9i:. !rowsing V This can involve accessing information in the database
9ii:. "isuse?This can be due to malice, errors of omission etc
9iii:. Cenetration?This can be caused by unauthorized users
9iv:. #ystem >aws?;an be caused by hardware or software errors
9v:. ;omponent failures?;aused by malfunctioning of hardware or
software or media
9vi:. Tempering?This can be due to attac%s to physical and logical
components
9vii:. Eavesdropping? This can be through passive surveillance of
telecommunication channel e.g. tapping and sni@ng.
9viii:. enial of service?involves preventing or delaying performance.
(amming, tra@c >ooding
11... Countermeasures to database t"reats
;ountermeasures refer to action, process, device or system that can prevent
or mitigate the eAects of threats on a database. #ome of the
countermeasures to database threat are described as follows$
AaB. 7n%orcin$ inte$rity
This ensures the integrity of the database provides concurrency and
serializability of transactions and prevents data corruption. E8amples entity
integrity, referential integrity, domain integrity and user defned integrity.
AbB. #ut"entication
Crocess of determining whether a user is who heIshe claims to be. It ensures
that users of the database are authenticated using passwords, strong
authentication 6use something the user has and something the user %nows7,
smartcards, biometrics etc.
AcB. 5rivile$es
A permission to access a named ob(ect in a prescribed manner. Crivileges can be
granted or revo%ed. Crivileges can be system privileges where the user is allowed to
perform a particular system action. It can also be a schema ob(ect privileges which
allow the user to perform a particular action on a specifc schema ob(ect e.g. a
privilege to delete rows of a particular table.
AdB. /oles
&oles are used to ease management tas% of assigning a multitude of privileges to
users. &oles are frst created and then given sets of privileges that can be assigned
45
to users and other roles. =sers can be given multiple roles. #o a role is a set of
privileges. E8amples connect role, resource role and database administrator role.
AeB. 5ro;les
Crofles allow administrator to place a specifc restrictions and controls on a number
of system resources, password use etc. The profles can be defned, named, and
then assigned to specifc users or groups of users. Crofles can be system resource
profles which are used to put limits on certain system resources such as ;C= time,
number of data bloc%s that can be read per session or program call. ;an also be
product profles, which are used to prevent users from accessing specifc commands
or all commands^
A%B. #ccess control
This control can be enforced for operating system as well as databases. <or e8ample
by requiring users to login.
A$B. #udits
Auditing is performed at diAerent levels, by user, by statement, by privilege and by
schema ob(ect.
a6 :ie&s
A view is essentially a virtual table. It loo%s and acts li%e a table but does not require
physical storage. It is actually, a composition of table in the form of a predefned
query stored in the database. They are used to limit access to predetermined set of
rows and columns of a table.
b6 -ac'u3s
!ac%ups refer to fles, equipment, data and procedures available for use in the
event of system failure or loss, if the originals are destroyed or out of service.
;reating, managing and restoring bac%ups can be done for a subset or the entire
database on diAerent storage devices.
c6 /e3lication
It refers to sharing of data between databases to reduce wor%load among database
servers thereby improving client performance while maintain consistency among all
systems. <or e8ample, copying data between servers.
d6 /ecovery
atabase recovery can be automatic or manual but it is aimed at restoring database
fles to original state and appropriate physical locations.
e6 Data 3artitionin$
It involves brea%ing up or sub?setting data into smaller units that can be managed
and accessed separately. ata partition can useful in increasing database
performance and security.
11.0. Database Inte$rity
atabase integrity refers to the requirement that information be protected from
improper modifcation. "odifcation of data includes creation, insertion, updating,
changing the status of data, and deletion. Integrity is lost if unauthorized changes
are made to the data by either
intentional or accidental acts. If the loss of system or data integrity is not corrected,
continued use of the contaminated system or corrupted data could result in
inaccuracy, fraud, or erroneous decisions.
11.2. 4y3es o% database inte$rity
There are four main types of database integrity$
AaB. Domain inte$rity
This is restricting what users can enter into the feld. It is the validity of entries for a
given column. It can be enforced by restricting the type6through data types7, chec%
46
constraints and rules can be used to validate the data that users try to enter against
a list of acceptable data and defaults can be used to enter data for the users if they
forget.
AbB. 7ntity inte$rity
This is the process of ma%ing sure that each record in a table is unique in some
way.Crimary %eys are used to enforce entity integrity.
AcB. /e%erential inte$rity
This is the process of protecting related data that is stored in some separate tables.
It is possible for an attribute not to have a corresponding value, but it will be
impossible to have an invalid entry. The enforcement of the referential integrity rule
ma%es it impossible to delete a row in one table whose primary %ey has mandatory
matching foreign %ey values in another table.
AdB. Cser de;ned Inte$rity
=ser?defned integrity allows users to defne specifc business rules. E8ample
Age_Y*3.
11.10. /evision 1uestions
9a:. escribe the following classes of database integrity
9i:. Entity integrity
9ii:. &eferential integrity
9iii:. omain integrity
9iv:. =ser defned integrity
9b:. #tate and e8plain any EI:7 database security threats.
9c:. <or each of the above threats e8plain one possible counter measure.
11.11. Summary
In this lesson you have learnt database security, its characteristics, threats and
countermeasures to those threats. Rou have also learnt database integrity and types
of database integrity that you can enforce in the database.
11.12. Su$$ested readin$
9*:. &amez Elmasri and #ham%ant !. 0avathe 6+5**7$ <undamentals of
database systems$ 1
th
Edition. Cearson education.
9+:. Thomas ". ;onnolly and ;arolyn E. !egg 6+5547$ atabase #ystems$ A
Cractical Approach to esign, Implementation, and "anagement$ /th Edition.
9):. ate 6+5517$ An Introduction to atabase #ystems$ Cearson Education
9-:. Ceter &ob and ;arlos ;orone6+5527$ atabase #ystems$ esign,
Implementation, and "anagement, #eventh Edition.
Lesson 12: Introduction to distributed databases
1.1. Introduction
In the previous lesson you learnt about database integrity, database security
threats and security countermeasures. In this lesson you will learn about
distributed databases$ defnition, advantages, disadvantages, storage
strategies and their uses.
1.2. Lesson objectives
!y the end of this lesson you will be able to$
escribe uses of a distributed database 6!7.
escribe the advantages and disadvantages of a !
escribe the applications of a distributed database.
4#
iAerentiate between heterogeneous and homogenous !
escribe various ways of data storage in a distributed database.
1.3. Lesson outline
This lesson is structured as follows$
*+. *. Introduction
*+.+. ,esson ob(ectives
*+.). ,esson outline
*+.-. efnition
*+./. Advantages of a distributed database
*+.1. isadvantages of a distributed database
*+.2. ata storage in a distributed database
*+.3. Types of distributed database
*+.4. &evision questions
*+.*5. #ummary
*+.**. #uggested reading
1.. De;nition
A distributed database is a database in which storage devices are not all
attached to a common processing unit such as the ;C=, controlled by a
distributed database management system. A distributed database system
consists of loosely coupled sites that share no physical component.
A distributed database management system 6!"#7 is the software that
manages the ! and provides an access mechanism that ma%es this
distribution transparent to the users.
;onsider the diagram below.
1.(. #dvanta$es o% distributed databases
The advantages of a distributed database include$
Improved reliability due to data replication.
,ocal autonomy or site autonomy since each department 6unit7 can
control the data about them.
4$
#ite A #ite !
#ite ;
;ommunication
networ%
#ite
Crotection of valuable data because in case a catastrophic event such
as a fre, all of the data would not be in one place, but distributed in
multiple locations.
Improved performance since data is located near the site where there
greatest demand.
Economical since it costs less since centralized processing power in a
single computer hardware is actually e8pensive than separate units in
the distributed system.
"odular growth since systems can be modifed, added and removed
from the distributed database without aAecting other modules
6systems7.
;ontinuous operation, even if some nodes go o`ine 6depending on
design7.
1.6. Disadvanta$es o% distributed databases
isadvantages of distributed databases include$
;omple8ity since e8tra wor% must be done by the to ensure that the
distributed nature of the system is transparent.
;ost can be prohibitive because of increased comple8ity and a more
e8tensive infrastructure and labor.
There is an increased challenge since the units must be secured, and
they are not centralized.
i@cult to maintain integrity since enforcing integrity over a networ%
may require too much of the networ%Hs resources to be feasible.
,ac% of standards because there are no tools or methodologies to help
users convert a centralized !"# into a distributed !"#.
atabase design more comple8 since the design of a distributed
database has to consider fragmentation of data, allocation of
fragments to specifc sites and data replication.
i@cult to ensure concurrency control.
1... Cses o% distributed database
A distributed database can provide the following applications
"anufacturing
"ilitary command control
!an%ing
;orporate "I#
Airlines
.otel chains
#upermar%et chains
1.0. Data stora$e in a distributed database
There are mainly two approaches to store a relation r in a distributed
database system$
9i:. &eplication
9ii:. <ragmentation 6Cartitioning7.
/e3lication$ The database system maintains several identical replicas of
the same table in diAerent sites.
ata is more available in this scheme.
4%
Carallelism is increased when read request is served.
Increases overhead on update operations as each site containing the
replica needed to be updated in order to maintain consistency.
Era$mentation: The table is fragmented into several tables
table*,table+, table )Ltable n in such a way that the actual table
could be reconstructed from the fragments and then the fragments
are scattered to diAerent locations. There are basically two schemes of
fragmentation$
.orizontal fragmentation ? splits the tableIrelation by assigning each tuple
of the table to one or more fragments.
Dertical fragmentation ? splits the table by decomposing the schema of
the table.
1.2. 4y3es o% distributed database systems
A distributed database can classifed as homogenous or heterogeneous.
i6. !omo$enous distributed database systems.
This is a distributed database system in which all sites have identical
software and are aware of each other and agree to cooperate in processing
user requests. Each site surrenders part of its autonomy in terms of right to
change schema or software. A homogeneous distributed database systems
appears to the user as a single system. The homogeneous system is much
easier to design and manage. The following conditions must be satisfed for
homogeneous database$
The data structures used at each location must be same or compatible.
The database management system 6or !"#7 used at each location must
be same or compatible.
ii6. !etero$eneous distributed database systems.
This is a distributed database where diAerent sites may use diAerent schema
and software. iAerence in schema is a ma(or problem for query processing
and transaction processing. #ites may not be aware of each other and may
provide only limited facilities for cooperation in transaction processing. In
heterogeneous systems, diAerent nodes may have diAerent hardware G
software and data structures at various nodes or locations are also
incompatible. iAerent computers and operating systems, database
applications or data models may be used at each of the locations. <or
e8ample, one location may have the latest relational database management
technology, while another location may store data using conventional fles or
old version of database management system. .eterogeneous systems are
usually used when individual sites use their own hardware and software.
Translations are therefore required to allow communication between diAerent
sites 6or !"#7. In this system, the users must be able to ma%e requests in a
database language at their local sites. =sually the #F, database language is
used for this purpose. The heterogeneous system is often not technically or
economically feasible. In this system, a user at one location may be able to
read but not update the data at another location.
1.10. /evision 1uestions.
5&
9a:. #tate and e8plain any three security threats in a distributed database
systems.
9b:. iscuss two types of distributed database systems.
9c:. iAerentiate between replication and fragmentation with regard to data
storage in distributed database systems.
1.11. Summary
In this lesson you have learnt about distributed databases. Be have
observed that a database need not be stored in a local dis% but can be
distributed in several sites connected by a communication lin%. =sers from
these sites can access the databases from any site as long a as they can
gain access to the networ%. This distribution has its advantages and
disadvantages. There are diAerent types distributed databases such as
heterogeneous and homogenous !.
1.12. Su$$ested readin$.
9*:. "odern atabase "anagement 61th Edition7 UeArey A. .oAer, "ary !.
Crescott, <red &. "c<adden Crentice .allJ 1th edition 6+55+7.
9+:. atabase systems$ practical approach to design, implementation and
management T ;onnolly and ; !egg 6+55-7 Addison Besley 6+55-7.
9):. atabase esign$ ;oncepts and Implementation 6"cgrah?.ill ;omputer
#cience #eries7 Eio Biederhold "cEraw?.ill ;ollegeJ )rd edition 6*44+7
9-:. atabase #ystem ;oncepts Abraham #ilberschatz, et al "cEraw?.ill
#cienceIEngineeringI"athJ - edition 6+55*7.
9/:. atabase "anagement #ystems &aghu &ama%rishnan, et al "cEraw?
.ill ) edition 6+55+7.
Lesson 13: SIL 4utorial
13.1. Introduction
In our previous lesson you learnt about distributed databases. In this lesson
we will discuss #F, as a standard language$ #F, versions, #F,
implementations and #F, components.
13.2. Lesson objectives
!y the end of this lesson, you will be able to$
E8plain various #F, implementations
escribe various commands of #F,$ ,, ",, F,, and ;,.
13.3. Lesson outline
This lesson is presented as follows$
*).*. Introduction
*).+. ,esson ob(ectives
*).). ,esson outline
*).-. efnition
*)./. #F, implementation
*).1. Types of #F, commands
*).2. &evision questions
*).3. #ummary
*).4. #uggested reading
13.. De;nition
51
#F, stands for structured query language. This is the most common !"#
implemented today. This is a standard language used to communicate with
relational databases. It was originally developed by I!" .#F, was approved
by A0#I as the standard language in relational databases. #ome of the #F,
versions are #F,?4+, #F, 44 and #F, +553.
13.(. SIL im3lementation
An #F, implementation is a particular vendorNs #F, product or &!"#.
These implementations vary widely though they remain A0#I #F, compliant.
#ome of the most popular #F, vendors include oracle, "icrosoft, Informi8,
#ybase and I!" supply the products with a license and so as said to be
closed sources.
'ther vendors such as "y#F,, Costgre#F, and #AC are open source.
13.6. SIL commands
The commands can be classifed according to their functions$
9a:. ata defnition language 6,7
9b:. ata manipulation language6",7
9c:. ata Fuery language 6F,7
9d:. ata control language6;,7
AaB. Data De;nition Lan$ua$e 9DDL6
These are statements used to defne, change and remove database ob(ects.
9i:. ;reate database
9ii:. ;reate table
9iii:. ;reate view
9iv:. ;reate user
9v:. ;reate inde8
9vi:. Alter database
9vii:. Alter table
9viii:. rop database
9i8:. rop table
98:. rop view
98i:. rop user
AiB. C/7#47 D#4#-#S7$ This statement is used to create a new database
synta8
;&EATE ATA!A#E aatatabase name_
E'
78am3le
;&EATE ATA!A#E #ongs
E'
AiiB. C/7#47 4#-L7$ This statement is used to create a new table
Synta8
=se aatabase name_
;&EAT TA!,E atable name_
6
;olumnname* aata type_ 6<ield size7 0'T 0=,, C&I"A&R SER,
52
;olumnname+ aata type_ 6<ield size7,
LLLLLLLLLLLLLLLLLLLLL..,
;olumnname0 aata type_ 6<ield size7
7
78am3le
=se #ongs
;&EAT TA!,E song
6
#ongI varchar6+57 0'T 0=,, C&I"A&R SER,
Eenre varchar 6/57,
Title varchar 6/57,
Artist varchar6/57
7
AiiiB. C/7#47 I)D7F$ This statement is used to create inde8es used to search
records.
Synta8
=se aatabase name_
;&EATE I0EO aInde8 name_
'0 aTable name_6<ield 0ame6s77
78am3le
=se songs
;&EATE I0EO #inde8
'0 song 6Eenre7
AivB. C/7#47 CS7/$ This statement is used to create user for the database.
Synta8
=se aatabase name_
;&EATE =#E& a=ser name_ IE0TI<IE !R aCassword_
E<A=,T TA!,E#CA;E aTablespace name_
78am3le
=se #ongs
;&EATE =#E& Listener IE0TI<IE !R list3&d
E<A=,T TA!,E#CA;E #ongsJ
AvB. C/7#47 :I7<: This statement is used to create database view.
Synta8
=se aatabase name_
;&EATE DIEB aDiew name_ A#
#E,E;T a;olumn name6s7_
<&'" aTable name_
B.E&E acriteria_
78am3le
;&EATE DIEB 9,atest songs: A#
#E,E;T #ongI,Eenre,Title
<&'" song
B.E&E Rear&elease_Y+5**
53
AviB. D/+5 D#4#-#S7$ This statement is used to delete the database
Synta8
&'C ATA!A#E aatabase name_
E'
78am3le
&'C ATA!A#E #ongs
E'
AviiB. D/+5 4#-L7$ This statement is used to delete the table from the database.
Synta8
=se aatabase name_
&'C aTable name_
78am3le
=se #ongs
&'C song
AviiiB. D/+5 I)D7F$ This statement is used to delete the inde8 from the table.
Synta8
=se aatabase name_
&'C I0EO atablename.inde8 name_
78am3le
=se #ongs
&'C I0EO song.Eenre
Ai8B. D/+5 :I7< statement$ This statement is used to remove view.
Synta8
=se aatabase name_
&'C DIEB aview name_
78am3le
=se #ongs
&'C DIEB ,atest songs
A8B. D/+5 CS7/$ This statement is used to delete the user from the database.
Synta8
=se aatabase name_
&'C =#E& a=ser name_ 9;A#;AE:J
78am3le
=se #ongs
&'C =#E& ,istener ;A#;AEJ
A8iB. #L47/ D#4#-#S7: This statement is used to change the name of the
database.
Synta8
=se aatabase name_
54
A,TE& ATA!A#E aatabase name_
"odify 0ameYa0ew database name_
78am3le
=se #ongs
A,TE& ATA!A#E #ongs
"odify 0ameY"usic
A8iiB. #L47/ 4#-L7 statement: This statement is used to change the structure of
the table.
Synta8: 4o add a ne& column
=se aatabase name_
A,TE& TA!,E aTable name_
A6;olumnPname ataPtype6length77J
78am3le
=se #ongs
A,TE& TA!,E #ong
A6Copularity varchar6*5577J
Synta8: 4o delete column
=se aatabase name_
A,TE& TA!,E aTable name_
&'Ca;olumnPname_J
78am3le: Delete title column
=se #ongs
A,TE& TA!,E #ong
&'C Title
AbB. SIL server: Data mani3ulation Lan$ua$e
ata "anipulation ,anguage 6",7$ These are statements used to insert,
update, delete and query data.
9i:. Insert data
9ii:. =pdate data
9iii:. elete data
9i:. Insert into statement: =sed to insert data into table. It can ta%e two forms$
#pecifying the column names where data will be inserted.
Synta8:
=se adatabase name_
Insert into atable name_6;olumn*, column+,L7DA,=E#6Dalue*,Dalue+,L7
78am3le
=se #ongs
I0#E&T I0T' song 6#ongI, Eenre, Title, Artist, Rear&eleased7DA,=E#
6*+,N&aggaeN,NCrisonerN,N,uc%y ubeN,+5547
#pecifying values to be inserted only.
Synta8:
=se adatabase name_
Insert into atable name_ DA,=E#6Dalue*,Dalue+,L7
55
78am3le
=se #ongs
I0#E&T I0T' song DA,=E# 6*+,N&aggaeN,NCrisonerN,N,uc%y ubeN, +5547
/emar': you can also specify which column the data will be inserted.
=#E #ongs
I0#E&T I0T' song 6#onEI,Title7 DA,=E# 6*),H.ip hopH7
9ii:. C3date statement: This statement is used to change values in the
database table.
Synta8:
=CATE aTable name_
#ET ;olumn*Yvalue*, column+Yvalue+,L
B.E&E ;riteria
78am3le
=se #ongs
=CATE song
#ET EenreYN;lassicalN,Rear&eleaseY+5**
B.E&E ArtistYNUohn 0gerezaN
9iii:. Delete statement: This statement is used to remove values from the
database table.
Synta8:
E,ETE <&'" aTable name_
B.E&E ;riteria
78am3le
E,ETE <&'" song
=#E #ongs
B.E&E ArtistYNUohn 0gerezaN
)-$ 'nly deleted record6s7 where the artist was Uohn 0gereza.
To delete all the records from the table 6 column names and inde8es will
remain7.
Synta8:
E,ETE <&'" aTable name_ '& E,ETEZ <&'" aTable name_
78am3le
=#E #ongs
E,ETE Z<&'" song
AcB. Data Iuery Lan$ua$e9DIL6
;onsists of only one command. Its base command is #E,E;T.
S7L7C4 9Iuery data6 statement: This statement is used to query data
from the table6s7.
Select all t"e columns:
Synta8:
56
#E,E;TZ <&'"aTable name_
'&
#E,E;T ;olumn6#7 <&'" aTable name_
78am3le1 ,isting all column names.
=se #ongs
#E,E;T #ongI,Eenre,Title,Artist,Rear&elease <&'" song
78am3le1: =sing asteris%
=se #ongs
#E,E;T Z <&'" song
0!$ To select specifc columns you must specify the column name6s7
To select specifc column6s7 using a criteria.
Synta8:
#E,E;T column6s7 <&'" aTable name_
B.E&E ;riteria
78am3le:
=#E #ongs
#E,E;T Eenre,Title,Artist <&'" song B.E&E Rear&eleasea+55/
This statement will only display records where year of release is before +55/.
To select record6s7 using b '&T operator.
isplays record6s7 if either the frst or the second condition is true.
Synta8:
#E,E;T ;olumn6s7 <&'" aTable name_
B.E&E ;riteria* '& ;riteria+
E8ample$
=#E #ongs
#E,E;T Eenre, Title, Artist <&'" song B.E&E EenreYN&oc%N '&
EenreYN;lassicalN
To select record6s7 using A0 operator.
isplays record6s7 if both the frst and the second condition is true.
Synta8:
#E,E;T ;olumn6s7 <&'" aTable name_
B.E&E ;riteria* A0 ;riteria+
E8ample$
=#E #ongs
#E,E;T Eenre, Title, Artist <&'" song B.E&E EenreYN&oc%N A0
Rear&elease_+555
To select record6s7 using both b'&T and bA0T operators.
Be use parenthesis to form a comple8 e8pression6s7.
Synta8:
#E,E;T ;olumn6s7 <&'" aTable name_
B.E&E ;riteria* A0 6;riteria+ '& ;riteria)7
E8ample$
=#E #ongs
#E,E;T Eenre, Title, Artist <&'" song B.E&E Rear&elease_+55/
A06 EenreYN&oc%N'& EenreYNUazzN7
'nly record6s7 released after +55/ and belong to Uazz or &oc% will appear.
5#
To select records then sort them by a specifed column.
;an be sorted in ascending or descending order.
Synta8:
#E,E;T ;olumn6s7 <&'" aTable name_
'&E& !R A0 ;olumn6s7 A#;cE#;
78am3le1: 4o dis3lay records in ascendin$ order.
=#E #ongs
#E,E;T Eenre, Title, Artist <&'" song B.E&E EenreYN&oc%N '&E& !R
Title A#;
78am3le2: 4o dis3lay records in descendin$ order
=#E #ongs
#E,E;T Eenre, Title, Artist <&'" song B.E&E EenreYN&oc%N '&E& !R
Title E#;
To select limited number of records.
;an be done by specifying number of records or percentage.
Synta8:
#E,E;T T'C 0umbercCercentage ;olumn6s7 <&'" aTable name_
78am3le1: 4o dis3lay %our records
=#E #ongs
#E,E;T T'C - Eenre, Title, Artist <&'" song B.E&E EenreYN&oc%N
'&E& !R Title A#;
78am3le2: 4o dis3lay 30R records in descendin$ order
=#E #ongs
#E,E;T T'C )5 CE&;E0T Eenre, Title, Artist <&'" song B.E&E
EenreYH&oc%H '&E& !R Title A#;
To select records using b,ISET operator.
=sed to search records for a specifed pattern in a column.
Synta8$
#E,E;T ;olumn6s7 <&'" atable name_ B.E&E ;olumn name ,ISE
apattern_
78am3le 1$ To display records where artist begins with letter b!T.
=#E #ongs
#E,E;T Eenre, Title, Artist <&'" song B.E&E Artist ,ISE ]![N
78am3le 2$ To display records where artist ends with letter b#T.
=#E #ongs
#E,E;T Eenre, Title, Artist <&'" song B.E&E Artist ,ISE ][#N
78am3le 3$ To display records where artist has letter bRT anywhere.
=#E #ongs
#E,E;T Eenre, Title, Artist <&'" song B.E&E Artist ,ISE ][R[N
78am3le $ To display records where artist that begin with letter b!T or
b"T or bST.
5$
=#E #ongs
#E,E;T Eenre, Title, Artist <&'" song B.E&E Artist ,ISE ]9!"S:[N
To select records using bI0T operator.
=sed to specify multiple values in a B.E&E clause.
Synta8:
#E,E;T ;olumn6s7 <&'" aTable name_ B.E&E ;olumn name
I06value6s77
78am3le:
=#E #ongs
#E,E;T Eenre, Title, Artist <&'" song B.E&E Eenre I06]UazzN,N;lassicalN7
To select records using b!ETBEE0T operator.
=sed to select a range of data between two values6te8t, numbers, dates,
L7
Synta8:
#E,E;T ;olumn6s7 <&'" aTable name_ B.E&E ;olumn name !ETBEE0
Dalue* A0 Dalue+
78am3le:
=#E #ongs
#E,E;T Eenre, Title, Artist <&'" song B.E&E Rear&elease !ETBEE0
*435 A0 +55+
To select records with unique column using bI#TI0;TT %eyword.
Synta8:
#E,E;T I#TI0;T 6;olumn7 <&'" aTable name_
78am3le:
=#E #ongs
#E,E;T I#TI0;T6Eenre7<&'" song
AdB. Data Control Lan$ua$e 9DCL6
These commands are used to control access to data within a database.
They are used to create ob(ects related to user access and also control
the distribution of privileges among users.
9i:. Alter password
9ii:. Erant
9iii:. &evo%e
9iv:. ;reate synonym
S6L 7,-/+ is a co88and used to provide access or privileges on the database ob9ects to the
users"
S6L ,EV):E co88and re8oves user access rights or privileges to the database ob9ects"
13... /evision 1uestions
9a:. Brite a , statement to create a database called sales in access.
9b:. =se , statement to create two tables 5/+DCC4 and SC55LI7/.
5/+DCC4
Column Data
ty3
e
Len$t
"
Decri3tion
CroductI Te8t *55 Crimary %ey
Croduct0a
me
Te8t *55 escriptor
Crice 0umber escriptor
5%
SC55LI7/
Column Data
ty3
e
Len$t
"
Descri3tion
#upplierI Te8t *55 Crimary %ey
#upplier0a
me
Te8t *55 escriptor
CroductI Te8t *55 escriptor
9c:. =se ", statement to insert the following records.
5/+DCC4
5roduc
tID
5roduct)ame 5rice
C* #ugar /55
C+ #alt )55
C) Bater )15
C- #oap /55
C/ <lash dis% +55
C1 Capers */5
SC55LI7/
Su33lie
rID
Su33lier)ame 5roduct
ID
#* "umias ltd C*
#+ "agadi ltd C)
#) #oft ltd C*
#1 Uamia ltd C)
#4 #oft<are ltd C+
#1 <u(i ltd C*
9d:. =se ", statements to display
9i:. Croducts whose prices e8ceeds )55
9ii:. #uppliers who supply sugar
9iii:. ;alculate the average price of the items
9iv:. isplay the products in ascending order of the price
9v:. isplay suppliers in ascending order of the supplier names
9vi:. Increase the price of all the products by *5[ if the product price is
less than -55
9vii:. ecrease the price of all the products by /[ if the product price is
more than -55
13.0. Summary
.n this lesson we have learnt about S6L" ;ou have learnt <our i8portant types o< S6L
co88ands= (ata de<inition language 0((L2 <or de<ining database ob9ects such as tables1 views
and <unctions1 (ata 8anipulation language0(*L2 which is part o< S6L synta> that deals with
data 8anipulation such update and delete1 (ata 6uery Language0(6L2 is part o< S6L synta>
which deals with selection and displaying o< records and (ata control language0(*L2 is a synta>
o< S6L that deals with controlling access to data"
13.2. Su$$ested readin$
9*:. "odern atabase "anagement 61th Edition7 UeArey A. .oAer, "ary !.
Crescott, <red &. "c<adden Crentice .allJ 1th edition 6+55+7.
9+:. atabase systems$ practical approach to design, implementation and
management T ;onnolly and ; !egg 6+55-7 Addison Besley 6+55-7.
6&
9):. atabase esign$ ;oncepts and Implementation 6"cgrah?.ill ;omputer
#cience #eries7 Eio Biederhold "cEraw?.ill ;ollegeJ )rd edition 6*44+7
9-:. atabase #ystem ;oncepts Abraham #ilberschatz, et al "cEraw?.ill
#cienceIEngineeringI"athJ - edition 6+55*7.
9/:. atabase "anagement #ystems &aghu &ama%rishnan, et al "cEraw?
.ill ) edition 6+55+7.
61