0% found this document useful (0 votes)
35 views26 pages

LECTURE - 3 Entity-Relationship Data Model

Relational database

Uploaded by

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

LECTURE - 3 Entity-Relationship Data Model

Relational database

Uploaded by

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

DATA MODELING

• Data modelling is the process of defined the structure of data and


relationships.
• We use ER diagram to model the database structure.
ER (Entity Relationship) Diagram in
DBMS
• ER model stands for an Entity-Relationship model. It is a
high-level data model. This model is used to define the
data elements and relationship for a specified system.
• It develops a conceptual design for the database. It also
develops a very simple and easy to design view of data.
• In ER modeling, the database structure is portrayed as a
diagram called an entity-relationship diagram.
• ER diagram is generally defined as the diagram that
defines the data elements and their relationships at
high level
ER (Entity Relationship) Diagram in
DBMS
• For example, Suppose
we design a school
database. In this
database, the student
will be an entity with
attributes like address,
name, id, age, etc. The
address can be another
entity with attributes like
city, street name, pin
code, etc and there will
be a relationship
between them.
Component of ER Diagram
Building Blocks of Entity-Relationship Diagram
Entity
• An entity may be any object, class, person or place. In
the ER diagram, an entity can be represented as
rectangles.
• Consider an organization as an example- manager,
product, employee, department etc. can be taken as an
entity.
Attribute
• The attribute is used to
describe the property of
an entity. Eclipse is used to
represent an attribute.
• For example, id, age,
contact number, name,
etc. can be attributes of a
student.
Key Attribute

• The key attribute is


used to represent the
main characteristics of
an entity. It represents
a primary key. The key
attribute is
represented by an
ellipse with the text
underlined.
Composite Attribute
• An attribute that
composed of many
other attributes is
known as a composite
attribute. The
composite attribute is
represented by an
ellipse, and those
ellipses are connected
with an ellipse.
Multivalued Attribute

• An attribute can have


more than one value.
These attributes are
known as a multivalued
attribute. The double oval
is used to represent
multivalued attribute.
• For example, a student
can have more than one
phone number.
Derived Attribute

• An attribute that can be


derived from other attribute
is known as a derived
attribute. It can be
represented by a dashed
ellipse.
• For example, A person's
age changes over time and
can be derived from
another attribute like Date
of birth.
Relationship
• A relationship is used to describe the relation between entities.
Diamond or rhombus is used to represent the relationship.
Types of relationships
• There are three types of relationship
• One to one relationship
• One to many relationship / many to one relationship
• Many to many relationship
One to one relationship
• When only one instance of an entity is associated with
the relationship, then it is known as one to one
relationship.
• For example, A female can marry to one male, and a
male can marry to one female.
One to many relationship
• When only one instance of the entity on the left, and
more than one instance of an entity on the right
associates with the relationship then this is known as a
one-to-many relationship.
• For example, Scientist can invent many inventions,
but the invention is done by the only specific scientist.
One to many relationship
• When only one instance of the entity on the left, and
more than one instance of an entity on the right
associates with the relationship then this is known as a
one-to-many relationship.
• For example, Scientist can invent many inventions,
but the invention is done by the only specific scientist.
Many-to-many relationship

• When more than one instance of the entity on the left,


and more than one instance of an entity on the right
associates with the relationship then it is known as a
many-to-many relationship.
• For example, Employee can assign by many projects
and project can have many employees.
Crow’s Foot Diagrammatic Notation of ER diagram

• Database can be
represented using the
notations. In ER
diagram, many
notations are used to
express the cardinality.
These notations are as
follows:
Reduction of ER diagram to Table

• The database can be


represented using the
notations, and these
notations can be
reduced to a collection
of tables.
• In the database, every
entity set or
relationship set can be
represented in tabular
form.
Reduction of ER diagram to relational data model (Table structure)

• Entity type becomes a table.


• All single-valued attribute becomes a column for the table.
• The multivalued attribute is represented by a separate table
• Composite attribute represented by components.
• Derived attributes are not considered in the table.
Advantages of ER diagram
The E-R model is a very simple approach to designing a database which considers the real world as consisting
of entities and relationships between them. The real world, of course, can be a lot more complex than the
simple view used in E-R modeling but the E-R model approach continues to be widely used by database
designers because it offers
1. Simplicity—As noted above, the approach is simple and easy to use with a client even if the client
knows little about computing.
2. Visual Representation—An entity-relationship diagram provides a clear, high-level view of the
proposed database.
3. Effective Communication—As noted above, visual representation of the model provides a clear, highlevel
view of the proposed database. This makes it easier to communicate with the client.
4. Ease of Mapping to the Relational Model—The E-R model was developed with the relational model
in mind and the entity and relationship constructs map easily to the relational model as we will find in
the next chapter.
5. Focus on the Model—The E-R model allows the database designer to focus on the complete and
accurate modeling of the enterprise without having to think about efficiency of implementation. The
efficiency issues should be considered in the implementation phase of database design.
summary
• Models have been used by people for a long time, for example, by architects, scientists and
engineers.
• • There are many benefits of modelling before building including focussing on the essentials,
product or
• process improvement and exploring alternatives.
• • Models can be of three different types, viz., descriptive, prescriptive or representative.
• • Database modelling has at least two phases. The first phase involves building an enterprise
conceptual
• model. In the second phase, the conceptual model is mapped to the database model to be
used.
• • A simple approach of database modeling is called the Entity-Relationship modeling (ERM).
• • ERM involves identifying entities (like a person, a player or a book), relationships (like batting,
• marriage) and attributes (like age, address).
• Relationships may be unary (e.g., employee and supervisor), binary (like employee and
the company)
• or ternary (like employee, project, and department).
• • Binary relationships may be 1-1, 1-m or m-n.
• • Attributes may be of several types including simple or composite, single-valued or
multivalued, stored
• or derived.
• • An E-R model may be represented as Chen’s E-R diagram or as Crow’s Foot diagram.
• • Different notations are used for both types of diagrams. In the E-R diagram a
rectangle represents
• an entity and a diamond a relationship. In the Crow’s Foot notation, lines joining
entities represent
• relationships.
Review questions (pag91-)
• 1. What is an entity?
• 2. What is a relationship?
• 3. Name three entities that you know should be part of any university database.
• 4. Name the primary key for each of the entities.
• 5. Name a superkey of each of the three entities.
• 6. Name three attributes of each entity you have identified.
• 7. Identify any relationships that exist between the three entities you have identified.
• 8. Name the primary key of each of the relationships.
Assignment 2: due date: next
session
Topic: Country/Rivers/Deserts/Mountains/Animals
A database of countries, their rivers, deserts, mountains and animals is to be developed.
We want to store a variety of information about the countries depending on availability
of information, e.g., name, population, leader’s name, number of newspapers per 1000
people, amount of alcohol consumed per person, energy consumed per person,
pollutants generated per person, etc. For rivers, we would want to store information like
name, country or countries it passes through, source of the river, destination, how long,
etc. For mountains, we would want to store information like name, height, country, part
of which mountain range, etc. For animals, we need to store information like name, type
(mammal, bird, etc.), found in which countries, and some of their characteristics.
QN: 1. Design an E-R model for this problem.
2. Design a relational database using mySQL workbench
DESIGN A RELATIONAL
DATABASE
• Requirements
• Knowledge on concepts of relational database
• E-R diagram
• Software eg. MySQL workbench

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