Sunteți pe pagina 1din 40

ENTITY RELATIONSHIP

DIAGRAM

DONE BY
LLOYD MUYA
JORAM ZENGEYA
TAMIA MUNGWIRA
CONTENTS
DATA MODEL
HISTORY OF AN ERD
WHAT IS ERD?
WHY ERD?
USES
SYMBOLS
COMPONENTS IN ERD
RULES
QUESTION
OOP AND STRUCTURED PROGRAMMING
DATA MODELLING

Data modelling is a technique to document a software system using diagrams and


symbols. It is used to represent communication of data.
The highest level of abstraction for the data model is called the Entity Relationship
Diagram (ERD). It is a graphical representation of data requirements for a database.
When we talk about entities in ERD, very often we are referring to business objects
such as people/role (e.g. Student), tangible business objects (e.g. Product), intangible
business objects (e.g. Log), etc. "Relationship" is about how these entities relate to
each other within the system.
THE HISTORY OF ENTITY RELATIONSHIP
DIAGRAMS
Peter Chen developed ERDs in 1976.Since then Charles Bachman and James Martin have
added some slight refinements to the basic ERD principles .Chen’s paper especially
since it focused on the term’s ‘entities’’ and ‘relationship’’ is generally considered to be the
beginning of the Data Modeling practice as it is known today.
Bachman Diagrams, a form of Modeling also deserve some mention. Charles Bachman’s
seminal late 60s article in DATABASE put forth the concept of database ‘entities’’ and one of
the first data structure diagrams later to be known as a Bachman Diagram. Bachman wasn’t
also in contributing to the dawn of the Data Modeling practice. In the early 1970s a UK
based systems engineer for IBM J Barrie Leigh developed nascent ER-Diagram for annuity
system he worked on for the Royal Insurance. Their work still echoes today whenever a DBA
place an entity on a model or draws a line denoting a one to many relationships.
WHAT IS AN ENTITY RELATIONSHIP DIAGRAM
(ERD)?
An entity relationship diagram (ERD) shows the relationships of entity sets stored in a
database. An entity in this context is an object, a component of data. An entity set is
a collection of similar entities. These entities can have attributes that define its
properties.
By defining the entities, their attributes, and showing the relationships between them,
an ER diagram illustrates the logical structure of databases.
ER diagrams are used to sketch out the design of a database
WHY ERDS?

Entity Relationship Diagrams are a major data modelling tool and will help organize
the data in your project into entities and define the relationships between the entities.
This process has proved to enable the analyst to produce a good database structure
so that the data can be stored and retrieved in a most efficient manner. By using a
graphical format, it may help communication about the design between the designer
and the user and the designer and the people who will implement it.
The main value of carefully constructing an ERD is that it can readily be converted
into a database structure.
USES OF ENTITY RELATIONSHIP DIAGRAMS
Database design: ER diagrams are used to model and design relational databases, in terms of
logic and business rules (in a logical data model) and in terms of the specific technology to be
implemented (in a physical data model.) In software engineering, an ER diagram is often an
initial step in determining requirements for an information systems project. It’s also later used to
model a particular database or databases. A relational database has an equivalent relational
table and can potentially be expressed that way as needed.
Database troubleshooting: ER diagrams are used to analyze existing databases to find and
resolve problems in logic or deployment. Drawing the diagram should reveal where it’s going
wrong.
Business information systems: The diagrams are used to design or analyze relational
databases used in business processes. Any business process that uses fielded data involving
entities, actions and interplay can potentially benefit from a relational database. It can
streamline processes, uncover information more easily and improve results.
Business process re-engineering (BPR): ER diagrams help in
analyzing databases used in business process re-engineering and
in modeling a new database setup.
Education: Databases are today’s method of storing relational
information for educational purposes and later retrieval, so ER
Diagrams can be valuable in planning those data structures.
Research: Since so much research focuses on structured data, ER
diagrams can play a key role in setting up useful databases to
analyze the data.
ER DIAGRAM SYMBOLS

In an ER diagram, symbols are commonly used to represent the types of information.


Most diagrams will use the following:
Boxes represent entities.
Diamonds represent relationships
Circles (ovals) represent attributes.
COMPONENTS IN ERD
There are three components in ERD.
Entities: Number of tables you need for your database.
Attributes: Information such as property, facts you need to
describe each table.
Relationships: How tables are linked together.
ENTITY

Entities are the basic objects of ERDs. These are the tables of your database. Entity
are nouns and the types usually fall into five classes. Concepts, location, roles, events
or things. For example: students, courses, books, campus, employees, payment,
projects. Specific example of an entity is called an instance. Each instance becomes a
record table. Entities are represented by rectangles
A definable thing—such as a person, object, concept or event—that can have data
stored about it. Think of entities as nouns. Examples: a customer, student, car or
product. Typically shown as a rectangle.

