Documente Academic
Documente Profesional
Documente Cultură
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
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
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
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.