Sign in to follow this  

Database Structure - Multiple Rows or Serialisation

This topic is 2547 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What sort of structure should I use with my database? I'm planning to use MySQL, and have a table for every type of thing that needs stored, like this:

table items(ID, items) - Stores the items that a player owns

example row:
1012, (serialised items array)

Alternatively, I could have a row for each item owned:

table items(ID, itemID)

example rows:
1012, 1
1012, 5
1012, 98

(ID 1012 owns 1, 5, and 98)

Which approach is better, and more importantly, why?

I know that MySQL is very forgiving, I owned a private server(well multiple connect) 1000 users online max, and it didn't lag, single table with ID, name, crumbs (crumbs = serialisation of ALL player data) Obviously, that wouldn't scale.(Unless I'm reeeaaallly wrong)

Any recommended reading on this subject?

Thanks in advance.

edit: Should I have placed this in General Programming? If you are a moderator and you see this, please move it, if I am correct in the belief that it should be moved

Share this post


Link to post
Share on other sites
From a design point of view normalisation is preferable over custom serialisation. This would mean splitting your data over multiple tables, e.g. A Player Id to Item ID table, Item ID to property table, etc.

There are several benefits of normalisation, which I won't list here, you can read them up in any database textbook or on Wikipedia.

There is one particular benefit, however, that you might be interested in: flexibility. Say you want to change certain item properties or add/remove/change items on the fly. Instead of wading through all your player's data you can simply modify the items table directly and have the change propagate automatically.

In case you encounter performance issues you can denormalise the data back at any time so the decision to split the data up is not a one-way road.

Share this post


Link to post
Share on other sites

This topic is 2547 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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