|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#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? |
|
#2
|
||||
|
||||
|
Quote:
one database, different tables |
|
#3
|
|||
|
|||
|
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.
![]() |
|
#4
|
|||
|
|||
|
Quote:
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. ![]() |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > Database design question: users, items, collections |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|