Ask HN: Best beginner database?

4 points by applecrazy ↗ HN
I'm developing a pet project (essentially a wishlist) using Node and Express so I can learn how to develop full-stack web apps. I was thinking of using Mongo to store data for the backend, but I don't think it's the database I should use as a newbie to databases. What do you think?

6 comments

[ 3.5 ms ] story [ 14.9 ms ] thread
Forget about MongoDB, it's terrible choice for 99% of projects.

Use PostgreSQL.

Could you elaborate as to why it's such a bad choice and also in which use case you would find it acceptable to use Mongo? I really want to understand why certain tools are better for certain tasks.
one could argue that it's useful to have a grasp of relational databases (and SQL) in general. taking the longview, mongo is more of a niche technology.
Most important of all, MongoDB doesn't support transactions. You have to learn how to work with transactions, only then you can ditch them when working with a database.

Then there is the age of each database. MongoDB is only a fraction Postgres' time on the market, and Postgres is still alive and kicking. Even if you look only for sexiness, the fact that Postgres is still nice and wanted thing is important. Have you seen any HN posts about MongoDB lately? And about Postgres? Food for thought.

MongoDB is never acceptable. Let's make this short and concise.

[edit: fail. This answer is crazy long. Seriously, this topic should be covered in a book. I'll write one some day]

--- ONE DECISION RULE TO RULE THEM ALL: SQL databases are easier to use and maintain than NoSQL databases. Always use SQL when possible, only use NoSQL when forced to.

--- If you have less than 1 TB of data, you should use a normal SQL database.

It's the easiest to use, it runs on a single node, it supports "JOINS", it supports transactions, it fits all the most common needs.

The usual free SQL choice is PostgreSQL. Sometimes it's MySQL instead (mostly for the Apache+PHP+MySQL stack for which there is cheap hosting service available).

--- If you have more than 1 TB of data, you have to use a NoSQL database. (Cassandra, ElasticSearch, Riak)

They support splitting data and operations over multiple nodes which is necessary to handle this scale. The downside is that they can't support joins nor transactions because of that.

--- Never use MongoDB.

99% of projects should use a traditional SQL database as per the major rule. The project is simple enough, SQL is fine!

The 1% of complex web scale projects MUST NOT use MongoDB under any circumstances. MongoDB has know reliability and scalability issues that WILL lead to disaster. Use either ElasticSearch or Cassandra instead (depending on the usage).

Why mongo is terrible: http://www.mongodb-is-web-scale.com/

Mongo is a bad choice for 99% of projects. Unless you're 100% sure your data is unstructured and will never ever relate to anything else, it's probably bad.

Mongo is designed for unstructured data. That is data which has a very loose relationship to any other object, and data which changes often or is unpredictable. To top it off, Mongo doesn't have transactions. Without transactions, you have to implement them by hand with something like Redis, which is rather iffy.

You almost always have structured data. A wish list would probably relate to products, which relate to merchants such as Amazon, Newegg, Ebay, etc.

Those relationships are a pain to express in Mongo. In-fact it even ends up being slower to express them in mongo, because of it's lack of JOINs, since they don't expect you to have relations.

I personally recommend MariaDB (MySQL fork, included by default on most linux distros now to replace mysql-server). Despite it's poor reputation, it's used (in some form) by practically every big company, including Facebook and Google.

PostgreSQL is another great option. I've found it a bit more difficult to find guides for Postgres, which is why I recommend it second to MariaDB/MySQL.

Postgres is not flawless, it has awkward quirks, like the fact you cannot sanely upgrade postgres versions without exporting all of your data, and then re-loading it again. However, it is regarded as the most powerful open source database, and possibly the most reliable database.