Data modeling involves designing data structures and expressing relationships between entities. Data modeling should create meaning from data so that it represents the real world.
The value of data modeling
Data modeling has great value for both application development and large-scale data warehouses.
From an application development perspective, data models act as a blueprint. It saves significant time, cost, and effort during development and while bug fixing, and provides data validation reducing data errors.
For data warehouses, where data is accumulated from a variety of sources, data modeling provides value for the business as a whole. Understanding the relationships between entities helps cultivate meaning and brings context and data closer together. The result: better data access, quality, and efficiency.
The key pillars of data modeling
Rather than going into great detail about the pillars, we’ll list them as they are self-explanatory.
- Main data subjects
- Attributes of the data subjects
- Relationship between data subjects
- Business rules for data.
The pillars of data modeling require domain and IT collaboration to get a true understanding of your data model.
Data modeling in TerminusDB
We have a section in our documentation that talks extensively about data modeling in TerminusDB and how it compares with SQL. We’ll provide a brief overview of how you can model data in this section:
Data Product Builder in the UI
The TerminusDB and TerminusCMS dashboard features a Data Product Builder. You can build your data structure quickly using the UI. You can insert:
- Documents – Add properties (XSD types)
- Subdocuments – Inherits the properties of the parent document
- Enums – Lists of things that documents can link to.
This short video shows how you can quickly build a schema for your database and create relationships between your documents.
We’ll use this simple project management application as an example:
Document | Document Relationship | Relationship | Relationship description |
organization | team | consists-of | An organization consists of teams |
team | project | collaborates-on | A team collaborates-on projects |
project | task | divided-into | A project is divided-into tasks |
task | employee | assigned-to | A task is assigned-to an employee |
Data modeling in JSON
GUIs aren’t everyone’s cup of tea so you can build your schema in JSON and import that into your database using cURL, the CLI, or the JavaScript or Python clients. Here’s the project management application schema in JSON:
[
{
"@base": "terminusdb:///data/",
"@schema": "terminusdb:///schema#",
"@type": "@context"
},
{
"@id": "project-status",
"@type": "Enum",
"@value": [
"in-progress",
"on-hold",
"completed"
]
},
{
"@id": "project",
"@inherits": "organization",
"@key": {
"@type": "Random"
},
"@type": "Class"
},
{
"@id": "organization",
"@key": {
"@type": "Random"
},
"@type": "Class"
},
{
"@id": "team",
"@inherits": "organization",
"@key": {
"@type": "Random"
},
"@type": "Class"
},
{
"@id": "task",
"@inherits": "project",
"@key": {
"@type": "Random"
},
"@type": "Class"
},
{
"@id": "task-status",
"@type": "Enum",
"@value": [
"in-progress",
"on-hold",
"completed"
]
},
{
"@id": "employee",
"@inherits": "team",
"@key": {
"@type": "Random"
},
"@type": "Class"
}
]
Extend your data model
Data modeling is not only useful when an application is first built, but it is also handy when extending the functionality of software. The world doesn’t sit still and neither does app development.
TerminusDB is handy for this purpose. TerminusDB is an immutable data store. When data is written to a store, it does not change or mutate existing data. Any deleted data is masked, and any new data resulting from a transaction is added on top of the mask.
As the transaction history of a database is preserved, it is easy to travel back in time to a particular commit or branch the database. All data and information at a commit point are immediately available. In a branch, make changes to schema and extend and experiment to build new features for your applications.
Branch your database with the TerminusDB CLI, or use the dashboard – watch the video below.
terminusdb branch create admin/foo/local/branch/changes --origin admin/foo/local/branch/main
Give it a go for yourselves. Try TerminusCMS or install TerminusDB.
Here’s an article to help that discusses patterns and principles for graph schema design in TerminusDB.