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
r
r
e
e
e
p
p
p
a
a
a
r
r
r
e
e
e
d
d
d


b
b
b
y
y
y



M
M
M
o
o
o
h
h
h
a
a
a
m
m
m
m
m
m
a
a
a
d
d
d


N
N
N
a
a
a
z
z
z
m
m
m
i
i
i


N
N
N
e
e
e
w
w
w
a
a
a
z
z
z


D
D
D
a
a
a
t
t
t
a
a
a
b
b
b
a
a
a
s
s
s
e
e
e


M
M
M
a
a
a
n
n
n
a
a
a
g
g
g
e
e
e
m
m
m
e
e
e
n
n
n
t
t
t


S
S
S
y
y
y
s
s
s
t
t
t
e
e
e
m
m
m
s
s
s


w
w
w
i
i
i
t
t
t
h
h
h


M
M
M
S
S
S


A
A
A
c
c
c
c
c
c
e
e
e
s
s
s
s
s
s



M
M
M
o
o
o
h
h
h
a
a
a
m
m
m
m
m
m
a
a
a
d
d
d


N
N
N
a
a
a
z
z
z
m
m
m
i
i
i


N
N
N
e
e
e
w
w
w
a
a
a
z
z
z
,
,
,


A
A
A
s
s
s
s
s
s
o
o
o
c
c
c
i
i
i
a
a
a
t
t
t
e
e
e


M
M
M
a
a
a
n
n
n
a
a
a
g
g
g
e
e
e
m
m
m
e
e
e
n
n
n
t
t
t


C
C
C
o
o
o
u
u
u
n
n
n
s
s
s
e
e
e
l
l
l
l
l
l
o
o
o
r
r
r
,
,
,


B
B
B
a
a
a
n
n
n
g
g
g
l
l
l
a
a
a
d
d
d
e
e
e
s
s
s
h
h
h


I
I
I
n
n
n
s
s
s
t
t
t
i
i
i
t
t
t
u
u
u
t
t
t
e
e
e


o
o
o
f
f
f


M
M
M
a
a
a
n
n
n
a
a
a
g
g
g
e
e
e
m
m
m
e
e
e
n
n
n
t
t
t


2
E
E
E
N
N
N
T
T
T
I
I
I
T
T
T
Y
Y
Y



An entity is an object with a distinct set of properties that easily identified. Entities are
the building blocks of a database. Some examples are Student, Course, Grade etc.
An entity instance is a specific value of an entity. For example; Bipul, Aurko, and Ratul
are students, they are instances of the entity Student. Similarly, Mathematics and
Physics are instances of the entity Course.


E
E
E
N
N
N
T
T
T
I
I
I
T
T
T
Y
Y
Y


S
S
S
E
E
E
T
T
T



An entity set is a set of entities of the same type that share the same properties, or
attributes. For example; the set of all persons who are students at a given department,
can be defined as the entity set Student.
The individual entities that constitute a set are said to be the extension of the entity
set. Thus, all the individual department students are the extension of the Entity Set
Student.


A
A
A
T
T
T
T
T
T
R
R
R
I
I
I
B
B
B
U
U
U
T
T
T
E
E
E
S
S
S



An attribute is a property of an entity that differentiates it from other entities and
provides information about the entity. An attribute is a property of an entity type. For
example; the attributes of the entity Student are Student ID, Student Name, Student
Roll, Student Course etc.
In an E/R model, we express attributes as ellipses and label them with the name of the
attributes.

Attributes mainly consists of values and domain or value set.

V
V
V
A
A
A
L
L
L
U
U
U
E
E
E




Each entity has a value for each of its attributes. For example; a particular
Student Entity may have the value 019-320-286 for Student ID, Bipul for
Student Name.

D
D
D
O
O
O
M
M
M
A
A
A
I
I
I
N
N
N




There is a set of permitted values for each attribute, called The Domain or Value
Set, of that attribute. The domain of attribute Student Name might be the set of
all text strings of a certain length. Again in case of Employee Salary in the
Employee entity set, the domain might be the set of numerical numbers.

