About .ini or flatfile database

05/17/2011 20:38 12tails#1
yo...

is there any issue with a .ini/flatfile database??
05/17/2011 20:59 pro4never#2
If done correctly then there's no reason a flatfile couldn't work just fine... but the real question to ask yourself is this..


1: Which is easier

2: Which is faster


The answer to both of those questions will 99 pct of the time be sql. The fact of the matter is. If flat file was 'better' then sql and other database systems would never have been invented.

Yes, sql could be slightly slower depending on how you use it and could pose issues... but again those only really pose an issue if you are using it incorrectly... and guess what! You face the exact same pitfalls using a flatfile database and give up all the advantages that sql brings such as lovely queries.


There are plenty of people who enjoy working with flatfile and when it comes right down to it, there's nothing 'wrong' with that... but I think anyone who looks into it very much will come to a conclusion that when used correctly and as intended a proper db system will outperform a simple binary/stream file when it comes to any serious data storage.


Now if you're dealing with static resources such as a magictype/itemtype or w/e there's much less encouragement to go with a db system other then the possibility of just using a linq type query to pull from db on use rather than storing the entire file structure in memory... In this case though I'm talking about say a character or item db that is crucial and is modified often.
05/17/2011 21:47 12tails#3
Ic...
Thanks for your advice pro ^^
05/17/2011 22:51 Korvacs#4
This is well documented really i've been over it loads of times >_>"
05/18/2011 03:41 InfamousNoone#5
Lets put it like this. The same reason .NET's "SuspendThread" method is deprecated is the same reason SQL was invented. It's more user-friendly and harder to make mistakes with.

People developing API have to assume their end users are mediocre programmers.
05/18/2011 15:28 unknownone#6
Performance, ease of use, preventing you from doing things wrong, etc. are all pretty valid reasons for using a DBMS, but there's a more fundamental reason you'd use one in the first place.

When you're trying to solve a problem, you should first try and specify what the domain of the problem is. In this case, it's quite obvious: our problem is that we want to implement a game server to emulate the functionality of official conquer servers so we can use the existing client more freely.

More specifically, the main problem is that of implementing the logic of a virtual world, specifying how virtual entities interact with eachother, blah, blah. In this problem domain, there is no mention of storage, because it isn't part of the problem. Storage is only one particular means of implementing the solution to the problem. We really need to consider storage to be it's own domain, separate from the domain of the game logic.

In a similar sense, we know that we need to communicate with the game client over TCP, using a protocol the client understands. This is part of our overall problem of making the game server, but it isn't really part of the primary problem domain: the game logic. In fact, the game logic doesn't need to know anything about the communication being used, in the same way it doesn't need to know about the storage being used. So likewise, communications should be in their own domain.

You might isolate some other problem areas into their own domains too. In the end, your overall problem domain has become more managable by breaking it up into sections that you can work with in isolation. The main problem domain of implementing game logic doesn't need to have the confusion of storage and communications associated with it. If we use a diagram to visualize this, it'll look a little like this, where the size of each of the subdomains are relative to the problem size (and how much code we should be writing for them.)

[Only registered and activated users can see links. Click Here To Register...]

This looks nice, but if we move onto the storage now, we can begin to consider how things will be stored. This could be quite simple if we just vomit our data onto the hard drive without any consideration as to whether the data we are writing is sensible, but the chances are that will come back to bite you later. In order to make sure that we are writing sensible data, we need to write sensible code to store it.

When it comes to writing that sensible code though, you soon find out that it is not simple, except for the most basic of data being stored. Whenever you are storing non-trivial data, there's a lot of boilerplate code you need to place to ensure you're doing things properly, efficiently and in a modular way, so we can make the most of the code. If we do this, and do it right, our overall problem now looks a bit like this:

[Only registered and activated users can see links. Click Here To Register...]

The problem is quite clear isn't it? Our problem of "emulating a game server" has now become a problem of data storage. Our solution has been overtaken by something that wasn't even part of the original problem, and we are going to waste a lot of resources doing it this way.

So the reason we use a DBMS is so that we can focus on the domain of our problem, and not one of storage. The DBMS themselves are projects which focus on the domain of storage, and they do it very well - in an abstract way that is easily reusable from other applications. These DBMS systems have millions of lines of code to make sure they're doing things right, and doing them well - you could never hope to match them in a specific implementation of any non-trivial data.