Repository navigation
JSON Duality Views
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.
Many business applications maintain two different representations of the same data:
Used by the database.
inspection_card
measurement
checklist_item
finding
attachment
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 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
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.
The API can work with complete business documents rather than assembling multiple result sets.
Benefits:
- Less transformation code
- Cleaner endpoints
- Easier maintenance
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.
The data remains stored in relational tables.
Benefits include:
- Referential integrity
- Transaction consistency
- Constraint enforcement
while still providing document access.
Developers spend less time writing:
- Join logic
- Serialization logic
- Document assembly code
and more time implementing business functionality.
Like any technology, JSON Duality Views are not a universal solution.
Important considerations include:
The quality of the resulting documents depends on the quality of the underlying model.
Poorly designed relationships can create complex documents.
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.
Large documents can become difficult to understand if too many unrelated entities are combined together.
Careful modeling is important.
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.
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.
The project demonstrated that MySQL JSON Duality Views can provide a practical