
Ask HN: Best beginner database? - applecrazy
I&#x27;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&#x27;t think it&#x27;s the database I should use as a newbie to databases. What do you think?
======
someguy1233
Why mongo is terrible: [http://www.mongodb-is-web-
scale.com/](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.

------
user5994461
Forget about MongoDB, it's terrible choice for 99% of projects.

Use PostgreSQL.

~~~
applecrazy
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.

~~~
user5994461
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).

