Jump to content

Question about the foreign key relationship between tables.


Murphdog

Recommended Posts

This is my first attempt at creating a database from scratch so please forgive me.

Lets say i have 40,000 items, sepearted by 8 categories (that can be seperated by additional sub-categories like male/female and armored/shielded/enhanced/none). Is it better to create a table for each of the 8 categories, or Create 2 tables, 1 for the 8 categories and 1 for the 40,000 items? More tables for the sub-categories?
(on a side note, each item has almost 50 different attributes so eventually, hopefully, they will be able to be searchable/queried)

I'm guessing the 2 table way would be more streamlined.

Maybe I'm a little confused as to which way to do this, but I have read that there really isn't a wrong way.

To help you understand, here is what I want to have...
8 categories separating types of clothing, seperated by sex, sepearated by Buff Types, separated by attribute (gamers know what this is and there are close to 50)

If I have confused anyone I'm sorry. I am too.

Now if I do use the 2 table way I described above, is it a requirement that the foreign key be INT and aut-incremented? This is the main reason why I'm posting. For some reason i thought ENUM would be better but I'm not so sure.

Thanks for any help
Murphdog
Link to comment
Share on other sites

You could use ENUM for simple things like Male/Female. But it sounds like you have a lot of branching (if its male you have one type, female another.)

I wouldn't do a two table approach. The best way is to figure out how to best organize your main table (each individual piece of clothing) and work backwards from there.

I'd make that table look something like this:
-id (autoinc INT) <- not required btw but makes life much easier
-description
-garment_id
-armor_id
-buff_id
-color_id

Make a garments table:
-id (autoinc INT)
-description ('polo shirt')
-gender (ENUM 'male','female','unisex')
-type_id (use a garment_type table with entries like "pants","shirts","hats",etc)

For attributes, it sounds like there is a 1 to many relationship (the same shirt could be 'warm', 'fuzzy','plaid','buttoned', who knows)
So you would all of those attributes in a table then add another table to link those attributes with a specific garment_id.
Link to comment
Share on other sites

I thought I would post a little more.
Here is a rundown of the categories and how the items could all differ. Clothing names and attribute lists have been shortened for sake of the discussion.

category            clothing name        sex            buff type        attribute
------------|    -----------------|-----------|-------------|----------------
pants        |    abt 40,000 of    |  male      | None          | Ballistic Resistance
shirts          |    them. Many with | Female    | Armored      | Confuse Duration Bonus
shoes          |    the Same name |                | Shielded      | Melee Resistance Bonus
leggings      |                            |                | Enhanced    | etc about 45 more of these
hats            |                          |                |                  |    attributes
outerwear    |
sunglasses    |
gloves        |
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.