10

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.

0

3 Answers 3

11

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.

0
5

Basically you a bunch of options here.

  1. Relational
  2. Non-relational
  3. Hybrid (basically relational data with some extended data in a non-relational form, like XML or the like).

Your initial discussion suggests that your data is essentially tabular so a relational model is naturally fits your data.

The second point to keep in mind is that the relational model is well defined mathematically, which helps you repurpose data later for analytics you may not have thought about now.

One of the promises of non-relational models however is a better API. I would suggest that relational models can be encapsulated through a stored procedure interface of you focus on discoverability which can be loosely coupled with your application. You haven't mentioned PostgreSQL but I have written a fair bit on ways to do this on my blog. The first to read is http://ledgersmbdev.blogspot.com/2011/10/introduction-to-soda.html

2

The question, "relational or not" is based on a false assumption that the two are somehow comparable. They are not. The question you're asking might be more constructively phrased as, Should I use a DBMS based on math and logic, one that supports transactions and provides provably correct results, or should I build my own?

Here's a metric for you: if you're not processing millions of transactions per second or adding terabytes of data per day, you're probably not in No-SQL territory. When you get to problems on that scale, it becomes worth it to your employer to pay you to cobble together something very specific to deal with an outsize need. Short of that, likely is $50,000 in hardware will run any SQL DBMS you care to name very quickly, saving gobs of time and money, with greater assurance of correct results and reliable operation.

1
  • 1
    Thanks for your answer, but I think this is more of a comment. Yes, I agree that it really isn't a relational vs non-relational question. As I said I think it really boils down to date/time handling and date range queries. What I need are answers outlining the specific advantages of a particular DB. Also I think that SQL vs NoSQL is not a matter of scale, but about the appropriateness for what you are trying to do. So your "metric" really has no bearing on whether to use an SQL vs NoSQL solution.
    – Ron
    Commented Apr 21, 2013 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.