Understanding Data Modeling

Njeri GitomeNjeri Gitome
7 min read

Data essentially refers to raw facts, figures and details that can be collected, measured, analyzed, stored and used for various purposes such as decision making.

In the current digital age, we are constantly generating massive volumes of data , however, for that data to be meaningful, it must be handled in a effective way. This is where data models come in handy.

What is a Data Model?

A data model is a visual representation of data and its relationships. It provides a standardized framework for representing real-world entities, their properties, and the relationships between them.

Data models are used to create databases and data warehouses, manage data for analytical processing, and develop applications that enable users to access and utilize information effectively.

Importance of Data Modeling

Data modeling is the process of creating a conceptual representation of data objects and their relationship to one another. Data modeling is crucial for managing data effectively. Here is how:

  1. Ensures data integrity - proper data modelling improves the quality of data by preventing redundancy and aids in the elimination of data anomalies.

  2. Facilitates effective data retrieval - it makes it easier to query and analyze data.

  3. Supports scalability - data modelling makes scaling easier by creating a structure that is efficient, flexible and modular that can manage growing data volumes, user loads, and complexity without compromising on performance.

  4. Enhances communication - the visual representation of data and its relationships provides a common language that can be understood by both technical and non-technical stake holders. This enhances communication and collaboration across different teams.

Types of Data Models

Data models are classified into three types based on the level of abstraction. These are: conceptual data models, logical data models, and physical data models.

  • Conceptual Data Model

A conceptual model is a high level visual representation of database concepts and the relationships between them.

Zooming out of the nitty gritty details and looking at the bigger picture helps one to see the related concepts in the area of focus. This serves as a great communication tool between stakeholders and technical teams.

Conceptual Data Model Example

A case example of a Hospital Management System. The conceptual data model will describe the key entities, attributes and relationships within the system. Here is a visual representation of the same:

Key components of a Conceptual Data Model:

  1. Entities : these are the major objects or concepts within the area of focus. In our case example above the main Entities are 'Doctor', 'Patient' and 'Appointment'.

  2. Attributes: they describe the characteristics of an entity for example the entity may have the attribute 'Patient ID'.

  3. Relationships: this illustrates how the entities relate to one another. For example 'A Doctor treats a Patient'.

  4. Cardinality: this defines the nature of the relationship between the entities such as one-to-one, many-to-many etc. For example 'One Doctor can Many Patients' (thus a one-to-many relationship)

  • Logical Data Model

The next data model - Logical Data Model - defines the structure of the data entities and the relationships among them. The logical data model takes the elements of the conceptual data model a step further by adding more details to them.

A Logical Data Model serves to define how a system will be implemented without it being tied to a specific database technology. The logical model should reflect the business' understanding of the data on a detailed level. Therefore, logical data modeling brings together two important basics of application development:

  1. Business requirements understanding.

  2. Quality data structure.

Logical Data Model Example

Continuing on the Hospital management System, the logical data model could clarify data structures and associations with the following:

Key components of a Logical Data Model:

  1. Entities : these are the major objects or concepts within the area of focus. In our case example above the main Entities are 'Doctor', 'Patient' and 'Appointment'.

  2. Attributes:

    • Attributes of the Doctor Entity : Doctor ID, Name, Specialization, Gender, Phone No, Email, Department, Hire Date

    • Attributes of the Patient Entity: Patient ID, Name, Date Of Birth, Gender, Age, Phone No, Email

    • Attributes of the Appointment Entity: Appointment ID, Appointment Date, Appointment Time, Patient ID, Doctor ID.

  3. Keys: identify unique records within an entity.

    • Primary keys: A unique identifier for each record within an entity.

      The Doctor ID is the primary key of the Doctor entity, Patient ID is the primary key of the Patient entity and the Appointment ID is the primary key of the Appointment entity.

    • Foreign keys: A field in one table that references the primary key in another table to establish a relationship.

      The Patient ID and Doctor ID present in the Appointment Entity are foreign keys.

  4. Relationships and cardinality :

    • Doctor <->Appointment : One-to-many relationship (one doctor can have many appointments booked to them, but an appointment must reference one doctor)

      'Doctor ID' in Appointment is a foreign key referencing 'Doctor ID' in Doctor entity.

    • Patient <-> Appointment: One-to-many relationship (one patient can book many appointments but an appointment must reference one patient)

      'Patient ID' in Appointment is a foreign key referencing 'Patient ID' in the Patient entity

