Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 Large database design

Author  Topic 

alik
Starting Member

1 Post

Posted - 2010-05-05 : 09:52:17
Hello,
I want to create a game for social network. The game's database must store information about users, their items and scores. It must be possible to add/extract scores and items QUICKLY, because there may be (I hope :)) a lot of players. I think my DB tables should be created like this:

CREATE TABLE users (
user_id UNSIGNED INT PRIMARY KEY,
score UNSIGNED INT
);

CREATE TABLE items (
user_id UNSIGNED INT PRIMARY KEY,
item_id UNSIGNED TINYINT
);

Also, can the users be added in a sorted (by score) order? If so, how to do that?

Any advices, suggestions about improvement and implementation will be highly appreciated.

dportas
Yak Posting Veteran

53 Posts

Posted - 2010-05-05 : 15:02:32
Welcome to the SQL Server forums. Unfortunately your code isn't valid in SQL Server! UNSIGNED INT isn't a supported type.

It also looks to me like user_id should not be the key of the items tables because that would mean you could only store one item per user.

quote:
Originally posted by alik
Also, can the users be added in a sorted (by score) order? If so, how to do that?


Tables have no order. A table is a set of rows. You need to specify the order when you query the table and display the results, not when you add the data.
Go to Top of Page

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2010-05-08 : 05:40:31
This looks like MySQL.
For design - based on your comments you need another table - Dealing with scores. This will give you more flexibility in the future regarding extra games etc.
For order - focus on the sql statements - and optimising the code.

Jack Vamvas
--------------------
http://www.ITjobfeed.com
Go to Top of Page
   

- Advertisement -