Since 5.7, MySQL stores and queries native JSON — letting you keep flexible, nested data inside a relational database. It's the pragmatic middle ground between rigid columns and a separate document store.
Key Points
- Define: attributes JSON in your CREATE TABLE
- Extract values: attributes->>'$.color' or JSON_EXTRACT(attributes, '$.size')
- Validate automatically — invalid JSON is rejected at insert
- JSON_TABLE turns JSON arrays into relational rows for joining
- Index JSON paths via generated columns + regular indexes
- Rule: stable, queried-often fields → real columns; variable extras → JSON
.png)