When your daily life regularly has databases in it, then the chances are quite high that you’ve already heard the term quite a few times, data modeling. But what is it exactly? And why should you do it?
what is data modeling?
Data modeling is often considered a necessary evil, a form of documentation, which is pushed to the end of the project, only to be ignored and forgotten, due to time or budget constraints, or both. But is that correct? Is it necessary? Is it evil? And is it only documentation, which can be made afterwards?
Let’s take a look at what Wikipedia says about Data Modeling:
“Data modeling in software engineering is the process of creating a data model for an information system by applying certain formal techniques”
Or, if we consider Data Modeling as “creating a data model“, then what is a data model exactly? Again, according to Wikipedia, the definition of a data model:
“A data model (or datamodel) is an abstract model that organizes elements of data and standardizes how they relate to one another and to the properties of real-world entities.”
This does describe a data model, or data modeling quite accurate, but doesn’t really give much more meaning to it. Is it just another document that needs to be produced? No, it is much more!
We, humans, are visual creatures, we use our eyesight to observe the world around us, and use visuals to remember things. Visual is not our only means of registering and remembering the world, but it is an important one. Words, by means of reading or hearing, is another one, but it is much harder to describe something in words, then it is to create an image.
There are many examples of this, for instance, when you read a book, you create a visual representation of what you are reading. When you see a movie based on that book, it will nearly always be different from how you imagined it. And even thousand different movies can be made from this book, but they will never come close to how you visualized the book.
If I tell you to imagine a beautiful place on earth, many people will get think of similar places, but no two people will visualize the same place in the same way. Even if I start describing the place, and tell you about the water flowing between the trees covered in colorful fall foliage, and the blue sky with the fluffy clouds, reflected in the water. The outcome of this exercise will render different results based on your experiences and more.
But, when I show you a picture of this setting , there is no (or way much less) discussion about what the scene looks like. If you add spoken or written words to this image, you can reproduce the visual of the scene as close as possible.
This is what a data model does, it is a representation of your data on different levels. Combine the visual representation of the data with the written documentation, and you have a decent start of your analysis, and a good chance to being able to recreate reality, the data flows or the database.
Types of data models
Data models come in different sizes and flavors, but there are some types that can be distinguished:
The Conceptual Data Model:
The conceptual data model describes the data and data flows on a high level, in a specific domain or area of interest. This domain can be the sales division of a company, the students in a school, fish in the sea, or even a whole enterprise.
In a conceptual data model, significant items in the domain are represented by entities or entity classes, for instance shops, points of sale, classes. Then the relations between the different entities are defined, creating a clear view of the sources of the different data and the flows and the relations of data.
Conceptual data models use non-technical names and terms, and more business related names, so that management on all levels can read and understand the model. Conceptual data models are typically created by architects.
The Logical Data Model:
The logical data model is derived from the conceptual data model, and describes and groups the data in entities and attributes, or tables and columns, or object oriented classes. It provides a clear overview of how your data is stored and grouped. Depending on the need of the data model, this can be according to different methodologies, such as the star schema for Kimbal based Data Warehouses, or a 3th Normal Form normalized schema for operational systems, or Data Vault for a data lake.
Logical data models are mostly designed using an ERD, and entity-relationship-diagram, which clearly visualizes the different data entities and their relations. Logical data models should be technology agnostic, meaning that they should be generic, and not include technical implications. When interpreting a Logical Data Model (LDM), you should not be able to derive the technical implementation on which the system will be running.
Logical Data Models are typically created by analysts, and still uses business names and terms instead of technical names, but on a more specific level.
The Physical Data Model:
The physical data model is derived from the Logical Data Model (LDM), and is further detailing the data model to the physical implementation on to storing the data, for instance in a database. This means that the physical data model (PDM) will include a granularity and clarity that allows for creating a database from it. It will contain for instance partitions, tablespaces, indexes, keys and more.
The physical data model is mostly created by a technically skilled person, and will use the technical names and terms as used in the DBMS that will be used. These names are then often subject to the technical limitations of the platform.
Why should I datamodel?
Higher quality through better understanding
Designing your way through the different levels of data models will increase your understanding of the data and how it is created and flowing. This will result in a better data model, and thus a better implementation of the database.
Reducing project cost and time
Data modeling does cost time, and thus it is often ignored or minimized to save costs. Yet, that is a wrong idea, and it should be considered an investment. Why? Because a well-designed data model will easily reduce your programming and testing cost with 50%, due to the ability to catch design errors and flaws in an early stage, preventing bugfixing afterwards, or even worse, expensive design changes when in production.
This already results in less project time and cost, but having a good data model method often gives the opportunity to automate tasks further down the workflow, such as automatic deduction of the PDM from the LDM, and automated DDL (Data Definition Language, SQL for instance) generation from the PDM, ready to run on your DBMS.
Beside these already big advantages, the same reduction in cost and time happens when you need to maintain or expand your system.
Documentation is still considered a dirty word by many developers. But in practice, have you ever looked back at code or a database that you created several years ago? Can you honestly say that you still know what is what and why things were created the way they are?
Then consider a colleague creating the database, without decent documentation and a good data model. And then he leaves your company, and a new person comes in. Think of how much easier it will be for the newcomer to dive in to the system and comprehend the what and why.
A good data model will visualize the complexity of a system, allowing you to get a clear view on the development needed, and the risks a project will have, and even better, to avoid many of these larger risks and errors that are otherwise bound to be made.
A well designed database runs many times more performant then any randomly created database. A good data model takes into account natural flow of the data, but also the usage of the system for which it is being designed, the way the data will be entering the system, but also the way the data will be retrieved from the system. Keeping all these requirements as clear objectives during the design phases of the data model, will result in a database that runs on top speed for what it is supposed to do.
Scoping and Agreeing
Data models in the different levels create a clear vision for people to work with, and to agree upon. The different data models should be clear for the business, management, analysts and developers to see what is expected, what it is looking like, what is in scope, and what is not.
Data models can help you visualize your data, and get a feel for the data and how it is flowing and grouped. It’s a very useful tool when working with data and databases, and will lead your project to success!