Database vs Flat Text File: What are some technical reasons for choosing one over another when performance isn't an issue?

Viewed 23221

I am having a problem in one of the teams that I am working in. One of the guys is a bit SQL happy in my opinion and wants to store the log information generated by a small python FTP downloader into a database, instead of just a nice formatted text file. Now its always been my opinion that a database should only be used if it speeds things up, or provides a more reliable interface to the data. What are your opinions?

Thanks!

Edit: In this particular instance, the data will grow about 100 lines per day and be processed once and thrown away. Although this case is of immediate concern, I am more interested in a general answer.

Edit 2: Thanks for all of your responses! I have marked the answer with the most up votes as the answer because I feel that it succinctly states most of the points you all have made, but I will watch and see if something else comes up.

23 Answers

Flat files are databases if you treat them as databases. Advantages of using flat files:

  • highly portable
  • human readable/directly editable
  • zero configuration/administration (sqlite has this advantage too). Security amounts to setting file permissions correctly

Disadvantages:

  • time/space efficiency (this doesn't seem matter for your use case though)
  • no data integrity checks
  • no explicit data types
  • tools for working with flat files as databases are (for the most part) much less mature than DBs with a native storage formats

It is wrong to say that you need to write to a DB in order to query your data. There are several tools that let you do that with flat files:

Related