| Lesson 2 | The Entity-Relationship (ER) Diagram |
| Objective | Explain the role and function of an ER diagram in data modeling. |
An Entity-Relationship Diagram (ERD) is a core tool in data modeling. It provides a visual representation of entities, attributes, and relationships, and it plays a central role in designing and understanding relational databases. ERDs are used not only in initial design, but also as documentation, communication aids, and integration tools.
An ER diagram is a conceptual model that captures business rules in a concise, structured format. Its objectives include:
Most modern CASE tools support ERDs in similar ways. Regardless of the style or notation, the core function remains the same: visualize and enforce consistency in data modeling.
Each simple attribute in an entity type is associated with a value set (or domain), which specifies the permissible values. For example, in Figure 7-2, the Age attribute of EMPLOYEE might be restricted to integers between 16 and 70, while Name values may be alphabetic strings separated by spaces.
Value sets are usually expressed using standard programming language types (integer, string, Boolean, float, enumerated types, subranges) or database-specific types such as date and time. While not shown on ER diagrams, they are vital in defining the validity of data.
Mathematically, an attribute A of entity set E with value set V can be represented as a function from E to the power set [2] of V:
A : E → P(V)
For an entity e, the value of A(e) can represent single-valued or multivalued attributes, including NULLs (the empty set). For composite attributes [3], the value set is defined as a power set of the Cartesian product of its component attributes:
V = P(P(V1) × P(V2) × ... × P(Vn))
Although these sets describe the full potential range of attribute values, the actual database will only hold values that correspond to the current state of the modeled domain (the "miniworld").
The next lesson introduces three well-known examples of ER diagram applications.