DBMS PPT

PrabhuGoyal 6,706 views 68 slides Jun 08, 2016
Slide 1
Slide 1 of 68
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51
Slide 52
52
Slide 53
53
Slide 54
54
Slide 55
55
Slide 56
56
Slide 57
57
Slide 58
58
Slide 59
59
Slide 60
60
Slide 61
61
Slide 62
62
Slide 63
63
Slide 64
64
Slide 65
65
Slide 66
66
Slide 67
67
Slide 68
68

About This Presentation

database management system PPT's for BTECH


Slide Content

Data Modeling Using
Entity-Relationship (ER) Model

2
Chapter Outline
•Example Database Application (COMPANY)
•ER Model Concepts
–Entities and Attributes
–Entity Types, Value Sets, and Key Attributes
–Relationships and Relationship Types
–Weak Entity Types
–Roles and Attributes in Relationship Types
•ER Diagrams - Notation
•ER Diagram for COMPANY Schema

3
Example COMPANY
Database
•Requirements of the Company
–The company is organized into DEPARTMENTs.
Each department has a name, number and an
employee who manages the department. We keep
track of the start date of the department manager.
–Each department controls a number of PROJECTs.
Each project has a name, number and is located at
a single location.

Example COMPANY Database
(Cont.)
–We store each EMPLOYEE’s social security
number, address, salary, sex, and birthdate. Each
employee works for one department but may work
on several projects. We keep track of the number of
hours per week that an employee currently works
on each project. We also keep track of the direct
supervisor of each employee.
–Each employee may have a number of
DEPENDENTs. For each dependent, we keep track
of their name, sex, birthdate, and relationship to
employee.

EntityEntity
•Entity - Thing which has existence distinguishable from other Entity - Thing which has existence distinguishable from other
objects (things)objects (things)
 independent existence
described by its attributes (set of properties)
 determined by particular value of its attributes
 can be concrete or abstract
Example
Rama, Raghu
Maker Towers, Hotel Cecil

ER Model Concepts
•Entity
–Entities are specific objects or things in the mini-world that
are represented in the database.
–For example the EMPLOYEE John Smith, the Research
DEPARTMENT, the ProductX PROJECT
•Entity type
–Entities with the same basic attributes are grouped or
typed into an entity type.
–For example, the EMPLOYEE entity type or the PROJECT
entity type.

ER Model Concepts
•Attributes
–Attributes are properties used to describe an entity.
–For example an EMPLOYEE entity may have a Name,
SSN, Address, Sex, BirthDate
–A specific entity will have a value for each of its attributes.
For example a specific employee entity may have
Name='John Smith', SSN='123456789', Address ='731,
Fondren, Houston, TX', Sex='M', BirthDate='09-JAN-55‘
–Each attribute has a value set (or data type) associated
with it – e.g. integer, string, subrange, enumerated type, …

Key Attributes
•An attribute of an entity type for which each entity must
have a unique value is called a key attribute of the entity
type. For example, SSN of EMPLOYEE.
•A key attribute may be composite. For example,
VehicleTagNumber is a key of the CAR entity type with
components (Number, State).
•An entity type may have more than one key. For example,
the CAR entity type may have two keys:
–VehicleIdentificationNumber (popularly called VIN) and
–VehicleTagNumber (Number, State), also known as
license_plate number.

Entity Sets
•An entity set is a set of entities of the same type that
share the same properties.
–Example: set of all persons, companies, trees, holidays
ENTITY SET corresponding to the
ENTITY TYPE CAR
car
1
((ABC 123, TEXAS), TK629, Ford Mustang, convertible, 1999, (red, black))
car
2
((ABC 123, NEW YORK), WP9872, Nissan 300ZX, 2-door, 2002, (blue))
car
3
((VSY 720, TEXAS), TD729, Buick LeSabre, 4-door, 2003, (white, blue))
.
.
.
CAR
Registration(RegistrationNumber, State), VehicleID, Make, Model, Year, (Color)

SUMMARY OF ER-DIAGRAM
NOTATION FOR ER SCHEMAS
Meaning
ENTITY TYPE
WEAK ENTITY TYPE
RELATIONSHIP TYPE
IDENTIFYING RELATIONSHIP TYPE
ATTRIBUTE
KEY ATTRIBUTE
MULTIVALUED ATTRIBUTE
COMPOSITE ATTRIBUTE
DERIVED ATTRIBUTE
TOTAL PARTICIPATION OF E
2
IN R
CARDINALITY RATIO 1:N FOR E
1
:E
2
IN R
Symbol
E
1 R E
2
E
1 R E
2
NN11

Summary of Symbols Used in
E-R Notation

ER DIAGRAM – Entity Types are:
EMPLOYEE, DEPARTMENT, PROJECT, DEPENDENT

Relationship
•A relationship relates two or more distinct entities with a
specific meaning.
•For example, EMPLOYEE John Smith works on the
ProductX PROJECT or EMPLOYEE Franklin Wong
manages the Research DEPARTMENT.

Relationship Type
•Relationships of the same type are grouped or typed into a
relationship type.
•For example, the WORKS_ON relationship type in which
EMPLOYEEs and PROJECTs participate, or the
MANAGES relationship type in which EMPLOYEEs and
DEPARTMENTs participate.
•More than one relationship type can exist with the same
participating entity types.
•For example, MANAGES and WORKS_FOR are distinct
relationships between EMPLOYEE and DEPARTMENT,
but with different meanings and different relationship
instances.
•A A relationship set relationship set is a class of relationships of the same type, is a class of relationships of the same type,
having common propertieshaving common properties

