SQL Vs NoSQL

  • In general case, choose Database/SQL because they've been arround for a while
  • Schema logic is both doable in Database/SQL and NoSQL
    • The only difference is for NoSQL you're moving schema to application layer rather than database layer
    • If your schema keeps changing than maybe NoSQL is better
  • Choose NoSQL if your application
    • require super low latency
    • unstructured, doesn't have any relational data
    • you only need to deserialise and serialise data (JSON, XML, YAML)
    • Trash data that can be safely discarded at some points (logging, session storage)
  • Choosing NoSQL is very risky. For example in MongoDB. When you write a data, the data is staged to write at a later time.
    • Now what happens if it can't write later?
    • It doesn't guarantee consistency
  • Database/SQL is harder to scale horizontally because of CAP theorem but doesn't mean it's not scalable. Scalability is a very complicated topic
    • SQL follows ACID which given consistency. When horizontally scaled and network failure happens. It sacrifices Availability by terminating the whole transaction
    • Join table is harder to scale horizontally given the join table and main table are in different instances
  • NoSQL is easier to scale horizontally (sharding)
    • NoSQL are contains of documents. and it's self-contained object.
    • We can put these objects on different servers without worrying about joining rows from multiple servers
    • BASE allows NoSQL to cheat the system by drop of some of the functionality to maintain scalibility concept
  • Now there is NewSQL that supports Horizontally scalability for SQL

Performance

NoSQL has better performance comparing to SQL: Paper.pdf (rochester.edu)

Technical knowledge