Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are databases always the solution in web data storage?

I haven't got any experience with databases, but intends to learn it and use it on a web project I'm planning.

Though, I've got advice from a pal of mine that the use of databases should be quite more extensive than I planned. He believes in keeping almost all of the data in databases, where I find that databases are most convenient regarding perhaps user data (just tiny pieces of data), and page content data and the like (everything that's not just very tiny pieces of data) in static files - without having any knowledge to build that assumption upon.

  • What would be the better solution? Minimum data in databases, or as much as I can find ways to store in them effectively?
  • Is there a performance difference between the use of static files and databases?
  • Would the best solution depend on general site traffic?

I intend to use a combination of PHP and MySQL.

like image 866
Sune Rasmussen Avatar asked Jan 18 '10 00:01

Sune Rasmussen


1 Answers

If you want to be able to search specific data based on several parameters, then you really need to use a database. The SQL language namely offers you the WHERE clause exactly for this. Also whenever data is to be created and updated, the database is the best choice, because it provides constraints to ensure the uniqueness of the data to certain degree. Also relations between data is best to be managed by the database (using foreign keys and so on).

For example an user profile is best to be stored in a database. Also user-controlled input must be stored in a database. Server-side include/template files are on the other hand best to be stored as normal files in the server's local disk file system, because there's no need to search in it. You can eventually store filenames in the database if you want to "link" them with some more (meta)information (e.g. menu/submenu). The same applies to binary files (images, downloads, etc), you don't want to have them in a database, unless you want a (extremely) high degree of portability.

like image 89
BalusC Avatar answered Sep 30 '22 22:09

BalusC