Since we are working on such Entity attribute value model from last 2 years. And it added so many good and bad experiences to share. So it is worth to write something about EAV model.
- Open Schema data structure model.
- New entity introduction is so easy.
- Reduce development time.
- No more data structure changes with a perfect crafted EAV Model. Which could be quite expensive for bigger databases.
Why i should not go for EAV model?
Well depends on the type of the application you need to deliver. I believe, for social applications, It is one of the best approach. Since digital social world has so many uncertainties. We can not afford to keep changing database structures to fulfil the requirements of objects.
- EAV model is state of the art but needs expert approach to handle.
- Your queries would be CPU expensive.
- If state of your objects is so certain, than better to go with simple RDBMS approach.
Elgg has implemented EAV quite effectively. We got an opportunity to work on some very complex and interesting requirements. I have so many bad and good experiences while working on such projects. Of course did some mistakes but keep learning from them.
Since we are working in the highly distributed environment where we suppose to work with developers of entirely different culture and opposite timezone. So as a project manager, it was so challenging for me to keep everything organised, especially with EAV model. Where very developer need to just type a very easy syntax ($object->processed = 1) to introduce new attribute of the object. But this simple code can change the whole state of the object.
It was so challenging to keep attributes of objects so organised while having the flexibility. So we built couple of rules in the core of the engine where every attribute is protected by set of rules. And only one guy would be responsible to introduce new attributes of the object. If any programmer try to code out of the defined set of rules. System starts poping up exceptions. This saves my lots and lots of hours. and it also helps us to find some messed up things introduced before i made this self diagnosis engine.