Search code examples
phpmysqlmongodbentity-attribute-value

Storing report results, MySql or MongoDB?


I have a bunch of reports that I am generating on a weekly and monthly basis. I started to create a MySQL database but then realized I will need to either have tables with tons of columns, and possibly adding them later on. I will then need to update the code every time I add a new column.

I could use an EAV model, or some kind of key/value model, but this would be slow, right?

So then I remember an article about MongoDB, being a 'document' database. The reports are documents, so is this an ideal solution to my problem? It seems too easy?


Solution

  • If your reports tend to have different data structures once in a while then MongoDB is the way to go. You could also store your reports on the filesystem in the XML or JSON formats. You can also serialize your reports to JSON and store them in a MySQL database (this way you can handle different data structures without the need to alter the table). There are many ways to achieve what you're describing. Keep in mind searchability of your reports that may vary based on the choice you make.