Menu

Postgres vs MySQL vs MongoDB: which database for a small business app?
📰

Postgres vs MySQL vs MongoDB: which database for a small business app?

DEV Community: postgres·Akshansh Gusain·3 days ago
#k2LBPc3b
#devtopostgresql#devto#dev#stock#postgres
Reading 0:00
15s threshold

Short answer: if your app has customers, orders, payments or stock, use Postgres or MySQL. MongoDB makes sense only when your data has no fixed shape.

The reason is transactions. When someone buys the last unit, the stock update and the order have to happen together, or you sell the same thing twice. In Postgres or MySQL that's the normal path:

BEGIN ; UPDATE products SET stock = stock - 1 WHERE id = 42 AND stock > 0 ; INSERT INTO orders ( customer_id , product_id , amount_paise ) VALUES ( 7 , 42 , 49900 ) ; COMMIT ;

Enter fullscreen mode

Exit fullscreen mode

MongoDB can do it too (it has had multi-document ACID transactions since 4.0), but there it's the exception you have to remember, not the default.

The full piece covers:

Relational vs NoSQL, and why "my data might change" isn't a reason to pick NoSQL

Where Postgres wins, and its real weakness

One genuine win each for MySQL and MongoDB

A five-question decision path

Checked against PostgreSQL 19, MySQL 9.7 LTS and MongoDB 9.0, as of December…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.