Fail in a design

OK, now I’m definitely sure MongoDB wasn’t a good choice. Another requirement I’ve imposed is to have a multiple-level tree of categories so that selecting one of them will show advertisements from this category’s descendants. There are some approaches to modelling trees described here, but all of them seem unelegant/unusable in my case. I like the idea of nested sets there, but setting numbers to nodes would be too complicated. So I’ve simplified the target model to 1 level only. Further narrowing search results down can be done by filtering. A filter will be stored together with a category so a collection of categories is still necessary and an advertisement can’t refer to its category by a name.

Another issue which I’ve noticed only after thinking deeper about the CRUD operations is transactions. If a user wanted to delete multiple advertisements, or the whole account (cascading to associated advertisements), there would be a few operations to perform on multiple documents. MongoDB is not designed for such references so it doesn’t provide transactions for different documents. It can be implemented manually as described here, but come on, should I reimplement the wheel? Anyway, I’ve gone too far now so I must go even further and continue developing the application as planned, without caring so much about good practises.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s