Visual Paradigm Desktop VP Online

Comprehensive Guide to UML Use Case Diagrams, Class Diagrams, and ERDs

Introduction

Understanding the relationships between UML (Unified Modeling Language) diagrams and Entity-Relationship Diagrams (ERDs) is crucial for effective software design. This guide explores these three essential modeling tools, their purposes, relationships, and optimal sequencing in the development lifecycle.

UML & ERD Modeling


1. What Are These Diagrams?

UML Use Case Diagram

A use case diagram is a behavioral diagram that captures the functional requirements of a system from the user's perspective. It shows:

  • Actors: Users or external systems interacting with the system

  • Use Cases: Specific functionalities or goals the system provides

  • Relationships: Associations between actors and use cases, including includes, extends, and generalizations

Purpose: To define what the system should do without specifying how.

Key Elements:

  • Actors (stick figures)

  • Use cases (ovals)

  • System boundary (rectangle)

  • Relationships (lines with stereotypes like <>, <>)

UML Class Diagram

A class diagram is a structural diagram that represents the static structure of a system. It shows:

  • Classes: Blueprints for objects with attributes and methods

  • Relationships: Associations, aggregations, compositions, inheritances

  • Multiplicity: How many instances relate to each other

  • Visibility: Public, private, protected members

Purpose: To define how the system is structured at the code level.

Key Elements:

  • Classes (rectangles with name, attributes, operations)

  • Interfaces

  • Relationships (association, aggregation, composition, inheritance, dependency)

  • Multiplicity constraints

Entity-Relationship Diagram (ERD)

An ERD is a data modeling diagram that represents the logical structure of a database. It shows:

  • Entities: Objects or concepts that store data (tables)

  • Attributes: Properties of entities (columns)

  • Relationships: How entities connect to each other

  • Cardinality: One-to-one, one-to-many, many-to-many relationships

Purpose: To define how data is stored and related in the database.

Key Elements:

  • Entities (rectangles)

  • Attributes (ovals or listed within entities)

  • Primary keys (underlined)

  • Foreign keys

  • Relationships (diamonds or lines with cardinality notation)


2. How Are They Related?

These three diagrams represent different perspectives of the same system:

Use Case  / Class Diagram / ERD Relationship

Key Relationships:

  1. Use Case → Class Diagram: Each use case may involve multiple classes collaborating to fulfill the functionality. Classes are identified by analyzing the nouns in use case descriptions.

  2. Class Diagram → ERD: Persistent classes (those that need to be stored) map to entities in the ERD. Class attributes become entity attributes, and class relationships inform database relationships.

  3. Use Case → ERD: Use cases determine what data needs to be captured and persisted, influencing which entities and relationships are necessary.

  4. Bidirectional Influence: Changes in one diagram often require updates in others. For example, adding a new use case might require new classes and new database tables.


3. Recommended Order and Flow

Waterful Approach vs Agile Approach -> Use Case vs Class Diagram vs ERD: how they are related

Traditional Waterfall Approach:

Step 1: Requirements Gathering
    ↓
Step 2: Create Use Case Diagrams (System Scope)
    ↓
Step 3: Develop Class Diagrams (Initial Design)
    ↓
Step 4: Design ERD (Database Schema)
    ↓
Step 5: Implementation
    ↓
Step 6: Testing & Deployment

Agile/Iterative Approach:

Sprint 0: High-level Use Cases + Initial Class Diagram + Core ERD
    ↓
Sprint 1-N: Incremental refinement of all three diagrams per feature/use case

4. Critical Question: Scope and Granularity

Should a Class Diagram Cover a Single Use Case or the Entire System?

Answer: Both approaches exist, but they serve different purposes.

Option A: System-Wide Class Diagram

Advantages:

  • Provides complete architectural overview

  • Shows all relationships between classes

  • Helps identify design patterns and potential coupling issues

  • Essential for understanding the full domain model

Disadvantages:

  • Can become extremely complex for large systems

  • Difficult to maintain as the system grows

  • May overwhelm stakeholders

Best For:

  • Small to medium-sized systems

  • Architecture documentation

  • Onboarding new team members

  • Final design review

Option B: Use Case-Specific Class Diagrams

Advantages:

  • Focused and manageable

  • Easier to understand and validate

  • Aligns with agile incremental development

  • Reduces cognitive load

Disadvantages:

  • May miss cross-cutting concerns

  • Requires integration effort later

  • Potential for inconsistent design across use cases

Best For:

  • Large, complex systems

  • Agile development teams

  • Detailed design discussions for specific features

  • Early-stage exploration

Recommended Hybrid Approach:

  1. Create a high-level system-wide class diagram showing major components and their relationships

  2. Create detailed use case-specific class diagrams for complex or critical use cases

  3. Maintain both, ensuring consistency between them

System-Wide Class Diagram (High-Level)
├── Package: User Management
├── Package: Order Processing
├── Package: Inventory
└── Package: Reporting

Use Case-Specific Class Diagrams (Detailed)
├── "Place Order" Use Case → Detailed classes involved
├── "Process Payment" Use Case → Detailed classes involved
└── "Generate Report" Use Case → Detailed classes involved

Should an ERD Cover the Entire System or Be Built Incrementally?

Answer: Similar to class diagrams, a hybrid approach works best.

Core ERD First, Then Extend:

  1. Identify core entities that are fundamental to the system (e.g., User, Product, Order)

  2. Design the initial ERD with these core entities and their relationships

  3. Incrementally add entities as new use cases are implemented

  4. Refine relationships as understanding deepens