or
An entity set is a collection of similar types of entities. An entity set may contain
entities with attribute sharing similar values. For example, a Students set may
contain all the students of a school; likewise, a Teachers set may contain all the
teachers of a school from all faculties. Entity sets need not be disjoint.
Entities are represented by means of rectangles. Rectangles are named with the
entity set they represent
EXAMPLE OF ENTITY
RELATIONSHIPS
Relationships are the associations between the entities. Verbs
often describe relationships between entities. For example, an
employee works at a department, a student enrols in a course.
Here, Works at and Enrols are called relationships We will use
Crow's Foot Symbols to represent the relationships. Three types
of relationships are discussed in this lab. If you read or hear
cardinality ratios, it also refers to types of relationships.
Relationships are represented by diamond-shaped box. Name
of the relationship is written inside the diamond-box. All the
entities (rectangles) participating in a relationship, are
connected to it by a line.
RELATIONSHIPS REPRESENTED BY A DIAMOND
ATTRIBUTES
Attributes are facts or description of entities. They are also often nouns and become
the columns of the table. For example, for entity student, the attributes can be first
name, last name, email, address and phone numbers.
ATTRIBUTE CATEGORIES:
Attributes are categorized as
simple, composite, derived, as well as single-value or multi-value.
Simple: Means the attribute value is atomic and can’t be further divided, such as a
phone number.
Composite: Sub-attributes spring from an attribute.
Derived: Attributed is calculated or otherwise derived from another attribute, such as
age from a birthdate.
CARDINALITY
Defines the number of occurrences of one entity for a single occurrence of the related entity.
E.g. an employee may process many payments but might not process any payments
depending on the nature of her job.
1. One-to-One
One instance of an entity (A) is associated with one other instance of another entity
(B). For example, in a database of employees, each employee name (A) is associated
with only one social security number (B)
CARDINALITY AND
ORDINALITY
•Cardinality refers to the maximum number of times an
instance in one entity can relate to instances of another
entity.
• Ordinality, on the other hand, is the minimum number
of times an instance in one entity can be associated with
an instance in the related entity.
•Cardinality and ordinality are shown by the styling of a
line and its endpoint, according to the chosen notation
style.
LIMITATIONS OF ER DIAGRAMS AND MODELS

Only for relational data: Understand that the purpose is to show relationships. ER
diagrams show only that relational structure.
Not for unstructured data: Unless the data is cleanly delineated into different fields,
rows or columns, ER diagrams are probably of limited use. The same is true of semi-
structured data, because only some of the data will be useful.
Difficulty integrating with an existing database: Using ER Models to integrate with
an existing database can be a challenge because of the different architectures.
HOW TO DRAW A BASIC ER DIAGRAM/ RULES

Purpose and scope: Define the purpose and scope of what you’re analysing or
modelling.
Entities: Identify the entities that are involved. When you’re ready, start drawing
them in rectangles (or your system’s choice of shape) and labelling them as nouns.
Relationships: Determine how the entities are all related. Draw lines between them
to signify the relationships and label them. Some entities may not be related, and
that’s fine. In different notation systems, the relationship could be labelled in a
diamond, another rectangle or directly on top of the connecting line.
Attributes: Layer in more detail by adding key attributes of entities. Attributes are
often shown as ovals.
Cardinality: Show whether the relationship is 1-1, 1-many or many-to-many.
QUESTION
A local hospital consists of many wards each of which is assigned many patients.
Each patient is assigned to one doctor who has an overall responsibility for the
patient in his or her care. Other doctors are assigned on advisory basis. Each patient
is prescribed drugs by the doctor responsible for that patient. Each nurse is assigned
to ward and nurses (care giver) all patients in that ward. Each patient is assigned
one nurse and one of the doctor is attached to each ward as an overall advisor.
DRAW ANY ENTITY RELATIONSHIP AND DENOTE THE RELATIONSHIPS,
CARDINALITY AND TYPES OF ATTRIBUTES ATTACHED TO EACH ENTITY.
HOSP.
ADDRESS HOSP. NAME
PRICE DRUG QUANTITY
1
CONSISTS
HOSPITAL N
HOSP. PHONE
NUMBER

N
CAPACITY NAME TYPE

PRESCRIBE
SPECIALITY D

1
1 IS 1
NURSE ASSIGNE
D
WARD ASSIG
NED
N 1

ROOM PATIENTS’
GENDER N

ID
NAME
ASSIGNED

PATIENT
NAME
1 SPECIALITY N
GENDER

ROOM 1 ASSIG
NED
DOCTOR SICKNESS
COMPRISON BETWEEN OOP AND
SRUCTURED PROGRAMMING
OOP STRUCTURED PROGRAMMING
The main difference between But in unstructured programming
structured and unstructured language, the whole program must be
programming language is that a written in single continuous way; there is
structured programming language no stop or broken block
allows a programmer to dividing the
whole program into smaller units or
modules
Structured Programming language is a . But in unstructured Programming
subset of Procedural Programming language no subset exists
language
while Unstructured Programming
Structured Programming language language produces hardly readable
produces readable code code “spaghetti”.
Structured programming follows top- .while Object oriented programming
down approach follows bottom-up approach
In Object Oriented Programming,
Programs are divided into small entities
Structured Programming, Programs are called objects.
divided into small self
contained functions while unstructured Programming
language offers freedom to program as
Structured Programming language has they want.
some limitations
ADVANTAGES OF OOP

