0% found this document useful (0 votes)
19 views

Entity/Relationship Modelling

The document discusses entity/relationship modeling and provides an example. It explains that an entity/relationship model represents a database as entities, attributes, and relationships. Entities are objects of interest with attributes. Relationships link entities. The example models a university database with entities for departments, courses, modules, lecturers, and students and relationships like "offers" and "teaches."
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Entity/Relationship Modelling

The document discusses entity/relationship modeling and provides an example. It explains that an entity/relationship model represents a database as entities, attributes, and relationships. Entities are objects of interest with attributes. Relationships link entities. The example models a university database with entities for departments, courses, modules, lecturers, and students and relationships like "offers" and "teaches."
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 38

Entity/Relationship Modelling

Entity/Relationship Modelling
Modelling:
• A database can be modeled as:
• a collection of entities,
• relationship among entities.

• E/R Modelling is used for conceptual design


• Entities - objects or items of interest
• Attributes - facts about, or properties of, an entity
• Relationships - links between entities

• Example
• In a University database we might have entities for Students, Modules and Lecturers. Students
might have attributes such as their ID, Name, and Course, and could have relationships with
Modules (enrolment) and Lecturers (tutor/tutee)
Entity/Relationship Diagrams
• E/R Models are often represented as E/R diagrams that
• Give a conceptual view of the database
Lecturer ID
• Are independent of the choice of DBMS
• Can identify some problems in a design Name Course

Tutors Student

Module Studies
Entities
• Entities represent objects or things of interest
• Physical things like students, lecturers, employees, products
• More abstract things like modules, orders, courses, projects

• Entities have
• A general type or class, such as Lecturer or Module
• Instances of that particular type, such as Steve Mills, Natasha Alechina are instances of
Lecturer
• Attributes (such as name, email address)
Diagramming Entities

Lecturer ID

Name Course
• In an E/R Diagram, an entity is usually drawn as a box with
rounded corners
Tutors Student
• The box is labelled with the name of the class of objects
represented by that entity

Module Studies
Attributes
• Attributes are facts, aspects, properties, or details about an entity
• Students have IDs, names, courses, addresses, …
• Modules have codes, titles, credit weights, levels, …

• Attributes have
• A name
• An associated entity
• Domains of possible values
• Values from the domain for each instance of the entity they are belong to
• Attribute types:
• Simple and composite attributes.
• Single-valued and multivalued attributes
• Example: multivalued attribute: phone_numbers
• Derived attributes
• Can be computed from other attributes
• Example: age, given date_of_birth
Diagramming Attributes

Lecturer ID

• In an E/R Diagram attributes may be drawn as ovals Name Course

• Each attribute is linked to its entity by a line


• The name of the attribute is written in the oval Tutors Student

Module Studies
Relationships
• Relationships are an association between two or more entities
• Each Student takes several Modules
• Each Module is taught by a Lecturer
• Each Employee works for a single Department

• Relationships have
• A name
• A set of entities that participate in them
• A degree - the number of entities that participate (most have degree 2)
• A cardinality ratio
Mapping Cardinality Constraints
• 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

One to one One to many

Note: Some elements in A and B may not be mapped to any elements in the other set
Mapping Cardinalities

Many to one Many to many

Note: Some elements in A and B may not be mapped to any elements in the other set
E-R Diagrams

 Rectangles represent entity sets.


 Diamonds represent relationship sets.
 Attributes listed inside entity rectangle
 Underline indicates primary key attributes
Cardinality Ratios
• Each entity in a relationship can participate in zero, one, or more than one instances of that
relationship
• This leads to 3 types of relationship…

• One to one (1:1)


• Each lecturer has a unique office
• One to many (1:M)
• A lecturer may tutor many students, but each student has just one tutor
• Many to many (M:M)
• Each student takes several modules, and each module is taken by several students
Diagramming Relationships

Lecturer ID
• Relationships are links between two entities
Name Course
• The name is given in a diamond box
• The ends of the link show cardinality
Tutors Student

One Many

Module Studies
Removing M:M Relationships
Student
• Many to many relationships are difficult to represent
• We can split a many to many relationship into two one to Student
many relationships Has

• An entity represents the M:M relationship


Studies Enrolment

In
Module

Module
Making E/R Models
• To make an E/R model you need to identify
• Enitities
• Attributes
• Relationships
• Cardinality ratios
• from a description
• General guidelines
• Since entities are things or objects they are often nouns in the description
• Attributes are facts or properties, and so are often nouns also
• Verbs often describe relationships between entities

Entity Relationship Modelling


Example
A university consists of a number of departments. Each department offers several courses. A
number of modules make up each course. Students enrol in a particular course and take modules
towards the completion of that course. Each module is taught by a lecturer from the appropriate
department, and each lecturer tutors a group of students

