MongoDB and noSQL


So today I tackled some problems at work with MongoDb, this is my first time using a NoSQL data engine. Basically I woke up and realized that what my client wanted required a EAV pattern implemented, I shivered, I've worked a lot with Magento and even when I think it's a excellent tool it is the prime example on why EAV can be a PITA.

For those not familiar with EAV, wikipedia describes it as:

Entity–attribute–value model (EAV) is a data model to describe entities where the number of attributes (properties, parameters) that can be used to describe them is potentially vast, but the number that will actually apply to a given entity is relatively modest. In mathematics, this model is known as a sparse matrix. EAV is also known as object–attribute–value model, vertical database model and open schema.

So far so good, the thing is that EAV isn't all roses and candy, or it is when you are modelling the data as it looks good on the database, implements easy and inserting records is a piece of cake, but ... the horror comes when querying for content, just look up on google and you will find some scary pieces of sql just for retrieving some trivial data.

Enter MongoDb...

MongoDB allowed me to avoid this, at least so far and have the app ready for the first prototype demo for the client. And it's quite easy (for this case of use at least). Plugging this implementation of Mongo on my site I successfully converted everything to NoSQL and just had to change a few snippets of code here and there. However I didn't want to put all my money on MongoDB just yet so I ended up with a Mongo/MySQL hybrid, just using the first on the model that I needed the functionality in.

I'm not really sure if this is the best approach to solve it, not being familiar with NoSQL databases makes developing in it a little slower.

Post information
Posted by 2014-11-01 07:13:57 +0000 UTC

Leave a Comment: