ERD Lecture
ERD Lecture
ERD Lecture
What is ERD?
What is an ER diagram (ERD)?
When to draw ER Diagrams?
ERD notations guide
Conceptual, Logical and Physical data models
How to draw an ER diagram?
Data model examples
Using ERD with DFD
Using ERD with BPMN
Choosing an ERD tool
Related Links
Database is absolutely an integral part of software systems. To fully utilize ER Diagram in
database engineering guarantees you to produce high-quality database design to use in database
creation, management, and maintenance. An ER model also provides a means for
communication.
Today we're going to walk you through everything you need to know about ER Diagramming.
By reading this ERD guide, you will get the essential knowledge and skills about ER Diagrams
and database design. You will learn things like what is ERD, why ERD, ERD notations, how to
draw ERD, etc. along with a bunch of ERD examples.
Entity
An ERD entity is a definable thing or concept within a system, such as a person/role (e.g.
Student), object (e.g. Invoice), concept (e.g. Profile) or event (e.g. Transaction) (note: In ERD,
the term "entity" is often used instead of "table", but they are the same). When determining
entities, think of them as nouns. In ER models, an entity is shown as a rounded rectangle, with
its name on top and its attributes listed in the body of the entity shape. The ERD example
below shows an example of an ER entity.
Entity Attributes
Also known as a column, an attribute is a property or characteristic of the entity that holds
it.
An attribute has a name that describes the property and a type that describes the kind of
attribute it is, such as varchar for a string, and int for integer. When an ERD is drawn for
physical database development, it is important to ensure the use of types that are supported by
the target RDBMS.
The ER diagram example below shows an entity with some attributes in it.
Primary Key
Also known as PK, a primary key is a special kind of entity attribute that uniquely defines a
record in a database table. In other words, there must not be two (or more) records that share
the same value for the primary key attribute. The ERD example below shows an entity
'Product' with a primary key attribute 'ID', and a preview of table records in the database. The
third record is invalid because the value of ID 'PDT-0002' is already used by another record.
Foreign Key
Also known as FK, a foreign key is a reference to a primary key in a table . It is used to
identify the relationships between entities . Note that foreign keys need not be unique. Multiple
records can share the same values. The ER Diagram example below shows an entity with some
columns, among which a foreign key is used in referencing another entity.
Relationship
A relationship between two entities signifies that the two entities are associated with each
other somehow. For example, a student might enroll in a course. The entity Student is
therefore related to Course, and a relationship is presented as a connector connecting between
them.
Cardinality
Cardinality defines the possible number of occurrences in one entity which is associated
with the number of occurrences in another. For example, ONE team has MANY players.
When present in an ERD, the entity Team and Player are inter-connected with a one-to-many
relationship.
In an ER diagram, cardinality is represented as a crow's foot at the connector's ends. The three
common cardinal relationships are one-to-one, one-to-many, and many-to-many.
One-to-One cardinality example
A many-to-many relationship refers to the relationship between two entities X and Y in which
X may be linked to many instances of Y and vice versa. The figure below shows an example of
a many-to-many relationship. Note that a many-to-many relationship is split into a pair of
one-to-many relationships in a physical ERD. You will know what a physical ERD is in the
next section.
NOTE: Conceptual ERD supports the use of generalization in modeling the 'a kind of'
relationship between two entities, for instance, Triangle, is a kind of Shape. The usage is like
generalization in UML. Notice that only conceptual ERD supports generalization.
Since a physical ER Diagram provides a blueprint of an actual database, the entities in such an
ERD are aligned with datastores in a DFD. You can draw ERD as a complement to DFD by
representing the structure of information that flows within a system, or, on the contrary, to
draw DFD in complementing an ERD by showing how the data will be utilized by the system
in runtime.
Using ERD with BPMN Business Process Diagram (BPD)
In business process mapping, BPMN Business Process Diagram (BPD) can be drawn to
visualize business workflows. In a Business Process Diagram, there is a symbol called Data
Object, which represents the data input into / output from process activities.
Since a conceptual and logical data model provides a high-level view of business objects
within a system, the entities in such ERDs are aligned with data objects in BPD. You can draw
ERD as a complement to BPD by representing the structure of data objects needed by a
business workflow, or, on the contrary, to draw BPD in complementing an ERD by showing
how the data will be utilized throughout a business process.