John M. John M. - 4 months ago 18
MySQL Question

Why use MySQL over flatfiles?

A friend and I were debating about whether he should use MySQL or a flatfile database for his website's backend. I told him to go with MySQL because it was structured, held records well, and was consistent. He on the other hand said that he would rather go for speed. Reading files is a lot quicker than connecting to MySQL and it made me wonder whether he was right. For example, why not just create a folder for each table, like so:

users/
groups/
posts/
, within the folders have the files named by ID (
1
,
2
,
3
) and then for the data use a format like so:
username: John\npassword: e2fc714c4727ee9395f324cd2e7f331f\nemail: example@example.com
?

In other words, what are the advantages of MySQL over flatfiles?

Answer

In other words, what are the advantages of MySQL over flatfiles?

MySQL offers indexes and joins (for execution performance), transactions (for data integrity) and SQL (for development performance).

It your project involves just a 3-line self-sufficient text file, you don't need MySQL.