I was reading about EAV, and what options are available to avoid the pain caused by it, and stumbled upon using JSON in fields.

This mariadb feature page shows an example like,

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";

The JSON is the part that would be a problem, if it was defined in a relational table's schema. Is this really as viable as it looks at first glance?


Yes, It can.

But because it is a huge backward incompatible change it cannot be implemented in core in the nearest future

Also if you decide to switch to schema less data it is better to switch to document database like MangoDB

| improve this answer | |
  • MongoDB would be a mistake IMO, for a few solid reasons. First it doesn't provide a standardized query language, it also doesn't fit the requirements as well, because almost all of the data in Magento 2 really is relational. Only the additional attributes don't fit well in a relational model. The cost of not using a relational model means querying becomes has to be more complex, and push more work to the application layer, which is already required for the EAVs. – J. M. Becker Dec 29 '18 at 0:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.