DBMS Module 1
DBMS Module 1
Figure 3.1]
Asinpified diagram
to lkustrate the
Miniworld main phases of
database desgn
REQUIREMENTS
COLLEcTION AND
ANALYSIS
TRANSACTION internalSchema
IMPLEMENTATKON
Applicaton Program
1
Entities and Attributes
" Entity is a thing in the real world with an independence existence, an entity may be an object
with a physical existence (for ex: person, car, employee) or it may be an object with a
conceptualexistence (for ex: a company, a job).
Attributes are the properties of the entity
For Ex An EMPLOYEE entity can be described by employee's name, age, address, salary and job. An
entity can have value for its attributes. the values become a major part of the data in the database.
2
Stored versus Derived
WO or attribute values are telaled fos exomole, tbe ave and birth date attributes of a peron. The value
Ee can be ketermined bythe brh date of theocrson Hence age nttnbute is called Derived, and
birth date is called stored attribute,
IV, Complex Attributes
s he cOmbination of composite aund Multivalued attributes which is nested arbitrarily, we are nesting
he conyosite attitbute between parenthesis ) and separating the components with commas, and by
displaying multivalued atuibutes between braces (0.
(adkl1ess phone((phone(area code, hone nunmbe)),Address(Street address
(Number,Sreet),city,state))
1.14.4NULL Values
A purticular entity may not have a applicable value for an attribute. For
example; an apartment_no
appies to only to those who stay in apartnent and not for other family homes. There are two types of
be further cassified into two cases. The first case
NULL. one is unknown, the unknown categorycan
missing- for example, if the height attribute
arises when it is known that theattribute value cxists but is the attribute
it is now known whether
of the person is listed as NULI. The second case arises when
valuc exists for ex: if the Home phone attribute of person is NULLL.
Entity Set (Fred Brown, 40, 3OK) (Fast Computor, Dallas, Bob King)
(Extension)
a rectangular box
An entity type is represcnted in ER diagrans (see Figure 7.2) as
enclosing the entity type name.
Attribute names are enclosed in ovals and are attached to their entity type by straight lines.
Composite attributes are attached to their component attributes by straight lines.
3
displaycd in double ovals
Multivalued attributes are
fype in this notaio
Hyure 7.7(a) showsa CARctity
trator )CVt e
distinctfoa tah
1.15.2 Key Attribules of an Entity Type. attributes whose values are can te
mre
. key attribute : An entity type usually has one of is calleda key attribute, and its values
COMPANY
individual entity in the entity set. Such an attr1bute Name attributeis a key of the
used to identify cach entity uniquely For example, the sarre
the nanc.
are allowed to have
entity type in Figure 7.6 because no two companies
assciated with
Exch simple attribute of an entity type is
1.15.3 Value Sets (Domains) of Attributes. atribte
the set of values that maybe assigpedto that
a value set (or domain of values), which specifies betwecn 16 arxd 70, we can
for each individual entity. if the range ofages allowed for ernployces is
integer rurnbers
betwcen 16
specify the value set of the Age attribute of EMPLOYEEto be the set of
and 70.
4
(Name ) umte)
CLocticn 4 DEPARTME NIMaragt
Maner start ate
Name ) umber
Contreng dgartment
(Brth date)
IEMPLOYEE Addres
Flgure 78
Prebnrvary des A r t y types
(Barth datSexEmpkyee for the COMPANY datatase
Some A the shown attr taAes wl
Dependent name)
Relationehip [DLPENDENT be tetined into relatiorships
Constraints
1.17 Relationship Types, Relationship Sets) Roles, and Structural
1.17.1Relationship Types, Sets, and Instances relationship
E2, ....En defines a set of associations or a
A relationship type R amongnentity types El,
set among entities from these entity types.
FOR between the two entity types EMPLOYEE
For example, consider a relationship type WORKS the department for which the employee
and DEPARTMENT, which associates each employce with
works in the corresponding entity set.
WORKS_FOR associates one EMPLOYEE entity and
Each relationship instance in the relationship set
one DEPARTMENT entity.
DEPARTMENT
EMPLOYEE WORKS_FOR
Figure 7.9
Some instances in the
WORKS FOR relatonship
set, which represenits a
relationshp type
WORKS FOR between
EMPLOYEE and
DEPARTMENT.
Relationships
1.172 Relationship Degree, Role Names, and Recursive entity
Degree ofa Relationship Type. The degree of a relationship type is the number of participating
types. Hence, the WORKS_FOR relationship is of degree two.
5
aonship type of degree twois called binary, and one of degree three is called ternary. three
etanple of a ternary relationshio is SUPPLY, where cach relationship instance ri associates
suppher s, a part p, and a project i, whenever s supplies part p to project) in figure below
SPPLY POHCI
PART
6
is called lernary
ationship type ol degree twois called binary, and oneof dee thrce
instance i aisocates thaee
AnCtample of alenary tlalionhin is SUPPLY whC cach rclationship
below
hes a suppliet s, a part p, and a roicct i. whenever ssupplies part po projectyJ n hgure
PAI
Figue below shows an example. The SUPERVISION relationship type relates an employee to a
supervisor, where both employee and supervisor entities are members of the sane EMPLOYEE entity
set. Hence, the EMPLOYEE entity type participates twice in SUPERVISION: once in the role of
supenisor (or boss), and once inthe role of superisee(or subordinate) the lines marked 'l' represent
the supervisor role, and those marked '2' represent the supervisee role, hence, el supervises e2 and e3,
ed supervises e6 and e7, and e5 supervises el and e4.In this example, each relationship instance must
be connected with two lines, one marked with 1' (supervisor) and the other with '2' (supervisee)
EMPLOYEE SUPEFVSON
6
I.
Cardinality Ratios for Binary Relationships
Ihe cardinality ratio for a binary
that an cntity can relationshin specfies the maimm number of relationship instances
For example, inparticipate in.
the WORKS_HOR binary relationship type, DEPARTMENT: EMPLOYEE is of
Cardinal1ty ratio 1:N, meaning that each department can be related to (that is, employs) any nun
mpiees,y but an employee can be related to (work for) only one depart1ment. On the other hand, an
cmployee can be related to a maximum of one department.
The possible cardinality ratios for binary relationship types are 1:1, 1:N, N:1, and M:N.
An example of a 1:1binary relationship is MANAGES (Figure below), which relates a department
entity to the employee who manages that depart1nent.
Flyure 7.12 EMELOYEE MANACES DEPATMENT
AI at p
MANAM.S
da
The relationship type WORKS_ON (Figure below) is of cardinality ratio M:N, because the mini-world
rule is that an employce can work on several projects and a project can have several employees.
EMPLOYEE WORKS ON PROECT
...
Flgure 7.13
An MNrelabrnstp
WORKS ON
8
A) ry )
Chddyy DPAruNT
( t datey
MANAE9 CONTOUS
H N
M PlOECI
WKS ON
C r aton
Nanber
DEPENOE NIS OF
GEEONT
Sood
10
Meaing Figure 7 14
Semay of he ntatn
Fnty
Wak Enty
Aonahp
hdnthying Relahonahp
Artnbute
Key Artribute
Mvaed Atrbute
Q Composte Atrbute
Demved Amrbute
Total Parbcpion of E, nR
1.20.2 Proper Naming of Schema Constructs possible, the meanings attached to the
> One should choose names that convey, as much as
d1fferent constructs in the schema.
ones, because the entity type
Choose to use singular names for entity types, rather than plural
type.
name applies to each individual entity belonging to that entity
names are uppercase letters, attribute
Use the convention that entity type and relationship type
lowercase letters.
names have their initial letter capitalized, and role names are
database requirements, the nouns uppearing
As a general practice, given a narrative description of the
and the verbs tend to indicate names of relationship
in the narrative tend to give rise to entity type names,
that describe the nouns coesponding to
types. Attribute names generally arise from additional nouns
left to right and from top to bottom.
entity types ER diagram of the schema readable from
To explain this naming convention further, we have
one exception to the convention in Figure 7.2-the
top. When we describe this
DEPENDENTS_OF relationship type, which reads from bottom to
entity type) are DEPENDENTS_OF
relationship, we can say that the DEPENDENT entities (bottom
to read from top to bottom, we
(relationship name) an EMPLOYEE (top entity type). To change this
HAS_DEPENDENTS,
could rename the relationship type to
11
Frame Mt (name Flgure 7.15
Bdate ERdagrams for the company schena, wth structural con
Name strants speofd uing(min, max) rotation arxd role rames
Ssn
meAdtess Salary
Sex Locations
WORKS FOR (4N)
(1,1), Name Number
Employee Department
EMPLOYEE Start dato) Number ot_enployees: DEPARTMENT
o.anoget MANAGES
Department
Maraged)
(ON Controling
CONTROLS
Departent
Hours
(0.N) Worker
Supervisor (0.1) Controlled
|Supervisee (1.1)) Project
WORKS_ON Project PROJECT
(1N)
SUPERVISION (0,N)
Employee Name
Location
Number
DEPENDENTS OF
(1,1)Dependent
DEPENDENT