Why We Need Smart and Dynamic Data Models

In the META Web project, a data model is an essential building block. But how it differs from standard application data models?

More than Data Types

In programming languages, there are common data types such as int, float, bool, string, and so on. What do they tell us? Nothing more than how they will be stored in a memory and which value we can assign to them.

This approach lacks semantic meaning. For that reason, META Web comes with more complex data types. Take a look at following examples.

Text type represents a basic textual value which can have limited length and pattern checking.

Number type represents both integer and float values, and it can has boundaries.

These are basic types such as string or integer. But following types tell us more than their data type.

Email type represents also text value but that value must match an e-mail address format. And well, if we know it is an e-mail we can use that information. A browser or an API client can provide an interface for sending emails to that address. Or it can save the address into a contact list.

Range type represents also a numeric value. But we know it has boundaries so we can display it as range selector or as a gauge component.

Semantic Schemas

The META Web data model also supports an attribute called “schema” which describes a nature of a model property and how it relates to others.

  • The “customer” property schema tells us that it represents a person.
  • The “name” schema tells about fields that they represent a generic entity name
  • The “email” does not need a schema because the nature of it’s type tells us enough information

Together it describes a person with a name and email information. How can we use it? A browser, for example, can offer an option to add this person to an address book or a social network automatically.

Dynamics

In programming languages, we often define more than data types of our data model. In many cases, data models are conditional and more complex.

Take an order form for an example. It consists of an invoicing address and a delivery address. And for simplifying the order process it often has a checkbox “Same as invoicing address”. For data model, this means if that checkbox is checked then all delivery information fields are not mandatory anymore.

This behaviour is not a problem when creating a data model using standard programming languages. But in the META Web, the data model is defined in a declarative fashion without any programming.

Take the following example of the order form data model:

How can we describe desired logic without programming? For that purpose, we’ve created a META Script expression language. It’s not a programming language. It’s more similar to spreadsheet formulas. You can describe a data model logic using simple expressions.

Look at another example with the implemented order form logic:

What is different? We defined “required” attribute of delivery fields as an expression, which tells an API client that these fields are required only if “sameAsInvoicing” is not true.

Conclusion

The modern data model needs more information than simple data types. If we want to understand the model we need more complex types and semantic information. And also a way to describe dynamic relations between individual fields.

Read more about the META Web project at http://metahub.cloud/ and follow us on Twitter @metaweb_hub

Want to try the META Script? Check out the playground at http://play.metahub.cloud/meta-script/