Mongodb – Relational vs Non-Relational Database for Events Database

database-designdatabase-recommendationmongodbnosql

I'm trying to find out whether an SQL or no-SQL solution would be better for creating an events database. I'm creating a ticketing system, similar to ticket master. I know that for either database-type storage is the simple part. The deciding factor is the performance of the following queries:

  • Select events by location within a specific date range.
  • Select all events in a given location (city, town, etc.), sort by date.
  • Search for events by keyword, within a specific date range, within a specific location.

Events basically have ID, NAME, LOCATION, VENUE, START DATE, END DATE

In a relational schema I would have an EVENTS table, a DATES table for storing dates separately because events can occur on more than one date and they are repeatable, and a VENUES table from which the event location (country, city, etc) can be cross-referenced.

I have no experience with no-SQL databases, so if you vote for no-SQL please suggest how you see the "schema" being organized and which particular DB.

I hope this question is specific enough. Query performance is the deciding factor.

After further consideration, I realize the question more properly distills to the availability of date/time functions that can facilitate fast date range queries. I know MySQL and PostgreSQL have such functions. PostgreSQL is even looking a little better at this point in terms of syntax. I don't know what NoSQL solutions have to offer regarding this.

I know the system can certainly be modelled comfortably in a relational database. I also am aware that each no-sql solution is different. I was wondering if anyone with any specific knowledge of a particular no-sql DB could cite why that particular DB is good for the solution.

Best Answer

This seems a little outside the scope of a StackExchange question. However.....

NoSQL databases are, typically, build to resolve specific issues with the relational model. The most common issue addressed is scalability. However, because they're all designed to address different aspects of certain problems that some applications have with the relational model, there really isn't something you can say about all of them as a whole. Maybe you need to handle terabytes of data? Or maybe you need to handle a data schema that is very dynamic across the board and an EAV type schema would just kill performance? Maybe you want a data store that cares about availability more than consistency (see CAP theorem)? Each one is good at something that could be wildly different from what another is good at, while an RDBMS is a much more generalized database.

The answer I hear from people I trust on this topic is that if you don't already know why you need to abandon a traditional RDBMS for NoSQL, then you almost certainly should stick to an RDBMS. There's a reason it took 30 years before people began to seriously consider data store models beyond the RDBMS. If your queries are requiring features not available in MySQL/MariaDB, you may wish to consider another RDBMS that has a more robust feature set. That could be PostgreSQL, or Oracle, or MS SQL Server.

Your proposed schema here already suits the relational model fairly well. You may need a few junction tables for many-to-many relationships, but I don't think you necessarily will see many of those. If you properly size the DB, properly index your tables, and analyze your common queries -- things you have to do with NoSQL, too -- I don't see that you'd have a huge problem. You may even be able to get away with views for the most common queries.