Forum Moderators: coopster & phranque

Message Too Old, No Replies

Database vs Flat File

advantage over one and another

         

copongcopong

4:09 am on Oct 6, 2002 (gmt 0)

10+ Year Member



I do not know if this is in a correct forum but it is very related to php or any scripting language and even perl.

I would like to hear from you guys which do you prefer for an average site, would you go for a flat file or make the site database driven? Advantage and disadvantage one against the other?

Lastly, if your hosting is capable with mysql, would you go for database driven information for static site?

Thanks for your insight/s on this. :)

dingman

4:36 am on Oct 6, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It depends on what I'm doing. I pretty much always use scripting, but whether or not a database is called for varries. I haven't sat down and worked up a set of criteria, but I've done it both ways. For example:

My personal web site is fundamentally static content anyway. All I really want to achieve with the scripting is to keep from having the layout, navbar, and formatting info duplicated in a whole bunch of separate files. If I decide I want to add a page, I don't want to have to edit 15 different files to put a link to it in the navbar. For that, it's all flat files on the HD, and they are simply include()ed based on query-string variables. Using a database for this would just make my life harder by making me put the HTML into the database before I read it out into the page, wheras now I can write it up in Emacs (my preferred text editor), put it in my web dir, and I'm done.

On the other hand, I also have a community site with login info, address book, message posting, etc. Trying to store all the data for this in flat files and process them to get the output for any given page would be a nightmare. Dbm files might be good enough. I don't know, because I've never tried using them.

In general, if you can just grab stuff from files without having to process it much before display, that might be the best way to go, but if there's more processing involved to find the bit you want from the data files, I'd go ahead and use MySQL.

littleman

4:41 am on Oct 6, 2002 (gmt 0)



We had a good thread about this a while ago.
[webmasterworld.com...]

I still run perl with flat text files, mostly because it is fast and highly portable. MySQL is really easy to use and very powerful, but I still would use flat files for smaller sites.

It has saved me a few times. The only thing I need to set up shop is a good apache server and access to perl. I could drop a flat text driven ecommerce site on a new host and have it running in 20 minutes.

dcheney

4:42 am on Oct 6, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Database driven sites tend to be much easier to maintain in the long wrong but they also have a few disadvantages such as taking longer to initially develop, tend to be a bit slower to serve a page, and have a few additional security issues to worry about.

Personally, for my largest site, I use a database to create the pages but I serve them as static pages.

One of the big things that may effect the choice is how often the data on the site will change (in my case probably 90% is unchanged in a given month).

jatar_k

7:38 am on Oct 6, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I also do both. Each has advantages but it always depends on the project at hand and what it is best suited to.

Most often I use mysql, I haven't encountered many spots where it was slowing me up. More often than not it is my php as opposed to the db. I use flat files mainly on smaller projects. Littleman has the best point though, for portability you can't beat flatfiles. You just pick the whole thing up and move it. A few tweaks to the config and you're off. Db's are a little more time consuming to set up.

john316

12:04 pm on Oct 6, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I agree that flat files are the way to go. Unless you really need/understand the relational capabilities of mysql it's really not necesary.

martin

8:11 pm on Oct 6, 2002 (gmt 0)

10+ Year Member



There is a very simple rule:

If you want the information the way it is you can store it in flat files, if you want to sort it or reformat it go with a database.

Also if you like to have online administration go with a database.

copongcopong

11:49 pm on Oct 6, 2002 (gmt 0)

10+ Year Member



Thanks for your insights on this and also for the link of the old thread which was also very very informative.

It just made may stand on flat files more strong. To complicate things up, I would plan to use an xml flat files and php.

But to add to my learning cup, i think i need to dig my hands into mysql too. :)

martin

7:28 pm on Oct 7, 2002 (gmt 0)

10+ Year Member



And another simple rule I missed:

If you need simultaneous modifications of the same information you need a database.

lorax

7:50 pm on Oct 7, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Personally, for my largest site, I use a database to create the pages but I serve them as static pages.

So you're using script to export the data into a template? Do you use this method to add pages? How do you handle navigation?

Martin,
Whenever I'm dealing with related data or data that needs to be updated on a regular basis I use a MySQL db driven page. My last few projects have been a mix of static and php driven pages.