The programmes written with OOP are really easy to understand.


Since everything is treated as objects, so we can model a real-world concept using
OOP.
Objects can also be reused within an across applications. The reuse of software
also lowers the cost of development. More effort is put into the object-oriented
analysis and design, which lowers the overall cost of development.
Since the parallel development of classes is possible in OOP concept, It results in the
quick development of the complete programmes.
Programmes written in OOP technique are marginally easier to test, manage as well
as maintain.
It is a secured development technique since data is hidden and can’t be accessed by
external functions.
Simplicity: Software objects model real world objects, so the complexity is reduced
and the program structure is very clear
It makes software easier to maintain. Since the design is modular, part of the system
can be updated in case of issues without a need to make large-scale changes
Reuse also enables faster development. Object-oriented programming languages
come with rich libraries of objects, and code developed during projects is also
reusable in future projects.
It provides a good framework for code libraries where the supplied software
components can be easily adapted and modified by the programmer. This
Modularity: Each object forms a separate entity whose internal workings are
decoupled from other parts of the system
Modifiability: It is easy to make minor changes in the data representation or the
procedures in an OO program. Changes inside a class do not affect any other part
of a program, since the only public interface that the external world has to a class is
through the use of methods.
Extensibility: Adding new features or responding to changing operating environments
can be solved by introducing a few new objects and modifying some
. Improved software maintainability: For the reasons mentioned above, objectoriented
software is also easier to maintain. Since the design is modular, part of the system
can be updated in case of issues without a need to make large-scale changes.
DISADVANTAGES OF OBJECT-ORIENTED
Some of the programming include:
1. Steep learning curve: The thought process involved in object-oriented programming
may not be natural for some people, and it can take time to get used to it. It is
complex to create programs based on interaction of objects. Some of the key
programming techniques, such as inheritance and polymorphism, can be challenging
to comprehend initially.
2. Larger program size: Object-oriented programs typically involve more lines of
code than procedural programs
DISADVANTAGES OF OOP
Sometimes, the relation among the classes become artificial in nature.
Designing a program in OOP concept is a little bit tricky.
The programmer should have a proper planning before designing a program
using OOP approach.
Since everything is treated as objects in OOP, the programmers need proper skill such
as design skills, programming skills, thinking in terms of objects etc.
The size of programmes developed with OOP is larger than the procedural
approach.
Since larger in size, that means more instruction to be executed, which results in the
slower execution of programmes.
Steep learning curve: The thought process involved in object-oriented programming
may not be natural for some people, and it can take time to get used to it. It is
complex to create programs based on interaction of objects. Some of the key
programming techniques, such as inheritance and polymorphism, can be challenging
to comprehend initially
Larger program size: Object-oriented programs typically involve more lines of code
than procedural programs.
Slower programs: Object-oriented programs are typically slower than
procedurebased programs, as they typically require more instructions to be executed.
while unstructured Programming language offers freedom to program as they want.

Structured Programming language is easy to modify and debug, while unstructured


Programming language is very difficult to modify and debug.

Examples of Structured Programming language are C, C+, C++, C#, Java, PERL,
Ruby, PHP, ALGOL, Pascal, PL/I and Ada; and example of unstructured Programming
language are BASIC (early version), JO
STRUCTURED PROGRAMMING
structured programming: A technique for organizing and coding computer programs
in which a hierarchy of modules is used, each having a single entry and a single exit
point, and in which control is passed downward through the structure without
unconditional branches to higher levels of the structure. Three types of control flow
are used: sequential, test, and iteration.
ADVANTAGES OF STRUCTURED
PROGRAMMING
Complexity can be reduced using the concepts of divide and conquer.
Logical structures ensure clear flow of control.
Increase in productivity by allowing multiple programmers to work on different
parts of the project independently at the same time.
Modules can be re-used many times
Easier to update/fix the program by replacing individual modules rather than
larger amount of code.
Ability to either eliminate or at least reduce the necessity of employing GOTO
statement.
DISADVANTAGES

A high level language has to be translated into the machine language by translator and thus
a price in computer time is paid
Lack of encapsulation
Same code repetition
Lack of information hiding.
Data type are proceeds in many functions in a structured program. When changes occur in
those data types, the corresponding change must be made to every location that acts on those
data types within the program. This is really a very time consuming task if the program is very
large
Change of even a single data structure in a program necessitates changes at many places
throughout it, and hence the changes becomes very difficult to track even in a reasonable
sized program.
Not much reusability of code.
Can support the software development projects easily up to a certain level of
complexity. If complexity of the project goes beyond a limit, it becomes difficult to
manage.

S-ar putea să vă placă și