D
D
D
a
a
a
t
t
t
a
a
a
b
b
b
a
a
a
s
s
s
e
e
e


M
M
M
a
a
a
n
n
n
a
a
a
g
g
g
e
e
e
m
m
m
e
e
e
n
n
n
t
t
t


S
S
S
y
y
y
s
s
s
t
t
t
e
e
e
m
m
m
s
s
s


w
w
w
i
i
i
t
t
t
h
h
h


M
M
M
S
S
S


A
A
A
c
c
c
c
c
c
e
e
e
s
s
s
s
s
s



M
M
M
o
o
o
h
h
h
a
a
a
m
m
m
m
m
m
a
a
a
d
d
d


N
N
N
a
a
a
z
z
z
m
m
m
i
i
i


N
N
N
e
e
e
w
w
w
a
a
a
z
z
z
,
,
,


A
A
A
s
s
s
s
s
s
o
o
o
c
c
c
i
i
i
a
a
a
t
t
t
e
e
e


M
M
M
a
a
a
n
n
n
a
a
a
g
g
g
e
e
e
m
m
m
e
e
e
n
n
n
t
t
t


C
C
C
o
o
o
u
u
u
n
n
n
s
s
s
e
e
e
l
l
l
l
l
l
o
o
o
r
r
r
,
,
,


B
B
B
a
a
a
n
n
n
g
g
g
l
l
l
a
a
a
d
d
d
e
e
e
s
s
s
h
h
h


I
I
I
n
n
n
s
s
s
t
t
t
i
i
i
t
t
t
u
u
u
t
t
t
e
e
e


o
o
o
f
f
f


M
M
M
a
a
a
n
n
n
a
a
a
g
g
g
e
e
e
m
m
m
e
e
e
n
n
n
t
t
t


3
A
A
A
T
T
T
T
T
T
R
R
R
I
I
I
B
B
B
U
U
U
T
T
T
E
E
E
S
S
S


C
C
C
A
A
A
N
N
N


B
B
B
E
E
E


C
C
C
H
H
H
A
A
A
R
R
R
A
A
A
C
C
C
T
T
T
E
E
E
R
R
R
I
I
I
Z
Z
Z
E
E
E
D
D
D


B
B
B
Y
Y
Y


D
D
D
I
I
I
F
F
F
F
F
F
E
E
E
R
R
R
E
E
E
N
N
N
T
T
T


A
A
A
T
T
T
T
T
T
R
R
R
I
I
I
B
B
B
U
U
U
T
T
T
E
E
E


T
T
T
Y
Y
Y
P
P
P
E
E
E
S
S
S



S
S
S
i
i
i
m
m
m
p
p
p
l
l
l
e
e
e


a
a
a
n
n
n
d
d
d


C
C
C
o
o
o
m
m
m
p
p
p
o
o
o
s
s
s
i
i
i
t
t
t
e
e
e


A
A
A
t
t
t
t
t
t
r
r
r
i
i
i
b
b
b
u
u
u
t
t
t
e
e
e
s
s
s


