Relational and semi-structured data

Schema Flexibility with Data Integrity

Hybrid data modeling – using both structured and semi-structured data – can meet the flexibility requirements of modern web, mobile and IoT applications, without sacrificing ACID transactions or standard SQL.

White paper

Flexible data modeling: JSON functions

MariaDB TX includes a comprehensive set of SQL functions for creating and querying JSON documents – everything from reading and writing fields, arrays and objects to creating JSON documents and merging relational data.

Download now

Top 5 reasons to use relational + JSON


You can use transactions to insert/modify multiple JSON documents.


You can apply integrity constraints to specific fields within JSON documents.


You can query JSON documents using standard SQL functions.


You can index specific fields within JSON documents.


You can return JSON documents as relational data, and vice versa.

Querying hybrid data models

What if you want to store user profiles in a single row? Yes, a user has user_id, name and country (and more). However, users may have personal and work email addresses as well as mobile and office phone numbers. While some users have Twitter and LinkedIn accounts, others may have Facebook and Instagram accounts. What about interests?

With JSON functions, you can store users profiles in a single row.

user_idnamecountryattr
sjohnsonShaneUS{
"email": {
"work": "shane.johnson@mariadb.com"},
"phone": {
"mobile": "(555) 555-5555"},
"social": {
"twitter": "@shane_dev",
"linkedin": "/in/shanekjohnson"},
"interests": [
"Science Fiction",
"Distributed Systems"]
SELECT name,
   JSON_VALUE(attr, "$.email.personal") AS email,
   JSON_VALUE(attr, "$.social.twitter") AS twitter,
   JSON_VALUE(attr, "$.interests[0]") AS favorite_interest
FROM   tbl_user_profiles
WHERE  user_id = "sjohnson";


nameemailtwitterfavorite_interest
Shanenone@shane_devscience fiction
On-Demand Webinar

How to use hybrid data models

Learn how to validate, query and index JSON documents using SQL functions for JSON, introduced in MariaDB Server 10.2, and how to extend relational data models with JSON documents for increased schema flexibility.

Watch now
White paper

Flexible data modeling: JSON functions

MariaDB TX includes a comprehensive set of SQL functions for creating and querying JSON documents – everything from reading and writing fields, arrays and objects to creating JSON documents and merging relational data.

Read more