Example - Entities
A university consists of a number of departments. Each department offers several courses. A
number of modules make up each course. Students enrol in a particular course and take modules
towards the completion of that course. Each module is taught by a lecturer from the appropriate
department, and each lecturer tutors a group of students

Example - Relationships
A university consists of a number of departments. Each department offers several courses. A number
of modules make up each course. Students enrol in a particular course and take modules towards
the completion of that course. Each module is taught by a lecturer from the appropriate department,
and each lecturer tutors a group of students
Example - E/R Diagram
Entities: Department, Course, Module, Lecturer, Student

Department

Course Module Lecturer

Student

Entity Relationship Modelling


Example - E/R Diagram
Each department offers several courses

Offers Department

Course Module Lecturer

Student

Entity Relationship Modelling


Example - E/R Diagram
A number of modules make up each courses

Offers Department

Course Includes Module Lecturer

Student

Entity Relationship Modelling


Example - E/R Diagram
Students enrol in a particular course

Offers Department

Course Includes Module Lecturer

Enrols In Student

Entity Relationship Modelling


Example - E/R Diagram
Students … take modules

Offers Department

Course Includes Module Lecturer

Takes

Enrols In Student

Entity Relationship Modelling


Example - E/R Diagram
Each module is taught by a lecturer

Offers Department

Course Includes Module Teaches Lecturer

Takes

Enrols In Student

Entity Relationship Modelling


Example - E/R Diagram
a lecturer from the appropriate department

Offers Department Employs

Course Includes Module Teaches Lecturer

Takes

Enrols In Student

Entity Relationship Modelling


Example - E/R Diagram
each lecturer tutors a group of students

Offers Department Employs

Course Includes Module Teaches Lecturer

Takes

Enrols In Student Tutors

Entity Relationship Modelling


Example - E/R Diagram

Offers Department Employs

Course Includes Module Teaches Lecturer

Takes

Enrols In Student Tutors

Entity Relationship Modelling


Entities and Attributes

• Sometimes it is hard to tell if something should be an entity or an attribute


• They both represent objects or facts about the world
• They are both often represented by nouns in descriptions

• General guidelines
• Entities can have attributes but attributes have no smaller parts
• Entities can have relationships between them, but an attribute belongs to a single entity

Entity Relationship Modelling


Example
• We want to represent information about products in a database. Each product has a description, a
price and a supplier. Suppliers have addresses, phone numbers, and names. Each address is made up
of a street address, a city, and a postcode.

Example - Entities/Attributes

• Entities or attributes:
• product • Products, suppliers, and addresses all have smaller parts so we
• description can make them entities
• price • The others have no smaller parts and belong to a single entity
• supplier
• address
• phone number
• name
• street address
• city
• postcode
Example - E/R Diagram
Street address
Price

Description Product Address City

Postcode

Example - Relationships
Name Supplier • Each product has a supplier
• Each product has a single supplier but there is nothing to
stop a supplier supplying many products
Phone number
• A many to one relationship
• Each supplier has an address
• A supplier has a single address
• It does not seem sensible for two different suppliers to
have the same address
• A one to one relationship
Example - E/R Diagram

Price

Description Product

Has A Street address

Name Supplier Has A Address City

Phone number Postcode


Please convert the ER diagram into a relational database
schema. Be certain to indicate primary keys and referential
integrity constraints.
Find the name of the “Entities”, “Attributes” and
“Relationships” using following paragraph
UPS prides itself on having up-to-date information on the processing and current
location of each shipped item. To do this, UPS relies on a company-wide information
system. Shipped items are the heart of the UPS product tracking information system.
Shipped items can be characterized by item number (unique), weight, dimensions,
insurance amount, destination, and final delivery date. Shipped items are received
into the UPS system at a single retail center. Retail centers are characterized by their
type, uniqueID, and address. Shipped items make their way to their destination via
one or more standard UPS transportation events (i.e., flights, truck deliveries). These
transportation events are characterized by a unique scheduleNumber, a type (e.g,
flight, truck), and a deliveryRoute.
One to One Relationships
• Some relationships between entities, A and B, might be redundant if
• It is a 1:1 relationship between A and B
• Every A is related to a B and every B is related to an A
• Example - the supplier-address relationship
• Is one to one a x
• Every supplier has an address
• We don’t need addresses that are not related to a supplier b A B y

Redundant Relationships c z
• We can merge the two entities that take part in a redundant
relationship together
• They become a single entity a x
• The new entity has all the attributes of the old one
b AB y

c z
Example - E/R Diagram

Price

Description Product

Has A

Name Supplier City

Phone number Postcode Street address


Alternative ER Notations
Chen IDE1FX (Crows feet notation)
Summary of Symbols Used in E-R Notation
Symbols Used in E-R Notation (Cont.)
Alternative ER Notations

• Chen, IDE1FX, …

You might also like