Why Not Completely Incremental?

  • Database schema changes can be expensive and risky

  • Early identification of key relationships prevents costly refactoring

  • Some entities are referenced across multiple use cases

  • Normalization decisions affect the entire database

Practical Strategy:

Phase 1: Core Domain ERD
├── Identify 5-10 critical entities
├── Define primary relationships
└── Establish normalization rules

Phase 2-N: Incremental Extensions
├── Add new entities for each use case
├── Refine existing relationships if needed
└── Maintain backward compatibility

5. Incremental Development Strategy

Recommended Workflow for Agile Teams:

Sprint 0: Foundation

  1. Create high-level use case diagram covering the entire system scope

  2. Identify major actors and epics

  3. Draft initial class diagram with core domain classes

  4. Design core ERD with fundamental entities

Each Subsequent Sprint:

For each use case/feature being implemented:

  1. Refine relevant use cases (add detail, clarify flows)

  2. Create/update use case-specific class diagrams showing classes involved

  3. Update system-wide class diagram with new classes and relationships

  4. Extend ERD with new entities/attributes if persistent data is needed

  5. Implement code and database migrations

  6. Validate consistency across all diagrams

Example: E-Commerce System

Sprint 0: Foundation
├── Use Cases: Browse Products, Place Order, Manage Account
├── Core Classes: Product, User, Order, Cart
└── Core ERD: products, users, orders, order_items tables

Sprint 1: Implement "Browse Products"
├── Refine "Browse Products" use case
├── Add Category, Review classes
├── Update class diagram
├── Add categories, reviews tables to ERD
└── Implement and test

Sprint 2: Implement "Place Order"
├── Refine "Place Order" use case
├── Add Payment, ShippingAddress classes
├── Update class diagram
├── Add payments, addresses tables to ERD
└── Implement and test

Sprint 3: Implement "Manage Account"
├── Refine "Manage Account" use case
├── Add Wishlist, Notification classes
├── Update class diagram
├── Add wishlists, notifications tables to ERD
└── Implement and test

6. Best Practices

For Use Case Diagrams:

  1. Keep it simple: Focus on major functionality, not every detail

  2. Use clear actor names: Represent roles, not individuals

  3. Avoid over-complication: Limit <> and <> relationships

  4. Validate with stakeholders: Ensure use cases reflect real user needs

  5. Write use case descriptions: Complement diagrams with detailed narratives

For Class Diagrams:

  1. Start with domain-driven design: Identify entities from the problem domain

  2. Apply SOLID principles: Ensure proper separation of concerns

  3. Show only relevant details: Don't clutter with every method

  4. Use consistent naming: Follow language/framework conventions

  5. Review for cohesion and coupling: Minimize dependencies

For ERDs:

  1. Normalize appropriately: Balance between 3NF and performance

  2. Define clear primary and foreign keys: Ensure referential integrity

  3. Consider indexing strategy: Plan for query performance

  4. Document business rules: Include constraints and validations

  5. Plan for scalability: Anticipate growth in data volume

For Integration:

  1. Maintain traceability: Link use cases to classes to entities

  2. Use modeling tools: Tools like Enterprise Architect, Lucidchart, or draw.io help maintain consistency

  3. Regular synchronization: Update all diagrams when changes occur

  4. Version control: Treat diagrams as code; store in repository

  5. Team collaboration: Review diagrams together to ensure shared understanding


7. Common Pitfalls to Avoid

Pitfall Solution
Creating diagrams in isolation Ensure cross-referencing between use cases, classes, and entities
Over-engineering early Start simple; refine incrementally
Ignoring non-functional requirements Consider performance, security, and scalability in design
Not updating diagrams Treat diagrams as living documents
Too much detail too soon Focus on high-level design first
Skipping validation Review with stakeholders and technical team
Assuming one-size-fits-all Adapt approach to project size and complexity

8. Tool Recommendations

  • Enterprise Architect: Comprehensive UML and ERD support

  • Lucidchart: Web-based, collaborative diagramming

  • draw.io / diagrams.net: Free, open-source option

  • Visual Paradigm: Strong UML and database modeling

  • PlantUML: Code-based diagram generation

  • MySQL Workbench / pgAdmin: Database-specific ERD tools

  • Miro / Mural: Collaborative whiteboarding for early-stage diagrams


9. Summary

Key Takeaways:

  1. Use Case Diagrams define what the system does from the user's perspective

  2. Class Diagrams define how the system is structured at the object level

  3. ERDs define how data is stored and related in the database

  4. They are interconnected: Changes in one affect the others

  5. Start with system-wide views, then drill down incrementally

  6. Use a hybrid approach: High-level system diagrams + detailed use case-specific diagrams

  7. Build incrementally but maintain architectural coherence

  8. Keep diagrams synchronized and treat them as living documentation

  9. Adapt to your methodology: Waterfall vs. Agile requires different approaches

  10. Validate continuously with stakeholders and the development team

Final Recommendation:

For most projects, especially in agile environments:

  1. Begin with a high-level use case diagram covering the entire system

  2. Create an initial class diagram identifying core domain classes

  3. Design a core ERD with fundamental entities

  4. For each sprint/use case:

    • Refine relevant use cases

    • Create detailed class diagrams for that use case

    • Update the system-wide class diagram

    • Extend the ERD as needed

    • Implement and validate

  5. Continuously maintain consistency across all diagrams

This approach balances comprehensive architectural vision with agile incremental delivery, ensuring both strategic alignment and tactical flexibility.

Turn every software project into a successful one.

We use cookies to offer you a better experience. By visiting our website, you agree to the use of cookies as described in our Cookie Policy.

OK