E-R MODEL
Mrs. Anupama Sahu
Asst. Prof. Of CSE Dept
IGIT,Sarang
Basic Concepts of ER Model in DBMS
Entity-relationship model is a model used for
design and representation of relationships
between data.
In ER model the main data objects are
termed as Entities, with their details defined
as attributes, some of these attributes are
important and are used to identity the entity,
and different entities are related using
relationships.
STD
Lets take an example of a Student.
BRANC
S_ID H
NAME ADD
ER Model: Attributes
If a Student is an Entity, then student's roll
no., student's name, student's age,
student's gender etc will be its attributes.
There are different types of attributes defined
in ER database model.
1. Simple attribute
[Link] attribute
[Link] attribute
[Link] value attribute
[Link] attribute
Simple attribute: The attributes with values that are atomic
and cannot be broken down further are simple attributes. For
example, student's age.
Composite attribute: A composite attribute is made up of
more than one simple attribute. For example,
student's address will contain, house no., street
name, pincode etc.
Derived attribute: Derived attributes are those which are
derived based on other attributes. Age can be derived
from DOB.
Single-valued attribute: As the name suggests, they have a
single value.
Multi-valued attribute: And, they can have multiple values.
ER Model: Keys
It is a set of one or more attributes whose
values are unique among all occurrence in a
given table.
Based on the property of uniqueness, keys can
be classified
1-Primary key
2- Foreign key
[Link] key
[Link] key
[Link] Key
[Link] key
[Link] key
Primary key is a key that can be uniquely
identified each record in a table.
Student_table
Primary key of this table
S_id Name [Link] Age
1 Alok 987672345 17
2
2 Anupama 999116567 19
4
3 Sujit 789875654 18
3
4 Punam 898786789 19
8
5 Barun 999008008 17
[Link] key
A Foreign key is a field (or collection of fields) in one
table, that refers to the Primary key in another table.
Foreign Key
S_id Name [Link] Age Dept._i S_id Dept._name
1 Alok 9876723452 17 d
101 1 CSE
2 Anupama 9991165674 19
102 2 CSE
3 Sujit 7898756543 18
103 3 ETC
4 Punam 8987867898 19
104 4 MECH
5 Barun 9990080080 17 105 5 ELECT
[Link] key
Candidate keys are defined as the minimal
set of fields which can uniquely identify each
record in a table.
It is an attribute or a set of attributes that
can act as a Primary Key for a table to
uniquely identify each record in that table.
There can be more than one candidate key.
student_id and phone both are candidate
keys for table Student.
[Link] key
Super Key is defined as a set of attributes within a
table that can uniquely identify each record within
a table. Super Key is a superset of Candidate key.
In the table defined above super key would
include student_id, (student_id, name), phone etc.
The first one is pretty simple as student_id is
unique for every row of data, hence it can be used
to identity each row uniquely.
Next comes, (student_id, name), now name of two
students can be same, but their student_id can't be
same hence this combination can also be a key.
Similarly, phone number for every student will be
unique, hence again, phone can also be a key.
[Link] key
Key that consists of two or more attributes
that uniquely identify any record in a table is
called Composite key. But the attributes
which together form the Composite key are
not a key independentely or individually.
S_id Dept._id Name [Link] Age
1 101 Alok 9876723452 17
2 102 Anupama 9991165674 19
3 103 Sujit 7898756543 18
4 104 Punam 8987867898 19
5 105 Barun 9990080080 17
[Link] key/Secondary key
The candidate key which are not selected as
primary key are known as secondary keys or
alternative keys.