Database Systems (3+1)_Entity Relationship Models (2).pptx
1. Database Systems (3+1)
Entity Relationship Models
Aakash Ahmad (Lecturer)
Computer Science Dept.
CECOS University of IT and Technology, Peshawar
2. Contents and Objectives
Contents
● ER Model/ERD
● Design Process
● Modeling
● Constraints
● E-R Diagram
● Design Issues
● Weak Entity Sets
● Extended E-R Features
● Design of the University Database
● Database Design UML
Objectives
To understand ER model
● Design
● ER Modeling
Constraints To understand ER-Diagram
○ Entity
○ Attributes
○ Tuples
○ Associations
3. Database Design Phases
● The initial phase of database design is to fully characterize the data according to the needs of
database users.
●Next, the designer chooses a data model to translate the requirements into a conceptual
schema of the database.
●The process of moving from a data model to the implementation of the database proceeds in
two final design phases.
●Logical Design – Deciding on the database schema. Database design requires that we find a
“good” collection of relation schemas.
●Physical Design – Deciding on the physical layout of the database.
4. ER Model
● The ER data model was developed to facilitate database design
●An Entity Relationship Model (E-R Model) is a detailed, logical representation of the
data for an organization or for business area.
●ER Model is used to show the Conceptual Schema of an Organisation. E-R Model is
expressed in three terms:
○ Entities
○ Relationship (or association)
○ Attributes
5. Entity
●Entity is the basic building block of the Entity Relation Data Model.
●The term Entity is used in three different meanings or for three different terms
and that are:
■ Entity Type
■ Entity Instance
■ Entity Set
6. Entity Type
●Entity Type: A collection or a set of entities (often corresponds to a table) that shares common properties.
●The Entity Type can be defined as a name/label assigned to items/objects which have similar properties.
● It could be a person, place, object or event about which the organization wishes to maintain data.
●Examples are: Departments, Employees, Students, and Orders etc. To represent an Entity Type in a
Model, use the following conventions:
○ Soft box with rectangle dimensions.
○ Singular, Unique entity name.
○ Entity name in Uppercase.
7. Entity Instance and Set
● : A single occurrence (existence) of an Entity Type is called Entity Instance.
● For example, following table lists the Entity Types and their defining Properties and Instances.
● Entity Set: A group of Entity Instances of a particular Entity Type is called an Entity Set.
● For example, all employees of an organization form an Entity Set. Like all students, all
courses, all of them form Entity Set of different Entity Types.
8. Entity Types:
There are two types of Entity Types
Strong/Regular Entity Type
● An Independent Entity. An Entity Type that exists
independently of other Entity Types.
● The Strong Entity Type is also called the Identifying
Owner.
● An Entity Type whose Instances can exist
independently, that is, without being linked to the
Instances of any other Entity Type is called Strong
Entity Type.
● A major property of the Strong Entity Type is that they
have their own identification.
● For example, employee in an organization, is an
independent or Strong Entity Type, since its Instances
can exist independently.
Weak Entity Type/Dependent Entity.
● An Entity Type whose existence depends on another
Entity Type.
● An Entity Type whose Instances cannot exist without
being linked with Instances of some other Entity Type,
i.e., they cannot exist independently.
● For example, in an organization, to maintain data about the
Vehicles owned by the employees. Now a particular Vehicle
can exist in this organization only if the owner already exists
there as employee. Similarly, if an employee leaves the job
and the organization decides to delete the record of the
employee then the record of the Vehicle will also be deleted
since it cannot exist without being linked to an Instance of
employee.
9. Entity Types:
There are two types of Entity Types
Strong/Regular Entity Type
● Strong entity always has a primary key.
● Strong entity is not dependent on any other entity.
● Strong entity is represented by a single rectangle.
● Relationship between two strong entities is
represented by a single diamond.
Weak Entity Type/Dependent Entity.
● While a weak entity has not a primary key.
● Weak entity depends on strong entity.
● Weak entity is represented by a double rectangle.
● While the relationship between one strong and one
weak entity is represented by a double diamond.
10. Relationship/Association
●Relationship represents an association between two or more entities.
●Relationships are the connections and interactions between the Entity
Instances.
●Examples are employees and departments, orders and items etc.
○ Symbol of Relationship: Diamond
○ Symbol of Relationship (Weak Relation): Double Diamond
11. Relationship/Association
●Types/Degree of Relationships/Association:
●A Relationship may consist of many Entity Types.
●The number of Entity Types in a Relationship is called Degree of Relationship.
●The Relationships of Degree 2 are most common and are also called Binary Relationships.
●The Types of Relationships with respect to Degree are as follows:
○ 1. Unary Relationship
○ 2. Binary Relationship
○ 3. Ternary Relationship
12. ●Unary Relationship/Association
●Unary Relationship is a type of Relationship that is established between the
Instances of same Entity Type.
●An Entity Type linked with itself, also called Unary/Recursive Relationship.
●Example: Roommate, where STUDENT is linked with STUDENT. The Degree
of Unary Relationship is 1.
13. Binary Relationship/Association
●Binary Relationships exist between the Instances of two Entity Types.
●A Binary Relationship is the one that links two Entities Types e.g., STUDENT -
CLASS.
●The Degree of Binary Relationship is 2.
14. Ternary Relationship/Association
● Ternary Relationship exists among the Instances of three Entity Types.
● A Ternary Relationship is the one that involves three Entity Types.
●The Degree of Ternary Relationship is 3.
●The following Relationship means that one or many Analysts with one or many
Programmers work on one or more Projects.
15. Relationship Cardinalities:
The Cardinality of a Relationship is the number
of Entity Instances that can be associated with
another Entity Instances under that Relationship.
22. Cardinality Constraints:
The Cardinality Constraint specifies the number of instances of one entity Type that can be associated with each
instance of the other Entity Type.
There are three symbols to show Cardinality Constraint.
● A circle (O) means Zero,
● A line ( ) means one and crow’s foot symbol means many.
● A circle O indicates that relationship is Optional.
● A stroke indicates that relationship Mandatory.
● A crows-foot indicates that many relationships between instances.
Notation Styles: There are many notation styles that express cardinality.
● Information Engineering Style
● Chen Style
● Bachman Style
● Martin Style
27. Quiz 2
Draw an Conceptual Schema & ERD Diagram of a Hospital System Showing All Possible Attributes, Entities and
the Relationships that exist between them.
28. Attributes
●Attributes: A property or characteristic of an Entity Type is called an Attribute.
●Something that describes an Entity Type.
● For example, the employee Entity Type, the attributes would be the employee
number, name, job title, hire date, department number and so on. To represent
an attribute in a Model, use the following conventions: - Use Singular Name in
Lowercase - Symbol for Attribute
29. Attributes
●A property or characteristic of an Entity Type is called an Attribute.
●Something that describes an Entity Type.
● For example, the employee Entity Type, the attributes would be the employee
number, name, job title, hire date, department number and so on. To represent
an attribute in a Model, use the following conventions: - Use Singular Name in
Lowercase - Symbol for Attribute
31. Attributes
● Required Attribute: A Required Attribute is an Attribute that must have a data
value e.g., Student Registration Number, CNIC, Name etc. These Attributes are
required because they describe what is important in the entity.
● Optional Attribute: An Optional Attribute may or may not have a data value in it
and can be left blank e.g., Student Phone Number, Email Address, Passport
Number etc.
● Simple Attribute: An Attribute that cannot be decomposed into smaller Attributes
e.g., age, roll#, CNIC, Phone# etc. Symbol for Simple Attribute
32. Attributes
● Composite Attribute: An Attribute that can be decomposed into smaller Attributes e.g.
Name, address etc.
○ Name can be divided into first name, middle name, last name. Address can be
divided into House#, Street#, Sector#, Phase#, Tehsil, District etc. Symbol for
Composite Attribute.
● Single/Atomic Valued Attribute: An Attribute that has only one value for an Entity
e.g., Roll# CNIC, Passport#, name, father name etc.
● Multi Valued Attribute: An Attribute that can have more than one values for an Entity
e.g., Address, Email Address, Phone#, Subject, Hobbies, Skills etc. Symbol for Multi
valued Attribute
33. Attributes
● Stored Attribute: Normally Attributes are Stored Attributes, that is, their
values are stored and accessed as such from the database.
○ An Attribute whose value is stored in the database and cannot be derived from another
Attribute e.g., Date of Birth (D.O.B).
● Derived Attribute: Sometimes Attributes values are not stored as such,
rather they are computed or derived based on some other value which is
stored in database.
○ An Attribute whose value can be derived/calculated from the Stored Attribute e.g., age
which is derived from D.O.B, experience etc.
○ A Derived Attribute is based on another Attribute. Symbol for Derived Attribute
35. ERD
● E-R Diagram is a graphical representation of E-R model using a set of standard symbols.
● ER Diagram is a type of flowchart that illustrates how “entities” such as people, objects or
concepts relate to each other within a system.
● ER Diagram shows the complete logical structure of a database.
● ER Diagrams are created based on three basic concepts: entities, attributes and relationships.
● Components/Elements in ERD: The major activity is identifying entities, attributes, and their
relationships to construct model using the Entity Relationship Diagram.
● The E-R Diagram supports the following major components/Elements:
● Entity Table
● Attribute Column
● Relationships Line