Entity-Relationship Model
Entity-Relationship Model
• Entity Sets
• Relationship Sets
• Mapping Constraints
• E-R Diagram
• Extended E-R Features
• Design of an E-R Database Schema
• Reduction of an E-R Schema to Tables
Entity Sets
• A database can be modeled as:
• a collection of entities,
• relationship among entities.
• An entity is an object that exists and is distinguishable from
other objects.
• Example: specific person, company, event, plant
• Entities have attributes
• Example: people have names and addresses
• An entity set or entity type is a set of entities of the same type
that share the same properties.
• Example: set of all persons, companies, trees, holidays
Entity Sets customer and loan
customer-id customer- customer- customer- loan- amount
name street city number
Attributes
• An entity is represented by a set of attributes, that is descriptive
properties possessed by all members of an entity set.
Example:
customer = (customer-id, customer-name,
customer-street, customer-city)
loan = (loan-number, amount)
• Domain – the set of permitted values for each attribute
Types of Attributes-
1. Simple attributes
2. Composite attributes
3. Single valued attributes
4. Multi valued attributes
5. Derived attributes
6. Key attributes
1. Simple Attributes-
• Here, all the attributes are simple attributes as they can not
be divided further.
2. Composite Attributes-
• Here, all the attributes are single valued attributes as they can
take only one specific value for each entity.
4. Multi Valued Attributes-
2 r1
e1
1
e2 r2
1
e3 2 r3
1
e4 2 r4
e5 r5
Degree of a Relationship Set
• Refers to number of entity sets that participate in a relationship
set.
• Relationship sets that involve two entity sets are binary (or
degree two). Relationship sets that involve three entity sets are
ternary Generally, most relationship sets in a database system are
binary.
• Relationship sets may involve more than two entity sets.
E.g. Suppose employees of a bank may have jobs
(responsibilities) at multiple branches, with different jobs at
different branches. Then there is a ternary relationship set
between entity sets employee, job and branch
• Relationships between more than two entity sets are rare. Most
relationships are binary. (More on this later.)
Mapping Cardinalities or Cardinality
Ratio
• Express the number of entities to which another entity can
be associated via a relationship set.
• Most useful in describing binary relationship sets.
• For a binary relationship set the mapping cardinality must be
one of the following types:
• One to one
• One to many
• Many to one
• Many to many
Mapping Cardinalities
• All the keys which are not primary key are called an alternate
key.
• It is a candidate key which is currently not the primary key.
However, A table may have single or multiple choices for the
primary key.
Example:
StudID Roll No First Name LastName Email
1 11 Tom Price [email protected]
2 12 Nick Wright [email protected]
3 13 Dana Natan [email protected]
• In the given above table Stud ID, Roll No, and Email are candidate keys
which help us to uniquely identify the student record in the table.
What is the Foreign key?
DeptCode DeptName
001 Science
002 English
005 Computer
Table2:Teacher