MySQL Forums
Forum List  »  Newbie

Are subtables possible?
Posted by: Mitchell Hove
Date: November 13, 2016 11:24PM

I can't wrap my head around this concept.

I have a database I've been working on and I'm to the point where I'm working on Items for a game. I have a master table with the attributes for every item: Item_ID, Item_Type, Item_Value etc....

I need to create a set of subtables based off of the Item_Type. For example, A 'WEP' type item would need to have the attributes of damage, accuracy, etc. While a 'ARM' type item needs attributes such as defence, class, etc.

If I use ITEM_ID as my foreign key for the weapons table, it puts all items in there and then every item has a damage attribute, but it doesn't make sense for everything to have that, only 'Item_Type of 'WEP'. Am I best off using the foreign key, but then leaving the attributes null on all other items? Or is there a way to have tables where the relationship is exclusive to certain items of another tables primary key, based on data from another attribute like Item_Type?

I don't know how else I would explain that. Any help or suggestions for solutions are appreciated.

Options: ReplyQuote


Subject
Written By
Posted
Are subtables possible?
November 13, 2016 11:24PM
November 15, 2016 12:51PM
November 16, 2016 06:20AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.