When attributes are divided into only one part, then it is a single
attribute(example of single attribute described earlier); and when into several
subparts, it is a composite attribute(for example; an attribute Student Name
could be structured as a composite attribute consisting of first-name, middle-
name, and last-name.
S
S
S
i
i
i
n
n
n
g
g
g
l
l
l
e
e
e
-
-
-
v
v
v
a
a
a
l
l
l
u
u
u
e
e
e
d
d
d


a
a
a
n
n
n
d
d
d


M
M
M
u
u
u
l
l
l
t
t
t
i
i
i
-
-
-
v
v
v
a
a
a
l
l
l
u
u
u
e
e
e
d
d
d


A
A
A
t
t
t
t
t
t
r
r
r
i
i
i
b
b
b
u
u
u
t
t
t
e
e
e
s
s
s


In all our examples, we have single valued attributes. But in some cases, there
may more than one value for an attribute; say for, an attribute Student Phone
No. may have more than one number, or even no number.
D
D
D
e
e
e
r
r
r
i
i
i
v
v
v
e
e
e
d
d
d


A
A
A
t
t
t
t
t
t
r
r
r
i
i
i
b
b
b
u
u
u
t
t
t
e
e
e
s
s
s


Sometimes, the value for an attribute can be derived from the values of other
related attributes or entities. For example; the Student entity set has an
attribute Age, which indicates the students age. If the Student entity set also
has an attribute date-of-birth, we can calculate the age from the date-of-birth
and the current date.

R
R
R
E
E
E
L
L
L
A
A
A
T
T
T
I
I
I
O
O
O
N
N
N
S
S
S
H
H
H
I
I
I
P
P
P



A relationship is an association among several entities. It is used to establish a
connection between a pair of logical related entities. Separate entities can have
relationships with each other. For example; if students study various courses, the
entities Student and Course, while the relationship between them is Studies.





A relationship may associate an entity with itself. For example; in a company, one
employee may marry another employee; then the relationship will be expressed as
follows ::









Student Course Studies
Employee
Marriage
D
D
D
a
a
a
t
t
t
a
a
a
b
b
b
a
a
a
s
s
s
e
e
e


M
M
M
a
a
a
n
n
n
a
a
a
g
g
g
e
e
e
m
m
m
e
e
e
n
n
n
t
t
t


S
S
S
y
y
y
s
s
s
t
t
t
e
e
e
m
m
m
s
s
s


w
w
w
i
i
i
t
t
t
h
h
h


M
M
M
S
S
S


A
A
A
c
c
c
c
c
c
e
e
e
s
s
s
s
s
s



M
M
M
o
o
o
h
h
h
a
a
a
m
m
m
m
m
m
a
a
a
d
d
d


N
N
N
a
a
a
z
z
z
m
m
m
i
i
i


N
N
N
e
e
e
w
w
w
a
a
a
z
z
z
,
,
,


A
A
A
s
s
s
s
s
s
o
o
o
c
c
c
i
i
i
a
a
a
t
t
t
e
e
e


M
M
M
a
a
a
n
n
n
a
a
a
g
g
g
e
e
e
m
m
m
e
e
e
n
n
n
t
t
t


C
C
C
o
o
o
u
u
u
n
n
n
s
s
s
e
e
e
l
l
l
l
l
l
o
o
o
r
r
r
,
,
,


B
B
B
a
a
a
n
n
n
g
g
g
l
l
l
a
a
a
d
d
d
e
e
e
s
s
s
h
h
h


I
I
I
n
n
n
s
s
s
t
t
t
i
i
i
t
t
t
u
u
u
t
t
t
e
e
e


o
o
o
f
f
f


M
M
M
a
a
a
n
n
n
a
a
a
g
g
g
e
e
e
m
m
m
e
e
e
n
n
n
t
t
t


4


T
T
T
Y
Y
Y
P
P
P
E
E
E
S
S
S


O
O
O
F
F
F


R
R
R
E
E
E
L
L
L
A
A
A
T
T
T
I
I
I
O
O
O
N
N
N
S
S
S
H
H
H
I
I
I
P
P
P
S
S
S




There are three types of relationships that can exist between entities ::


One To One (1:1)





One To Many (1:m)




Many To Many (m:m)




Many To One (m:1)



D
D
D
e
e
e
p
p
p
a
a
a
r
r
r
t
t
t
m
m
m
e
e
e
n
n
n
t
t
t

Faculty-Member
Headed By
1 1
S
S
S
t
t
t
u
u
u
d
d
d
e
e
e
n
n
n
t
t
t


D
D
D
i
i
i
s
s
s
c
c
c
i
i
i
p
p
p
l
l
l
i
i
i
n
n
n
e
e
e


Register for
m 1
C
C
C
u
u
u
s
s
s
t
t
t
o
o
o
m
m
m
e
e
e
r
r
r


P
P
P
r
r
r
o
o
o
d
d
d
u
u
u
c
c
c
t
t
t


Purchase
m m
P
P
P
a
a
a
t
t
t
i
i
i
e
e
e
n
n
n
t
t
t
s
s
s


D
D
D
o
o
o
c
c
c
t
t
t
o
o
o
r
r
r


Appointment
m 1
D
D
D
a
a
a
t
t
t
a
a
a
b
b
b
a
a
a
s
s
s
e
e
e


M
M
M
a
a
a
n
n
n
a
a
a
g
g
g
e
e
e
m
m
m
e
e
e
n
n
n
t
t
t


S
S
S
y
y
y
s
s
s
t
t
t
e
e
e
m
m
m
s
s
s


w
w
w
i
i
i
t
t
t
h
h
h


M
M
M
S
S
S


A
A
A
c
c
c
c
c
c
e
e
e
s
s
s
s
s
s



M
M
M
o
o
o
h
h
h
a
a
a
m
m
m
m
m
m
a
a
a
d
d
d


N
N
N
a
a
a
z
z
z
m
m
m
i
i
i


N
N
N
e
e
e
w
w
w
a
a
a
z
z
z
,
,
,


A
A
A
s
s
s
s
s
s
o
o
o
c
c
c
i
i
i
a
a
a
t
t
t
e
e
e


M
M
M
a
a
a
n
n
n
a
a
a
g
g
g
e
e
e
m
m
m
e
e
e
n
n
n
t
t
t


C
C
C
o
o
o
u
u
u
n
n
n
s
s
s
e
e
e
l
l
l
l
l
l
o
o
o
r
r
r
,
,
,


B
B
B
a
a
a
n
n
n
g
g
g
l
l
l
a
a
a
d
d
d
e
e
e
s
s
s
h
h
h


I
I
I
n
n
n
s
s
s
t
t
t
i
i
i
t
t
t
u
u
u
t
t
t
e
e
e


o
o
o
f
f
f


M
M
M
a
a
a
n
n
n
a
a
a
g
g
g
e
e
e
m
m
m
e
e
e
n
n
n
t
t
t


5
K
K
K
E
E
E
Y
Y
Y
S
S
S




S
S
S
U
U
U
P
P
P
E
E
E
R
R
R
K
K
K
E
E
E
Y
Y
Y



A superkey is a set of one or more attributes that taken collectively, allow us to
identify uniquely an entity in the entity set. For example; the Customer ID
attribute of the entity set Customer is sufficient to distinguish one customer
entity from another. Thus, Customer ID is a superkey.


C
C
C
A
A
A
N
N
N
D
D
D
I
I
I
D
D
D
A
A
A
T
T
T
E
E
E


K
K
K
E
E
E
Y
Y
Y



An attribute or set of attributes that uniquely identifies a row is called a
Candidate key. This attribute has values that are unique. Consider the following
table ::
Table: Vehicle
Serial Number Registration Number Description
0234510001 02 5879 Toyota
0234510991 03 3687 Hyundai

The value of the attributes Serial Number, Reg. Number, and Description are
unique in every row. Therefore, all three are candidate keys.


P
P
P
R
R
R
I
I
I
M
M
M
A
A
A
R
R
R
Y
Y
Y


K
K
K
E
E
E
Y
Y
Y



The candidate key that is chosen to identify each row uniquely is called the
Primary Key. In the table, Vehicle, if Serial Number is chosen to identify rows
uniquely, then Serial Number is the Primary Key.




A
A
A
L
L
L
T
T
T
E
E
E
R
R
R
N
N
N
A
A
A
T
T
T
E
E
E


K
K
K
E
E
E
Y
Y
Y



A candidate key that is not chosen as a Primary key is an Alternate Key. In the
table Vehicle, Serial Number is chosen as the Primary Key, then Registration
Number is the Alternate Key.


C
C
C
O
O
O
M
M
M
P
P
P
O
O
O
S
S
S
I
I
I
T
T
T
E
E
E


K
K
K
E
E
E
Y
Y
Y



In certain tables, a single attribute cannot be used to identify rows uniquely and a
combination of two or more attributes is used as a Primary key. Such keys are
called Composite Keys.
D
D
D
a
a
a
t
t
t
a
a
a
b
b
b
a
a
a
s
s
s
e
e
e


M
M
M
a
a
a
n
n
n
a
a
a
g
g
g
e
e
e
m
m
m
e
e
e
n
n
n
t
t
t


S
S
S
y
y
y
s
s
s
t
t
t
e
e
e
m
m
m
s
s
s


w
w
w
i
i
i
t
t
t
h
h
h


M
M
M
S
S
S


A
A
A
c
c
c
c
c
c
e
e
e
s
s
s
s
s
s



M
M
M
o
o
o
h
h
h
a
a
a
m
m
m
m
m
m
a
a
a
d
d
d


N
N
N
a
a
a
z
z
z
m
m
m
i
i
i


N
N
N
e
e
e
w
w
w
a
a
a
z
z
z
,
,
,


A
A
A
s
s
s
s
s
s
o
o
o
c
c
c
i
i
i
a
a
a
t
t
t
e
e
e


M
M
M
a
a
a
n
n
n
a
a
a
g
g
g
e
e
e
m
m
m
e
e
e
n
n
n
t
t
t


C
C
C
o
o
o
u
u
u
n
n
n
s
s
s
e
e
e
l
l
l
l
l
l
o
o
o
r
r
r
,
,
,


B
B
B
a
a
a
n
n
n
g
g
g
l
l
l
a
a
a
d
d
d
e
e
e
s
s
s
h
h
h


I
I
I
n
n
n
s
s
s
t
t
t
i
i
i
t
t
t
u
u
u
t
t
t
e
e
e


o
o
o
f
f
f


M
M
M
a
a
a
n
n
n
a
a
a
g
g
g
e
e
e
m
m
m
e
e
e
n
n
n
t
t
t


6
Consider the following table, Purchase, which is used to maintain the purchases
made by various customers.

Customer_Code Product_Code Quantity Purchased Purchase Date
C0122 P0002 12 Feb 02 2002
C0134 P0005 15 Feb 02 2002
C0018 P0002 10 Feb 04 2002
C0122 P0003 17 Feb 04 2002
C0144 P0001 4 Feb 07 2002
C0134 P0003 9 Feb 07 2002

In the above table, all values are not unique for any of the attributes. However, a
combination of Customer_Code and Product_Code results in all unique values.
Hence, the combination can be used as a Composite Primary Key.

F
F
F
O
O
O
R
R
R
E
E
E
I
I
I
G
G
G
N
N
N


K
K
K
E
E
E
Y
Y
Y



When a Primary key of one table appears as an attribute in another table, it is
called the Foreign Key, in the second table. A foreign key is used to relate two
tables.



E
E
E
N
N
N
T
T
T
I
I
I
T
T
T
Y
Y
Y



R
R
R
E
E
E
L
L
L
A
A
A
T
T
T
I
I
I
O
O
O
N
N
N
S
S
S
H
H
H
I
I
I
P
P
P


D
D
D
I
I
I
A
A
A
G
G
G
R
R
R
A
A
A
M
M
M



An entity relation diagram or E/R diagram perceives the real world as consisting of
basic objects, called entities, and relationships among these objects. It is a tool to build
the logical database design of a system. An E/R diagram represents the following three
elements ::
Entities
Relationships
Attributes

E/R diagrams are simple and clear. An E/R diagram consists of the following major
components ::
Rectangles :: which represents entity sets.
Ellipses :: which represents attributes.
Diamonds :: which represents relationship sets.
Lines :: which link attributes to entity sets and
entity sets to relationship sets
Double Ellipses :: which represent multi-valued attributes.
Dashed Ellipses :: which denote derived attributes.
Double Lines :: which indicate total participation of an
entity in a relationship set.
Double Rectangles :: which represent weak entity sets.

Das könnte Ihnen auch gefallen