1

I am building a social network (connections and their connections, messages and locations) and I am a little confused in deciding whether to go with a relational database (MySQL) or a no-sql system (MongoDB) when designing our backend APIs. Does anyone have any views on what to use when?

PS: I am building developer APIs for developers to tap into our system with oAuth. So scalability and performance is also key factor. Rails 3 + Devise (most likely).

halfer
  • 19,824
  • 17
  • 99
  • 186
xoail
  • 2,978
  • 5
  • 36
  • 70

4 Answers4

3

This depends largely on which technology you are comfortable with, what exactly do you want to get out of this etc. etc.

Coming back to your question, not all data is relational. So For those situations, NoSQL can be helpful. With that said, NoSQL stands for "Not Only SQL". It's not intended to knock MySQL or supplant it.

SQL or MySQL has several very big advantages:

  1. MySQL is Strong mathematical basis.
  2. Declarative syntax.
  3. A well-known language in Structured Query Language (SQL).
  4. Highly proven and extremely reliable technology. MySQL has been around far more than the oldest noSQL. It's a mature piece of technology. Google Adsense runs on MySQL, Facebook persistent store is MySQL. The examples suggest its reliability.
  5. As a result of being mature technology, people have optimised the shit out of it.
  6. Enormous online and open source community both for support and providing features as opposed to noSQL technologies (look what happened to Cassandra)

In my opinion, all the above questions matter to me when I choose a piece of technology. Hey well, if it's a Sunday evening project that you want to whip up with little real world consequences then do what whims you but if it's slightly more serious then please consider these questions.

SQL hasn't gone away (even in noSQL). It's a mistake to think about this as an either/or argument. NoSQL is an alternative that people need to consider when it fits, that's all.

Documents can be stored in non-relational databases, like CouchDB or even in MySQL (it borders on abuse but still). A Relational database in principle could make a very good NOSQL solution

Check out this hilarious video. This gives a different perspective on this topic :)

enter image description here

Community
  • 1
  • 1
Srikar Appalaraju
  • 71,928
  • 54
  • 216
  • 264
  • @SergioTulentsev, lol i know what you mean. Even the most optimized piece of technology can come crashing down if used "incorrectly". So the challenge is to figure out what "correctly" is. I have seen people use mySQL from a key-value store to a highly complex bank transaction system. Its important to figure out the right mix. – Srikar Appalaraju Jul 10 '12 at 02:46
1

I chose MongoDB for my "Social" application because of the flexibility of the schema and scalability/performance. MongoDB has allowed me to adjust my schema without having to make drastic code changes and makes reading/finding data very easy.

I also chose MongoDB as a learning experience. I wanted to know what all the fuss was about with these "noSQL" databases...and now I know why. MongoDB is awesome in my opinion and definitely worth looking at for a Social network that requires scalability and performance. Node.js would also be an excellent choice for the API ;)

SomethingOn
  • 9,813
  • 17
  • 68
  • 107
1

neither.

Go with a network/graph database, you will not regret. My current favorite is Neo4j.

http://neo4j.org/

note: Not related to Neo4J

I think the latest version of Neo4J has a sql interface, just in case you would need SQL compatibility. Otherwise, do your crud using their native library. It is very fast.

If you would need to visualize the Graph data, which would be very impressive to show to your boss, use yEd package. To export neo4J to a graphml format, use this:

Convert Neo4j DB to XML?

You could front end your relationships in Neo4J and backend it with a relational db or mongodb. I have seen those hybrid architectures as well.

Community
  • 1
  • 1
srini.venigalla
  • 5,137
  • 1
  • 18
  • 29
0

If you project requires actual relationships between certain objects then MySql will be fine. If you are storing things that typically just have inherent data to them, such as a user with messages to other users, then a document style database, such as MongoDB, makes more sense.

You can do relationships in mongo, but they make a lot more sense in a relational database. But, if most of your data is more inherent of a user then mongo makes more sense.

In your case a document type of scheme makes more sense where each user has a list of connected users and their own personal atributes, ect...

sean
  • 3,955
  • 21
  • 28