Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 25th, 2009, 04:17 PM
almo2001 almo2001 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2009
Posts: 99 almo2001 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 5 h 8 m 46 sec
Reputation Power: 1
Database design question: users, items, collections

Hi!

We have users, and they are kept in a table. We have items, which have statistics and are kept in another table (actually a set of tables related by foreign keys).

As users play our game, they collect items, and they can have multiple copies of an item. I was thinking that we'd need a table with these columns: user_id, item_id, num.

I would then use a composite key using user_id and item_id.

Here's my question. The items are actually divided up into types: creatures, rooms, traps. As such they have completely different statistics, and are kept in different sets of tables.

This means I'll need to keep the IDs unique across types, or have seperate tables for the user's collections of different types of items. That's all fine, too. But I want to use foreign keys to keep everything clean, and I guess that means all of these things are stored in one database.

For some reason, it feels like users and their information should be kept in one DB, creatures in another, rooms in another, and traps in another.

Am I completely off base here? Should I feel fine storing all these different types of info in the same DB?

Reply With Quote
  #2  
Old May 25th, 2009, 10:20 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 20,687 r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 1 Week 3 Days 9 h 27 m 54 sec
Reputation Power: 2458
Quote:
Originally Posted by almo2001
Should I feel fine storing all these different types of info in the same DB?
yes, you should

one database, different tables
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book

Reply With Quote
  #3  
Old May 26th, 2009, 09:27 AM
almo2001 almo2001 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2009
Posts: 99 almo2001 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 5 h 8 m 46 sec
Reputation Power: 1
Ok, thanks a bunch. As I'm new to SQL stuff, I imagined keeping absolutely EVERYTHING in the same DB might be a noob mistake.


Reply With Quote
  #4  
Old June 4th, 2009, 08:47 AM
almo2001 almo2001 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2009
Posts: 99 almo2001 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 5 h 8 m 46 sec
Reputation Power: 1
Quote:
Originally Posted by almo2001
Ok, thanks a bunch. As I'm new to SQL stuff, I imagined keeping absolutely EVERYTHING in the same DB might be a noob mistake.



Ok, I have a DB with 18 tables, and it seems to work. I made a user, who had a castle, the castle had a room, and the room had a creature and a trap. I deleted the user, and all those entries were removed by the foreign key relations, but the room, creature and trap templates remained.

I'll be having a DB expert here at the company check the structure to make sure I haven't done something really stupid.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Database design question: users, items, collections


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
Stay green...Green IT