This logical model further refines the conceptual model by adding specific attributes and defining the relationships between the entities with keys. It serves as a blueprint of creating a Physical Data Model.

  • Physical Data Model

In the final phase, the logical data model is transformed into the physical data model by defining data types and adding technical attributes like constraints and indices. The physical data model represents the actual implementation of the data model in a specific Database Management System (DBMS).

Physical data modeling is technology-specific, requiring a thorough understanding of indexing, compression, and the performance characteristics of data types and tables. Additionally, it's essential to know how data is or should be distributed within your chosen analytics database technology.

Physical Data Model Example

At this point in our Hospital Management System example, we would like to see the data flow into right places, adhering to our defined data structures on the conceptual and logical data modeling levels.

Physical data model must be tailored to a particular database system. Here is what it would look like for a relational database:

Key components of a Physical Data Model:

  1. Primary keys and foreign keys: Defined to ensure data integrity and enforce relationships between tables.

  2. Indices: Created on columns frequently used in queries for faster data retrieval. Usually, indices are automatically created based on the primary key.

  3. Data types: Use of specific data types like INTEGER, VARCHAR, DATE, etc., based on the database system's requirements and best practices for storing different types of data.

  4. Constraints: Rules applied to columns or tables to maintain data integrity and accuracy. Common constraints include:

    • NOT NULL: Ensures a column cannot have a NULL value.

    • UNIQUE: Ensures all values in a column are unique across the table.

This physical data model provides a detailed blueprint for the database implementation. It specifies the tables, their columns, data types, constraints, and indices required to create the database schema in a specific relational database, translating the logical data model into a technical representation that is ready for implementation.

Recap: conceptual vs. logical vs. physical data model

  1. Conceptual Data Model

    • It focuses on high level concepts and their relationships.

    • It represents business requirements without technical details.

    • It serves as a great communication tool between stakeholders and technical teams.

  1. Logical Data Model

    • It adds more detail to the conceptual model.

    • Defines entities, attributes, relationships, and keys.

    • It represents data elements independent of the database technology.

  2. Physical Data Model

    • It translates the logical model into technical specifications.

    • Specifies data types, constraints, and database-specific details.

    • Ready actual implementation in a specific Database Management System (DBMS).

Data Modeling Tools and Software

Several tools and software can assist in building data models:

Open Source and Free Tools

  • Lucid Chart : web-based diagrammatic application tool for collaborative data modeling.

  • Draw.io: (now known as diagrams.net) a versatile diagramming tool that can be used for various types of visual documentation.

  • MySQL Workbench: Integrated with MySQL, offering database design, administration, and development tools.

  • Oracle SQL Developer Data Modeler: a free graphical tool that enhances productivity and simplifies data modeling tasks.

Cloud Based Tools

  • Amazon AWS Glue: Data integration service with data modeling capabilities for big data workloads.

  • Google Cloud Dataflow: Cloud-based data processing service with data modeling features.

Commercial Tools

  • Erwin Data Modeler: Known for its robust features and enterprise-level capabilities.

  • IBM InfoSphere Data Architect: Part of a broader data management platform with advanced features.

  • PowerDesigner: Provides a unified modeling environment for data, process, and business modeling.

Choosing the right tool for data modeling is dependent on various factors such as project size and complexity, compatibility with target database, budget, tools that support multiple collaborators or the learning curve of a data modeling tool.

Conclusion

Investing in data modeling can aid in successfully capturing the vital and precise information about the domain one is interested.

Effective data modeling ensures data integrity, improves performance, and provides a clear understanding of data structures, resulting in better data management and utilization.

0
Subscribe to my newsletter

Read articles from Njeri Gitome directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Njeri Gitome
Njeri Gitome

Data Scientist