Sign in to follow this  

Data persistence?

Recommended Posts

Hello Again All,

Third question. This time I was wondering if anyone had anything good or bad to say on the subject of data persistence?

I am currently writing my coding masterpiece in Java, and while the Serializable interface/File Storage does offer a simple yet easily to implement method of storing objects. I know that long term/larger scale I am going to need to look at Database support or some form of XML but (I think) that is nearly the same as File Storage and to be frank......parsing XML is a pain in the arse and I can imagine creating classes/methods to write the files isn't much fun either :-)

So at the moment the options open to me are either an SQL relational database or DUM DUM DUM!!!!! The dreaded object relational database.

I was just wondering if anyone has any preferences? Thoughts? Random abuse they would like to throw my way :-)

I appreciate all the help and support I have received thus far. My little project is fair coming along. I may even have something to show in a couple of weeks.

So thank you and later

Share this post

Link to post
Share on other sites
What is your project? What kind of storage needs does it have? Size? Speed? Reliability?

The different approaches exist for a reason - there is no silver bullet.

Java serialisation is good for a quick dump/retrieve of data, and sharing between Java processes. XML is great as a general data interchange format, but is verbose and unnecessary otherwise. Relational databases are great for ACID stuff. I have no direct experience with object databases.

Tell us what you want your persistence layer to handle, and then we can give informed advice.

Share this post

Link to post
Share on other sites
Yeah that probably would be a good idea :-)

Basically I am trying to write an on-line Role Playing Game. Before I get the "Why you cant write an MMORPG "speech I'm not trying to, honest. Its more akin to a good old fashioned MUD.

This game has no graphics, text only and will have a maximum number of six players. Imagine playing an old fashioned text adventure as a party/group instead of by yourself.

I am just looking for a way to retain the state of the other locations within the game when the aren't players within them. The way my engine works, is it allows Dungeon Masters (Well me and my mate) to add new locations etc. to the game at will. To plug in new monsters, treasure etc. In essence a infinitely expandable world.

With each location, character, item etc being an object. However, the game would pretty much collapse (Or crawl) if every object existed in memory at the same time. So I want the game to load only so much of the dungeon at a time from a central database. This should hopefully keep everything running at a descent speed.

This whole project is more a "My freinds and I having fun" than I am going to write the new WOW and become rich. MWHAHAHAHAHAHAHAHAHA!

Although it may evolve into the Honours Project for my degree if the code continues to flow like this :-)

Thanks for the help and I hope this makes some form of sense.

Share this post

Link to post
Share on other sites
Sounds cool. I'd probably use an ACID supporting relational database for this. That way if your server crashes you shouldn't lose the data. XML and other formats are far more brittle - though you can take steps to make them less loss prone.

For example, write the data to a temporary file, then do an atomic filesystem rename to "swap" the data into your persistent store.

But still, loading a subset of data is harder to manage with something like XML or Java serialisation. With a relational database you can just fetch the rows that match the area you are in, and the surrounding area.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this