Skip to content

JSON Duality Views

morad1998 edited this page Oct 17, 2026 · 1 revision

JSON Duality Views

Introduction

One of the primary objectives of this project was to evaluate MySQL JSON Duality Views using a realistic quality inspection application.

Rather than building a simple proof-of-concept, the feature was tested within a complete business domain that included:

  • Inspection cards
  • Measurements
  • Checklists
  • Findings
  • Attachments
  • APIs
  • AI capabilities

The goal was to understand how JSON Duality Views perform in real application development scenarios.


Traditional Development Model

Many business applications maintain two different representations of the same data:

Relational Model

Used by the database.

inspection_card
measurement
checklist_item
finding
attachment

Application Model

Used by APIs and front-end applications.

{
  "inspectionCard": {
    "measurements": [],
    "checklist": [],
    "findings": [],
    "attachments": []
  }
}

This often requires:

  • Complex joins
  • Mapping code
  • Transformation logic
  • Additional maintenance effort

JSON Duality View Approach

JSON Duality Views expose relational data as editable JSON documents.

Instead of manually building document structures in application code, a complete business document can be generated directly from relational data.

Conceptually:

Relational Tables
        |
        v
JSON Duality View
        |
        v
Business Document

Inspection Card Document

The project models an inspection card as a single business document.

Example:

{
  "cardId": 1001,
  "workOrder": "WO-10001",
  "status": "OPEN",
  "measurements": [],
  "checklist": [],
  "findings": [],
  "attachments": []
}

From an application perspective, the card behaves like a document.

From a database perspective, the information remains stored in normalized relational tables.


Benefits Observed

Simplified API Design

The API can work with complete business documents rather than assembling multiple result sets.

Benefits:

  • Less transformation code
  • Cleaner endpoints
  • Easier maintenance

Natural AI Integration

AI models generally consume documents rather than relational tables.

JSON Duality Views naturally provide:

  • Structured business context
  • Nested relationships
  • AI-friendly payloads

without extensive preparation.


Single Source of Truth

The data remains stored in relational tables.

Benefits include:

  • Referential integrity
  • Transaction consistency
  • Constraint enforcement

while still providing document access.


Reduced Development Overhead

Developers spend less time writing:

  • Join logic
  • Serialization logic
  • Document assembly code

and more time implementing business functionality.


Challenges and Considerations

Like any technology, JSON Duality Views are not a universal solution.

Important considerations include:

Document Design

The quality of the resulting documents depends on the quality of the underlying model.

Poorly designed relationships can create complex documents.


Business Boundaries

Documents should align with meaningful business entities.

In this project, the Inspection Card was a natural document boundary.

Not every table should become a document.


Readability

Large documents can become difficult to understand if too many unrelated entities are combined together.

Careful modeling is important.


Why This Use Case Was Selected

Quality inspection is an excellent scenario because it naturally forms a business document:

Inspection Card
├── Measurements
├── Checklist Items
├── Findings
└── Attachments

Users think about a complete inspection, not individual database tables.

JSON Duality Views match this mental model very well.


Lessons Learned

During implementation several observations became clear:

  • Business-document thinking becomes more important than table thinking.
  • API design becomes simpler.
  • AI integration becomes more straightforward.
  • Relational integrity remains valuable and should not be abandoned.
  • JSON Duality Views work best when centered around a well-defined aggregate business entity.

Conclusion

The project demonstrated that MySQL JSON Duality Views can provide a practical

Clone this wiki locally