Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / text file v. database question, please

Author
Message
Dracula
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: DBP Recreation of Castle Csejthe
Posted: 26th Oct 2006 15:29
Before I choose one or the other and begin the coding, could you experts please give me your opinion on whether a text file or database file is preferrable for speed and manageability for storing data. If a DB is preferrable, will DBP access ODBC (MS Access) files? If so, is there some coding examples of this? I am comfortable with manipulating text files, but I've only used ODBC access (I hope I am getting the acronym right) with HTML and ASP.

Any insight is appreciated!!

D
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 26th Oct 2006 17:17
It depends on the amount of data you intend to process. If it's 10 names, then a text file will suffice. If it's 10,000 character structures, you need something more substantial.

You also have other alternatives, like Lua tables.



CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 26th Oct 2006 20:48
yes it depends on the data

i have database plugins for mysql, access, and sql server on my site

Free Plugins|Apps|Utils by CattleRustler

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 26th Oct 2006 23:00
Personally, I'd go for files almost every time. For the majority of queries in a game, you'll spend more time actually decoding the SQL commands than actually retrieving the data itself.

I wouldn't use LUA if this was the only thing it was being used for, but if you were including scripting, then that would be the way to go. The alternative is to hold your data-structures in memory and access them directly as needed. But that starts to move out of the newcomer territory ...

There's also a free plug-in on my site (the INI plug-in) that allows INI files to be used to hold data, and even for memory-based storage.

Dracula
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: DBP Recreation of Castle Csejthe
Posted: 27th Oct 2006 03:25 Edited at: 27th Oct 2006 03:37
Perhaps I should be more specific with what I am doing. I am working on a RPG and I am going to make separate tables/databases for npcs/mobs, items/weapons, and spells (maybe other types as well). These types will have several variable statisitics, so each items could have 5-20 fields. There could be 10 or 20 npc/mobs (more at some point), a great many items, and hopefully 20 or so spells. I will definitely use files for saveing the game, but with the amount of possible info in the files, I was thinking a DB file would be best. Ian, will the INI files allow for this? CattleRustler, what is the .NET framework needed to run the Access DB?

Thanks for all your input!!

D
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 27th Oct 2006 05:28 Edited at: 27th Oct 2006 05:33
Yes, the ini files...that's the ticket. I bolted on the registry before because of security, and what not...but ini files are great for all kinds of stuff.

I agree. Databases are really good when your application warrants them, but they are way overused. Your program knows its own data formats, and that makes it the best solution most of the time. BASIC languages actually mimic database engines with their file access using UDTs. The indexing is one-dimensional, but...you can move file pointers without reading the file, so it is a wash.

Access to the Jet engine is the most straightforward....definitely better than ODBC, which is very generic and requires alot of setup the Jet does not. Jet is what MS-Office products have used. ODBC is an attempt to allow access to any type of database. Jet is pretty nice for small scale databases that do not attempt to be everything to everyone. Your program should use text anyway, imo. Actually, you can use Jet with text files and get the database advantage without needing a database manager separate from the game.

...but, you will need to access this through the use of dlls, and actually...you are better off keeping all of the database specific stuff in your own dll, but that is just my opinion.

Personally, IanM's ini code sounds like the best place for it. You can do quite a bit of database oriented design in a text file. Look at win.ini, for example. That is pretty much where the registry started, and look at where that has gone.

Also, DBPro can read and write pk3/zip files, and memblocks to/from disk.
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 27th Oct 2006 14:35
those plugins are written in .NET so the framework would be required on any machine that runs an exe that calls the plugin.

good luck with your endeavors


IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 27th Oct 2006 15:30
If you need to do searches, then my INI plug-in won't help much. Other than that though, you can use INI files of the following format maybe:



This could map directly into a typed array:


... or something like that, at least. Basically, play around and see if you can do something that fits your needs.

Dracula
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: DBP Recreation of Castle Csejthe
Posted: 28th Oct 2006 05:13
Thank you for all the feedback. I appreciate it. Ian, I will play around with your .ini plugin and see what I can come up with. Jinzai, could you please explain how one can move a file pointer without reading a file using DBP? You mean by knowing how many fields are in a record you can use a loop to jump through records looking for a header, without reading each and every field? It sounds like it might be a good bet, if so.

Thanks again!!

D

Login to post a reply

Server time is: 2024-11-26 07:52:13
Your offset time is: 2024-11-26 07:52:13