DBMS Technical Publications Chapter 2
DBMS Technical Publications Chapter 2
DBMS Technical Publications Chapter 2
Entiff Relationships
o Separation and isolation : Each program maintains its own set of data,
users of one program may not aware of holding or blocking by other
Programs.
o Duplication : Same data is held by different programs, thus, wastes
space and resources.
o High maintenance costs such as ensuing data consistency and controlling
access.
(2-11
- ,/-'
o Compleximplementation
o Difficult to manage and lack of standards, such as problem to add
empty nodes and can't easily handle many-many relationships.
o Lacks structural independence, such add up application programming
and use complexity.
)
I
L I
Database Management Systems 2-3 Entity Relationships
allows view level, a way of presenting data to a group of users and logical
level, how data is understood to be when writing queries.
1970 : Ted Codd at IBM's San Jose Lab proposed relational models.
Two major projects start and both were operational in late 1970s.
o INGRES at University of California, Berkeley became commercial and
followed up POSTGRES which was incorporated into Informix.
o System R at IBM san Jose Lab, later evolved into DB2, which became
one of the first DBMS product based on the relational model. (Oracle
produced a similar product just prior to DB2.)
1976 : Peter Chen defined the Entity-reiationship(ER) model.
1980s : Maturation of the relational database technology, more relational
based DBMS were developed and SQL standard adopted by ISO and ANSI.
: Object-oriented DBMS (OODBMS) develops. Little success
1985
conunercially because advantages did not justify the cost of converting
billions of bytes of data to new format.
1990s : Incorporation of object-orientation in relational DBMSs, new
application areas, such as data warehousing and OLAP, web and Internet,
Interest in text and multimedia, enterprise resource planning (ERP) and
management resource planning (MRP)
o 1991, : Microsoft ships access, a personal DBMS created as element of
Windows gradually supplanted all other personal DBMS products.
r) 1995 : First Internet database applications
o 7997 : XML applied to database processing, which solves long-standing
database problems. Major vendors begin to integrate XML into DBMS
products.
)
]S,
)n
Database Management Systems 2-4 Entity Relationships Iletab€
- | l- ,
llatabase Management Systems 2-5 Entity Relationships
parts of the database that they should not be allowed to access are identified.
Steps are taken to ensure that they can access only the necessary parts.
,t Account no Balance
t F.121 1000
4305 2000
e
p|417 500
e
4519 3000
t Account
r
I
e
Fig. 2.1 Entity sets Customer and Account
Database Management Systems 2-6 Entity Relationships
2.3.2 Attributes
o An entity is represented by a set of attributes. Attributes are descriptive
--r properties possessed by each member of an entity set.
. The attributes of Customer entitty set are Custometid, Customer-name, and
City possible athibutes of the Account entity set are Account-no, and
Balance.
. Each entity has a value for each of its attributes. For instance, a particular
Customer entity may have the value 'C101' for attribute Custometid, 'Hari'
for Customer-name, and 'Bombay' for City.
o For each athibute, there is set of permitted values, called the domain, or
value set of that attribute. The domain of athibute Customer-name might be
set of all text strings of a certain length.
Types of attributes
Attributes are classified as :
. Simple
. Composite
. Single-valued
. Multi-valued
. Derived
i) Simple attribute : A simple attribute is an attribute composed of a single
component with an independent existence. Simple attributes can not be further
subdivided. Examples of simple attributes include Roll-No, Salary etc.
ii) Composite attribute : An attribute composed of multiple components each
with an independent existence is called a composite attribute.
. Examples of composite attributes are :
t) Name, which is composed of athibutes like first name, middte name and
last name.
2) Address, which is composed of other components like Street, City, Pincode.
iii) Single-valued attributes z A single-aalued attribute is one that holds a single
value for a single entity. Examples are Room-no, Customer]d. Single-valued
attributes are also called as atomic attributes.
iv) Multivalued attributes : A multiaalued attribute is one that holds multiple
values for a single entity. For example, a student entity can have multiple
values for the Hobby attribute such as reading, music, painting.
F
,
Database Management Systems 2 -7 Entity Relationships
Entity role
The function that an entity plays in a relationship is called that entity's role. A
is one end of an association.
Consider following Fig. 2.3 (a).
'
Database Management SYstems 2-8 Entity Relationships
Fig. 2.4 Association between two objects of the same entity set
ii) Binary relationship : A binary relationship exists when two entities €ue
associated. For example, the Book - Publisher relationshiP shown in Fig. 2-5 is
a binary relationship.
iii) Ternary relationship : A ternary relationship exists when there are three
entities associated. For example, the entities Teacher, Subject and Student are
related using a ternary relationship called 'Teaches' as shown in Fi9.2.6.
,\
2
lHabase Management Systems 2-9 Entity Relationships
Keys
A key allows us to identify a set of atbributes and thus distinguishes entities from
r other. Keys also help uniquely identify relationshpr, and thus disfnguish
from each other.
. Superkey
. Candidate key
. Primary key
. Foreign key
2-10 Entity RelationshiPs
Database Management SYstems
t\
!-
F
ips Database Management Systems 2-11 Entity Relationships
,to
Component name Symbol Description
ute
rely
me/
and 3) Diamonds Represents relationship sets
tion
late
4) Lines Links attributes to entity sets
& entity sets to relationship sets
tr as 5) Double ellipses Represents multivalued attributes
Ple,
lbe t-\
6) Dashed ellipses Represents derived attributes
the
it is
ever 7) Double rectangles Represents weak entity sets
7r
7tr
:-
Fig. 2.9 E-R diagram corresponding to Customers and Loans
tt
ET
Gardinality
-l
in E-R diagram that is represented by two ways :
line (+)
line (-)
Database Management SYstems 2-12 Entity RelationshiPs
relati
1. One-to-one relationship : Following Fig. 2.'!.0 represents one-to-one
f between two entities i 'Manager' and 'Departrn ent' , related through a
relationshiP'Manages'.
i1
l
T
7'
-
Primary keY
Address
attribute
Fig. 2.16 E-R diagram with composite, multivalued and derived
As shown in Fig. 2.1.6'Name' is a composite attribute with comPonent
attributes
with
First-name, Last-name. similarly Address is also a composite attribute
attribute and Age
component attributes Street, Crty, State, Pin. Ph no is a multivalued
is a derived attribute.
i1
\
&tabase Management Systems 2-15 Entity Relationships
s
h
e
b
le
7.s
The book club has members. The book club sells books to its members. The
members places orders for books, which the book club fulfills. Each order contains one
or more than one book. The books are written by author(s). The Publisher publishes
the book.
An author can write more than one book and a book can have more than one
author. A book is published by a publisher, but a publisher publishes many books. A
member can place more than one order. He also can choose not to place an order. The
book club sells many books. The book club example is converted into an E-R diagram
and is shown in Fig. 2.19.
-
-
.\
IbDase Management Systems 2-17 Entity Relationships
entities in A. Ther
Total
be tot
For
tions
Fig. 2.26 Many-to-one mapping cardinality Th
Database Management SYstems 2-19 Entity RelationshiPs
I
2.7.3 Weak Entities
'r
]"" Existence dependencies
If the existence of entity x depends on the existence of entity }/, then x is said to
be existence dependent on y. If y is deleted, so is x. Entity y is said to be a dominart
entity, and x is said to be subordinate entity.
Consider the entity set 'Loan' and the entity set 'Payment' that keeps informatim
about all the payments that were made in connection to a particular loan. TtE
payment entitl set is described by the attributes Payment-no, Payment-date and
payment_amount. We form a relationship set Loan-payment between these two entilr
from Loan to Payment. Every Payment entity must be
tty. If a Loan entity is deleted, then all its associated
be deleted. In contrast, Payment entities can be deleted
from the database without affecting any loan. The entity set Loan is therefore
dominant entity set which is also called as strong entity set, artd the entity set Paymert
is subordinate which is also called as weak entity set, in Loan-payment relationship.
Following Fig. 2.30 (a) shows the dominant entity set 'Loan' and subordinate entilr
set 'Payment' connected by relationship 'Loan-payment"
Entities are classified as being strong or weak entity types. An entity that is
set on
existence dependent on some other entity is called a weak entity type.An entity
which weak entity set depends, is called strong mtity set.
For example, following Fig. 2.30 (b) shows weak entity set 'Parent' which depends
on strong entity set 'EmPloYee'.
L7.4.1 Specialization
"Specialization is the process of designating subgroupings within an entity set."
Specialization is a top-down process. Consider an entity set Persory with attributes
Name, Street, and City. A Person may be further classified as one of the following.
1S
on o Customer
. Employee
nds Each of these Person types is described by a set of attributes that includes all the
athibutes of entity set Person plus additional attributes. For example, Customer
errtities may be further described by Customer id and Employee entities by
Employee_code and Salary.
Fig. 2.31 shows specializatiory which is represented by triangle. The lable ISA
stands for "is a", arrd represents, for example, that Customer "is a" Person. The ISA
relationship may also be referred to as a superclass-subclass relationship.
Database Management SYstems 2 -22 Entity RelationshiPe
2] .4.2 Generalization
"Generalization is the Process of defining a more general entrty type from a set of
specialized entity !ryes."
Generali zation is a bottom-up approach. This approach results in the identifica
of a generaltzed superclass from the original subclasses
Consider that the attributes of 'Customer' entity are Customer id, Name, Street,'
and an 'Employee' entity atbributes are Employee-code,, Street, City and Salary'
the entity sets Employee and Customer have several attributes in conunon.
conunonufiay can be expressed by generalization which is a containment relatic
that efsts between a higher-level entity set and one or more lower-level entity
As shown in Fig. 2.31, person is a higher-level entity set and Customer and E-P
can lower-levellntity sets. In other words, Person is a superclass if Customer
Employee are subclasses.
i\
I
lps Database Management Systems 2-23 Entity Relationships
:, A second type of constraint relates to whether or not entities may belong to more
ian one lower-level entity set within a single generalization. The lower-level entity
-Li may be one of the following :
. Disjoint : A disjointness constraint requires that an entity belong to only one
lower-level entity set. For example, da Account entity may be either
Saving_account or Checking_account. It satisfies just one condition at a time.
. Overlapping : In overlapping generaltzation, the same entity may belong to
tion
more than one lower-level entity set within a single generalization.
For example, a single manager may participate in more than one work team.
Cit)-
-\nother example is, assume from Person, two entities Customer and Employee,
hus,
IhLs
re derived. The generaltzation is overlapping if an Employee can also be a customer.
ship : -\ final constraint, is a completeness constraint on a generaltzatron/specialization,
set_s.
r-hich specifies whether or not an entity in the higher-level entity set must belong to
)vee
rt ieast one of the lower-level entity sets within the generalization/specialization. This
and
---xr-straint may be one of the following :
o Total generalization or specialization : Each higher-level entity must belong
to a lower-level entity set.
Database Management SYstems 2 '24 Entity
sets. We may characterize the team entity sets more fully as a partial, overla
specialization of EmPloyee.
The generalization of Checkingaccount and Savings-account into Account is
total disjoint genenltzation.
2.7.5 Aggregation
One limitation on E-R model is that it cannot express relationshiPt
relationshiPs.
Consider a quaternary relationship Manages between Employee, Branch, Iob,
Manager. using the basic E-R modeling constructs, we obtain the E-R diagram
showrr in Fig. 2.32. (See Fig. 2.32 on next Page)
There is redundant information in the resultant figure, since every
Branch, fob combination in Manages is also in works-on.
The best way to model above situation is to use aggregation- Aggregation is
abstraction through which relationships are treated as higher-level entities. Thus,
relationship set Works-on relating the entity sets Employee, Branch and Iob
considered as a higher level entity set called Works on. We can then create a
t\
ships Database Management Systems 2-25 Entity Relationships
not
We
Le to
ngle
e job.
entity
PPiNg
tisa
zation
y the
Fig. 2.32 E-R diagram with redundant rerationships
tes of
tional
r and ftionship manager between Works-on and manager to represent who manages
ft tasks.
Hg. 2.33 shows E-R with aggregation.
monS
t, and
rm as
loyee,
is an
s, the
ob is
rinary
)Ea Various design issues related to E-R model are given below :
(b)
:
'! I
i
Habase Management Systems 2-27 Entity Relationships
;Cffi:';;;;ilr';',il
r r5' L'rv' Hs; a project can be sponsored bv anv number or
is
ic.
tt i".-'t"t" t'tt" more proJec :ts' and
departments, a department can sPonsor one or
--l ^^^L sPonsorship
each -6n6c^1.clrin
,-^ -^-) rL^ o+l-t"ilrrrlp
until attribute nf
of
If we don't need to record the "-+il
",ffi;';;-;;;;; "-prov"es. s€r]' Sponsors 2' ^ ^L^-^'- shown in i
monitors, then we can use a ternary relationship,
Fig. 2.36.
constraint that each sponsorship (of a project by
the
u deparfiment) be
Consider
LDT\^LT LI
monitored by V V
IIT\JILTL\'.L9V J
below :
i) borrower.
ii) loan-branch.
iii) loan-payment.
iv) depositor.
v) cust-banlcer.
vi) works-for.
o Last step in database design is to draw E-R diagram using idenffied entity
sets and relationship sets.
,\
Database Management SYstems 2-31 Entity RelationshiPs
The State Bnnk of Indin offers the fiae different types of accounts : Ioan, checking,
recurring deposits, Iocker accounts and fixed deposit. The Bank has a number tf
brartches and a client of the bank can open many accounts. A account can be ioint
and more than one client may operate an account. Identify the entities, attributes
what relationships exist among these entities and Tables. Draw the corresponding
E-R diagrnm.
Bank name
Branch Address
Branch Name
Client Name
:-sallment Amt.
Fig. 2.37
r'
Fig. 2.38
Q.4 How can you gioe names to output columns in a query that are defined by arithmeti
or string expressions ? What support does SQL ffir for string pattern matching
Explain with an examPle.
Ans. : The example of query for giving names to output columns in a query that
defined by arithmetic or string expressions is given below :
select Author_nalne, sum (Unit-Price*0.15) "Royalty" ftom Book
group by Author-name;
Above query displays author narne and their royalty amount which is calcula
as 'Unit-price * 0.15' where Unit-price is a column in Book table.
String pattern matching : Refer section 2.I7.
r1
l
E
rships Ilatabase Management SYstems 2-33 Entity Relationships
eg Orgnnize the following fiels into a hierarchy for a bank's database : payment, saaing,
account, deposit, customer, Ioan nccount, wit.hdrawal'
hmetic
ching? Fig. 2.39
6d Q.10 Explain the dffirence between primary Vs n-ary relationship sets.
Lat are
Ans. :
Fig. 2.40
As shown in above diagram following ftrnctional dependencies are there in
student table.
Student-number -------) Student-Name
Student-number ----J Student-Major-dept
Student-number ------> Student-credits
Student-number Student advison_number
--J
Student-advison-number ---J Student-advison-name
Student-advison-number Student-advison-office-no
Student-advison-number -----+ Student-advison-phone-no
trtrtr