Flat Files Love 'em or Hate 'em?

C++, C#, Java, PHP, ect...
Post Reply
User avatar
Ravinos
Posts: 281
Joined: Tue Sep 15, 2009 4:14 pm

Flat Files Love 'em or Hate 'em?

Post by Ravinos »

I've been debating whether or not to use flat files for my combat text or use the database. What are your opinions about using flat files to save data?

For instance when a player attacks a mob it adds it to the flat file for the rest of his party to see. Every action the party takes is recorded along with loot, deaths, kills, and damage. Each party has a unique ID and unique combat text file.

Now the reasons for going the flat file route are:
a) less strain on the database
b) players will be able to "download" their combat text if they choose.
c) it creates a log for me to review and make sure nothing strange is going on.
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Flat Files Love 'em or Hate 'em?

Post by Jackolantern »

Flatfile does not work very well if multiple players are playing at the same time, since flatfile has no concurrency system. I am not sure about SQLlite, though, and that may be an option.

But then the problem is that flatfile puts more strain on the server. So you have to think of which one would go down first, the server or the MySQL database? In most cases, it is the server.
The indelible lord of tl;dr
Falken
Posts: 438
Joined: Fri May 08, 2009 8:03 pm

Re: Flat Files Love 'em or Hate 'em?

Post by Falken »

Here is a few reasons why you should NOT use a flat file for storing data:

1) Performance, String handling and reading from large files is extremely inefficient compared to getting a row in a database
2) Same time usage, remember that if someone is already reading/writing to a file, no one else can do that at the same time. This cause alot of delays and crashes. What if someone starts reading from a file and then for some reason not closes it correctly? It is locked, no one else can read from it and lots of stuff goes ka-boom :roll: .

If you are making a serious project, you should have BOTH MySQL and Flat files, altho the flatfiles works as logs, so you only write to them and never read from them except when something went wrong, in all other cases the MySQL database is used in the game/project.
--- Game Database ---
For all your game information needs!
Visit us at: http://www.gamedatabase.eu today!
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Flat Files Love 'em or Hate 'em?

Post by Jackolantern »

SQLlite is really the only thing that makes flatfiles even a consideration for main game storage. It fakes a bit of the functionality of a SQL database. However, the performance is still nowhere near a SQL database.
The indelible lord of tl;dr
Post Reply

Return to “Coding”