Attributes of Relationship types
•A relationship type can have attributes; for example,
HoursPerWeek of WORKS_ON; its value for each
relationship instance describes the number of hours per
week that an EMPLOYEE works on a PROJECT.

Attribute of a Relationship Type is:
Hours of WORKS_ON

Structural Constraints –
one way to express semantics of relationships
Cardinality ratio (of a binary relationship): 1:1, 1:N, N:1, or
M:N
SHOWN BY PLACING APPROPRIATE NUMBER ON THE LINK.
Participation constraint (on each participating entity type):
total (called existence dependency) or partial.
SHOWN BY DOUBLE LINING THE LINK
NOTE: These are easy to specify for Binary Relationship Types.

The minimum and maximum values of this connectivity is called the cardinality of
the relationship

Participation of an Entity Set in a Relationship
Set
Total participation (indicated by double line): every entity in the entity set
participates in at least one relationship in the relationship set
E.g. participation of loan in borrower is total
every loan must have a customer associated to it via borrower
Partial participation: some entities may not participate in any relationship in
the relationship set
E.g. participation of customer in borrower is partial

ER DIAGRAM – Relationship Types are:
WORKS_FOR, MANAGES, WORKS_ON, CONTROLS,
SUPERVISION, DEPENDENTS_OF

Roles
•Entity sets of a relationship need not be distinct
•The labels “manager” and “worker” are called roles; they
specify how employee entities interact via the works-for
relationship set.
•Roles are indicated in E-R diagrams by labeling the lines
that connect diamonds to rectangles.
•Role labels are optional, and are used to clarify
semantics of the relationship

Recursive Relationship Type
•Both participants are same entity type in different roles.
•For example, SUPERVISION relationships between
EMPLOYEE (in role of supervisor or boss) and
(another) EMPLOYEE (in role of subordinate or
worker).
•In following figure, first role participation labeled with 1
and second role participation labeled with 2.
•In ER diagram, need to display role names to
distinguish participations.

A RECURSIVE RELATIONSHIP
SUPERVISION
e
1
e
2
e
3
e
4
e
5
e
6
e
7
EMPLOYEE
r
1
r
2
r
3
r
4
r
5
r
6
SUPERVISION
2
1
1
2
2
1
1
1
2
1
2
2

Recursive Relationship Type is: SUPERVISION
(participation role names are shown)

Entities that are distinguished by their relationship to another entity Entities that are distinguished by their relationship to another entity

Weak entity has Weak entity has partial key or discriminator partial key or discriminator – –

Identify entities related to the same strong entity.Identify entities related to the same strong entity.
Weak EntityWeak Entity

The primary key = primary key of the strong entity set The primary key = primary key of the strong entity set
+ discriminator.+ discriminator.
 Do not have a key of their own
PF account of an employee
Engineer of a ship

Weak Entity Types
•A weak entity must participate in an identifying
relationship type with an owner or identifying entity
type
•Entities are identified by the combination of:
–A partial key of the weak entity type
–The particular entity they are related to in the
identifying entity type
Example:
Suppose that a DEPENDENT entity is identified by
the dependent’s first name and birthdate,
and the specific EMPLOYEE that the dependent is
related to.
DEPENDENT is a weak entity type with EMPLOYEE as
its identifying entity type via the identifying relationship
type DEPENDENT_OF

Weak Entity Types
Example:
Suppose that a DEPENDENT entity is identified by the
dependent’s first name and birthdate,
and the specific EMPLOYEE that the dependent is
related to.
DEPENDENT is a weak entity type with EMPLOYEE as
its identifying entity type via the identifying relationship
type DEPENDENT_OF

Weak Entity Type is: DEPENDENT
Identifying Relationship is: DEPENDENTS_OF

These attributes best describe the relationship prescription rather than any
individual entity Doctor, Patient or Medicine.

The identifying relationship is the one which relates the weak entity (dependant) with
the strong entity (Employee) on which it depends.
Id is underlined with a dotted line because it is used to form composite key of
dependent entity along with E#.

Relationships of Higher Degree
Relationship types of degree 2 are called binary
Relationship types of degree 3 are called ternary
and of degree n are called n-ary
In general, an n-ary relationship is not equivalent to
n binary relationships

Example of a ternary
relationship
SUPPLY relationship instance: (s,j,p)
A supplier s supplies part p to project j

Ternary vs Binary Relationship Types
Suppose (s,j), (j,p), and (s,p) participate in the relationships
SUPPLIES, USES, and CAN_SUPPLY, respectively
Is this equivalent to the instance (s,j,p) in ternary relationship?
3 binary
relationships

Example of a ternary relationship
SupplierProjectPart
Ace R1 T1
Ace R2 T2
Acme R1 T2
Acme R2 T1
Lowes R1 T1
Lowes R2 T2
SupplierProject
Ace R1
Ace R2
Acme R1
Acme R2
Lowes R1
Lowes R2
ProjectPart
R1 T1
R1 T2
R2 T1
R2 T2
SupplierPart
Ace T1
Ace T2
Acme T2
Acme T1
Lowes T1
Lowes T2

Ternary Relationships
TAUGHT_DURING and OFFERED_DURING are redundant, but
CAN_TEACH is not redundant
3 binary relationships may represent different info than a single ternary relationship

Cardinality Ratio of Ternary Relationships
1 M
N
There is 1 supplier
for every (project,
part) combination
A supplier can
supply same part to
more than 1 project
A supplier can
supply more than 1
part to a project