What is a Data Model?
A data model is a representation of entities and their relationships with one another. A data model is most commonly represented as a diagram, with shapes representing entities and arrows showing the relationship between entities.
For an e-commerce business, entities might be products, orders, customers and customer addresses. An order consists of one customer and one customer address and can contain one or more products.
Data models are conceived in the early stages of a project to create a shared model and language for designers, developers, data scientists and others. Data models can evolve to become more detailed (e.g., into a database schema) and are used to ensure that designers, developers and database administrators understand the requirements of a software application and how data can be accessed and stored.
Data models can prevent errors: they help project participants identify errors, false assumptions and misunderstandings before the software application is developed. Developers reference a data model when communicating and coordinating with database designers and database administrators. Data models help an organization decide how data will be stored, accessed, utilized and updated.
Types of Data Models
The three types of data models range from high-level (e.g., conceptual data model) to detailed and specific (e.g., physical data model).
Conceptual Data Model
The conceptual data model shows entities and their relationships. The intended audience for a conceptual data model is non-technical users on the business side. It shows entities and relationships as determined by the business.
Logical Data Model
The logical data model describes entities and relationships at a more detailed level, but is not associated with a particular database system. The intended audience for a logical data model is technical staff (e.g., database designers, application developers) and used as a basis to create a physical data model.
Physical Data Model
The physical data model contains the highest level of technical detail. It outlines how the entities and relationships will be implemented in a particular database system. In a relational database system, the physical data model is used to create the tables and fields that represent entities. It is used by technical staff to create and manage the database itself.
The Data Modeling Process
In a typical process, the project team progresses through each data model, starting with a conceptual data model, followed next by a logical data model and then a physical data model. Consistency of the entities and relationships should be maintained across each model.
In addition to these types of data models, there are four primary approaches: hierarchical, relational, network and entity relationship (E-R).
Hierarchical Data Model
A hierarchical data model is shaped like a tree, with a few entities at the top (i.e., parents) and child entities that flow downward from the top. Extensible Markup Language (XML), which defines rules for encoding documents in human-readable and machine-readable formats employs a hierarchical data model. XML documents contain a root element that is the parent (or ancestor) of all subsequent elements. Elements in an XML document can contain sub-elements with text and attributes.
Relational Data Model
The relational data model is based on a set of tables. Each table contains fields. Those fields that are common across tables can be used to “join” two or more tables. The relational data model is implemented in relational database systems such as Oracle. Structured Query Language (SQL) is a widely-used mechanism for generating queries and writing data to relational databases.
Network Data Model
The network data model was designed as a flexible way to represent entities and their relationships. Unlike the tree-based representation of the hierarchical data model, the network data model employs a graph with edges and nodes. The network data model allows for each entity to have multiple parents and children.
Entity Relationship (E-R) Data Model
The entity relationship (E-R) data model uses a graphical approach that shows entities and relationships in an entity-relationship diagram. The diagram typically represents entities as squares or rectangles, with lines drawn between them to denote relationships. When implemented in a relational database, each row in a table is an instance of an entity type, while each field in that table is an instance of an attribute type.