Web Weaving: Flat File Database vs. SQL

Continuing my research on different styles of databases that I could possibly use for web developing, I have found something interesting about flat file databases. I have always heard mixed things about them, which I can usually lump into two categories: “It’s faster than SQL” and It’s slower than SQL”. The funny thing about this is the fact that both categories aren’t necessarily wrong, until someone decides to use a word like “always” when describing how a flat file database is better or worse.

Both styles of databases have their pros and cons, and what you are doing should help dictate what sort of database you are going to use (not just what you want, but what is the best/most functional). There are a few things that should be looked into before you decide on what database structure you’re going to go with. Is the data static (hardly ever changed or added to) or is it dynamic (always changing)? Is the website that is using this database going to grow and evolve, or is it a “one time” deal?

Is the data static or dynamic? Flat file databases work very well with data that is meant to be stored and not altered very much, if at all. All you have to do is read the file and pull the data that you want, right? Generally speaking, yes. More specifically, you are going to have to find or make a structure/system for declaring how you data is going to be stored (for example, CSV or by line? The great thing about using a SQL database is that the main architecture is already there – all you need to do is define what the columns and rows will hold, and then create the code (in my case, php) to insert/edit/update/remove the data from the rows/cells.

Is the website going to evolve? For many websites, it is natural progression to add more pages and features to it, either to make it more user friendly or to accomodate other forms of data. Flat file databases can be a headache when it comes to large quantities of data (not to mention that you’ll see a performance degredation due to having to read a file [files can only be read from top to bottom]). SQL can link similar tables/rows together by using “joins”, whereas you may need several flat file databases to be accessed and then the data strung together via php, asp, or whatever else you’re using. SQL allows for a more convenient and modular design of your website. SQL is great for allowing greater scalability as more complex data is needing storage.

It is easier to change the code behind a SQL based site than it is to rewrite all of your parsing code when you allow for more complex data. So, unless you are using largely static data storage, SQL is a good choice for storing data.

This entry was posted in The Plank, The Soapbox and tagged , . Bookmark the permalink.

About Captain Thomas Mashek

"Captain Thomas Mashek is a self-imposed captain with no formal aerial history to speak of (or anywhere on record under that name). He donned the title of captain when the Zygote was presented to him by a strange man named Gwyn Wynn. The only stipulations with the ship were that Gwyn was to be a permanent part of the crew and that the crew would help him with his 'studies', no questions asked. Seeing this as a good opportunity, Thomas took this stranger up on his deal without giving much thought to it, figuring it was better than being stranded on this junk dock he managed to get himself to." - Excerpt from the Captain's Log.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CommentLuv badge