0% found this document useful (0 votes)
40 views40 pages

The ER

Uploaded by

Adnan Asif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views40 pages

The ER

Uploaded by

Adnan Asif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

 The entity-relationship (E-R) data model was

developed to facilitate database design by


allowing specification of an enterprise schema
that represents the overall logical structure of a
database.

 The E-R data model employs three basic


concepts: entity sets, relationship sets, and
attributes.
 An entity is an object that exists and is
distinguishable from other objects.
 Example: specific person, company, event, plant
 An entity has a set of properties, and the
values for some set of properties may
uniquely identify an entity.
 Example: person_id property of a person
 An entity may be concrete or abstract
 Example: person or book are concrete
 Example: course offering, or a flight reservation
are abstract
 Anentity set is a set of entities of the same
type that share the same properties.
 Example: set of all persons, companies, trees,
holidays
 Extension of the entity set refer to the
actual collection of entities belonging to the
entity sets.
 Set of actual instructors in the university forms
extension of the entity set instructor.
 Entity sets do not need to be disjoint.
 An entity is represented by a set of
attributes. Attributes are the descriptive
properties possessed by each member of an
entity set. Each entity may have its own
value for each attribute.
 Possible attributes of the instructor entity set are
ID, name, dept_name, and salary.
 Each entity has a value for each of its
attribute.
 A particular entity instructor may have the value
12121 for ID, the value Wu for name, the value
Finance for dept_name, and value 90000 for
salary.
A database can be modeled as:
 a collection of entities,
 relationship among entities.
 Thefigure shows part of university database
that consists of two entity sets : instructor
and student.
A relationship is an association among
several entities.
 A relationship set is a set of relationships of
the same type.
 A relationship set “Advisor” denotes the
association between instructors and students.
 The association between entity sets is
referred to as participation.
 The Entity sets E1,E2,…,En participate in the
relationship set R.
A relationship instance in an E-R schema
represents an association between the
named entities in the real-world enterprise
that is being modeled.
 The individual instructor Katz, who has
instructor ID 45565, and the student entity
Shankar, who has the student ID 12345,
participate in the relationship instance of
advisor. This instance represents that in the
university, the instructor Katz is advising student
Shankar.
 The function that an entity plays in a
relationship is called entity’s role.

 The same entity may participate in the


relationship set more than once, in different
roles, this type of relationship set is called a
recursive relationship set.
A relationship may also have attributes called
descriptive attributes. As shown in the figure
below, the attribute date with the
relationship specifies the date when an
instructor became the advisor of the student.
 The number of entity sets that participate in
the relationship set is the degree of the
relationship set.
 A binary relationship set is of degree 2; a ternary
relationship set is of degree 3.
 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
 The attribute take a null value when the
entity does not have a value for it.
 Simple and composite attributes

 Simple:
 They have not been divided into subparts.

 Composite:
 They have been divided into subparts.
 Example: an attribute name could be structured as a
composite attribute consisting of first_name,
middle_initial and last_name.
 Single-valued and multi-valued attributes

 Single-valued :
 The student_id attribute for a specific student entity
refers to only one student ID.

 Multi-valued :
 An instructor may have zero, one, or several phone
numbers, and different instructors may have different
numbers of phone.
 Derived attributes

 The instructor entity set has an attribute age


that indicates instructor’s age. If it also has an
attribute date_of_birth, we can calculate age
from it and the current date. So age is derived
attribute. Date_of_birth may be referred to as
base or stored attribute. The value of derived
attribute is not stored but is computed when
required.
 AnE-R diagram can express the overall
logical structure of the database graphically.
 Rectangles divided into two parts represent entity
sets.
 The first part, contains the name of the entity set. The
second part contains the names of all the attributes of
the entity set.
 Diamonds represent relationship sets.
 Undivided rectangles represent the attributes of a
relationship set. Attributes that are part of the primary
key are underlined.
 Lines link entity sets to relationship sets.
 Dashed lines link attributes of a relationship set to the
relationship set.
 Double lines indicate total participation of an entity in a
relationship set.
 Double diamonds represent identifying relationship sets
linked to weak entity sets
 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
A directed line from the relationship set
advisor to both entity sets instructor and
student. This indicates that an instructor may
advise at most one student, and a student may
have at most one advisor.
A directed line from the relationship set
advisor to the entity set instructor and an
undirected line to the entity set student.
This indicates that an instructor may advise
many students, but a student may have at
most one advisor.
 An undirected line from the relationship set
advisor to the entity set instructor and a
directed line to the entity set student. This
indicates that an instructor may advise at
most one student, but a student may have
many advisors.
 Anundirected line from the relationship set
advisor to both entity sets instructor and
student. This indicates that an instructor
may advise many students, and a student
may have many advisors.
 An entity set that does not have a primary
key is referred to as a weak entity set.
 The existence of a weak entity set depends
on the existence of a identifying or owner
entity set
 the identifying relationship is many-to-one from
the weak entity set to the identifying entity set,
and the participation of the weak entity set in
the relationship is total.
 Identifying relationship is depicted using a
double diamond.
 The discriminator (or partial key) of a weak
entity set is the set of attributes that
distinguishes among all the entities of a weak
entity set.

 The primary key of a weak entity set is


formed by the primary key of the strong
entity set on which the weak entity set is
existence dependent, plus the weak entity
set’s discriminator
 In E-R diagrams, a weak entity set is
depicted via a rectangle, like a strong entity
set, but there are two main differences:
 The discriminator of a weak entity is underlined
with a dashed, rather than a solid, line.
 The relationship set connecting the weak entity
set to the identifying strong entity set is
depicted by a double diamond.
 One entity type might be subtype of another
 Freshman is a subtype of Student
A relationship exists between a Freshman entity
and the corresponding Student entity
 e.g., Freshman John is related to Student John
 This relationship is called IsA
 Freshman IsA Student
 The two entities related by IsA are always
descriptions of the same real-world object

29
 Inheritance - Attributes of supertype apply to
subtype.
 E.g., GPA attribute of Student applies to Freshman
 Subtype inherits all attributes of supertype.
 Key of supertype is key of subtype
 Transitivity - Hierarchy of IsA
 Student is subtype of Person, Freshman is subtype of
Student

30
 Advantage: Used to create a more concise
and readable E-R diagram
 Attributes common to different entity sets need
not be repeated
 They can be grouped in one place as attributes of
supertype
 Attributes of (sibling) subtypes can be different

31
 Top-down design process; we designate subgroupings
within an entity set that are distinctive from other
entities in the set.
 These subgroupings become lower-level entity sets
that have attributes or participate in relationships
that do not apply to the higher-level entity set.
 Depicted by a triangle component labeled ISA (E.g.
customer “is a” person).
 Attribute inheritance – a lower-level entity set
inherits all the attributes and relationship
participation of the higher-level entity set to which it
is linked.
 A bottom-up design process – combine a number of
entity sets that share the same features into a
higher-level entity set.
 Specialization and generalization are simple
inversions of each other; they are represented in an
E-R diagram in the same way.
 The terms specialization and generalization are used
interchangeably.
 The ISA relationship also referred to as superclass

- subclass relationship
 Aggregation is an abstraction through which
relationships are treated as higher level entities.

 Eliminate this redundancy via aggregation


 Treat relationship as an abstract entity
 Allows relationships between relationships
 Abstraction of relationship into new entity

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy