Current location: Hot Scripts Forums » Programming Languages » PHP » Flat file vs mysql database


Flat file vs mysql database

Reply
  #1 (permalink)  
Old 06-28-05, 06:00 PM
Imusion Imusion is offline
Newbie Coder
 
Join Date: May 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Flat file vs mysql database

Hi,

I have a question regarding server load in respects to using flat file database vs. a mysql database.

I have a member profile thing on my site where the user can change like a background color. Basically I'm having it so the script either opens up a text files with all the members information about what colors they are using then applying them. Or my second method would be to just store that info into a mySQL database then have the script query the database everytime a user visits the page, so it will display the right colors the member has chosen.

I was wondering which method would cause a bigger load on the server, or are both ways find. I'm leaning towards the mySQL database but I'm not sure if everytime a user visits the profile page and querying the data is efficent for the server.

If anyone can give me some insight on which method is more viable or even possibly suggestions on how I would make it more efficent I would appreciate it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 06-28-05, 07:04 PM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
Anytime you're calling from a database - with equally efficient code - MySQL will always be faster and less stressful than flatfile.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 06-29-05, 06:08 AM
FiRe FiRe is offline
Code Guru
 
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
yes and more secure, wheras you can just download "filename.txt" its a lot more difficult to download the database info unless u exploit it in someway! I understand that most ppl r reluctant to use databases as I was, but it is so easy to manage and use over flatfiles!
__________________
Alexa Share <-- Trade virtual shares in websites with this online game.

codR.us <-- Submit and vote for your favorite code snippets with codR.us.

XEWeb.net <-- The ultimate PHP resource network.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 06-29-05, 08:13 AM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
Yeah, it took me a long time to let go of flat databases and move to MySQL, which honestly was stupid on my part.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 06-13-06, 12:58 PM
worshiploud worshiploud is offline
New Member
 
Join Date: Jun 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Smile

I have big issues with MySQL.

The biggest thing is that the host has to have
MySQL available.

Then if you ever move from one host to another,
the database is hard to move unless you are an expert
or pay someone to move it.

I deal with a lot of churches who get free hosting
and it is very limited. I use flat files and keep everything
in one directory. If they ever move, they just copy the
directory and move it.

As for security, if a directory has propper security scripts
installed, it will be as secure as a MySQL DB.

If designed right, it is as fast as MySQL.

I try not to use MySQL just because the things that
make it secure and fast, also make it difficult to use,
modify, backup and restore..

Just an observation.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 06-13-06, 01:10 PM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
What's with all the old topics being dug up lately?

MySQL library commands (as well as pgsql, oci, etc...) are just as easy/difficult as using file library commands. But file handling simply cannot beat "UPDATE this WHERE this = this", etc...

Databases are extremely easy to backup, whether you prefer a web interface, like PHPMyAdmin or PHPMyBackup, or a Windows GUI, like SQLyog Free.

The same goes for restoring. I can have a database backed up and installed on another host in under a minute. In fact I just did this last night with about 6 databases while moving my hosting from hostgator to jaguarpc. Took me all of about 5 minutes.

And let's look at it on a larger scale. Say you have 3,000 (or 300,000, or 3,000,000) items and you want to page them out to show only 25 per page. With flat files you will almost certainly have to load all items into an array, loop through them till you come to the desired results, then display them... this can be pretty slow and eat up a lot of memory. With MySQL it's done effortlessly by appending a limit/offset to the query.

Even when using a relatively small database the processing time should at least be acknowledged. With a small database, the difference in efficiency will not be noticeable below a few milliseconds... but the overhead is still there, just on a smaller scale. And that's not even bringing into account all the extra code needed for flat databases to perform the identical task with SQL.

I'm not at all saying flat files are bad, but if you try to add any type of complexity to the app it can become a huge headache in comparison to SQL.

Last edited by Keith; 06-13-06 at 02:00 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Form to update a MySQL database? Scoobler PHP 9 09-04-08 02:41 AM
Can't connect to mysql in include file when included in forums Forse PHP 2 07-12-04 08:39 PM
Excel document containing records, need to save as a text file to upload to mysql bearslife PHP 1 06-05-04 04:24 AM
Flat File to MySQL - DB conversion? irfaan PHP 1 03-15-04 09:54 PM
how to import a png file from mysql database. rani PHP 1 01-16-04 04:34 AM


All times are GMT -5. The time now is 01:14 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.