Monday, October 20, 2014

Data structures are not tabelar

Recently one of my colegues has been designing a piece of structure that was supposed to store some data about something. It isn't really important why or what data. The point is that for the most part there have been 1:1 or 1:n relations. I can't tell why or how it came to me but the itch was just to strong to let it go and I really had to ask what is actual thing he's trying to achieve.

The data model consisted of 8 tables, 2 additional artificial concepts (just for the sake of storing data) and a bunch of names that didn't really make any sense.

It turns out that when we tried to create example records we wrote them down very naturally in JSON because storing data in tables on paper was just to cumbersome.

A rule of thumb: if you can't picture something don't do it!

I started to look for an alternative storage for those documents and found out that there are not too many options available for free. There's obviously the (almost infamous) MongoDB but with its recent bad press and the lack of embedded mode I felt it's not the right way to go. Luckily we've stumbled upon OrientDB - a multi-paradigm database implemented in Java. Since the application was already on the JVM having an option to do an embedded document database seemed like the perfect match.

Now the whole thing is just a document with some embedded documents since all the data comes as one. And using OrientDB's pseudo-SQL dialect is super simple!

Go ahead and try it out yourself! It's super simple!

Happy coding!

No comments: