Jump to content

Ways of storing data...


Kryptix

Recommended Posts

So I have a friend system, it's just a table with 2 columns: user (int), friend (int)

 

Now it currently has over 2 million rows and seems pretty pointless having a row per entry because the data doesn't need to be searched in any way. The data doesn't need to be joined or anything.

 

I'm considering adding a new column to the users table called 'friends' and just store the data like: <FRIEND ID>;<FRIEND ID>;<FRIEND ID>;<FRIEND ID>;<FRIEND ID>;<FRIEND ID>;<FRIEND ID>;

 

Is this a bad idea? Which would use less disc space and/or be more efficient?

 

When you login to the game all it currently does is:

 

result = db.getQuery("SELECT * FROM `friends` WHERE `user`= '" + userID + "'");
while (result.next())
player.addFriend(result.getInt("friend"));

 

So instead of that I'd just use Java's equivalent of PHP's explode() looping through the ID's and adding them.

 

If there's no problem in doing this, which data type is the best to use for this kind of stuff?

 

As I said there's literally no other usage, I will never need to use the friend system for anything else except from the above code.

Link to comment
Share on other sites

Hi

 

Seems a bit strange to have a table of ID fields (which are basically meaningless) and to never join these to a table of people to get a meaningful value for them (such as name). And if you do get the value you either need to use a join (efficient), do an extra query (inefficient) or do a query per row (hideously inefficient).

 

All the best

 

Keith

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.