Results 1 to 8 of 8
  1. #1
    Join Date
    Feb 2012
    Posts
    4

    Unanswered: Organizing tables in access

    Hello I am currently studying programming and I am at my last year in my course. I have to make a database using access and I cannot get help from my teachers because it is my final project. Me and my teammates are making a small game in C sharp with XNA and for now I am trying to make a database that will contain informations about the items in the game and maybe more. I have made some table but I have reached a problem. I don't know if I should make many tables for my equipment like healing items and weapons or if I should separate them in different tables.

    For example, I have healing items that will give the main character some health back and I have weapons that deal damage.Both are items but do different things. Should I still keep them in the same table and for the damage field for the healing items put 0 or should I make different tables for both of them.

    Again I am fairly new to the database world and if my question doesn't seem as detailed as it should be, just ask and I will try to clear it up. Thank you in advance for any help I could get.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    for this app you probably need to look at the super/sub type model

    having a single table for each and every type of thing used in your game is asking for trouble. it means each time you want to add or remove a 'thing' it involves changing the db structure AND the application.

    mind you you could argue that healing and damage are two sides of the same (pardon the deliberate pun) sword

    if you can map your items into two categories then you could, mebbe, have two tables, but you must resist the temptation to have a separate table for each item type.
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Feb 2012
    Posts
    2
    I have not done a huge amount of DB design, so I am sure others can come up with a better solution. However, I would suggest 3 tables. One table for items, and one table for effects, with a linking table for all the effects that and Item could have.

    Have a one-to-many relationship from the items to the linking table, and from the effects to the linking table.

    Doing in that way, each item can have any number of effects, or none at all.

  4. #4
    Join Date
    Feb 2012
    Posts
    4
    By effects you mean items that could heal or do damage? And what would the linking table be like? I understand that the item table would hold, for example, the name and texture of the item and that the effect table would hold the information about what the item does like damage or healing but what would the linking table have? Numbers about how much healing or damage is done?

  5. #5
    Join Date
    Feb 2012
    Posts
    2
    Table1 - Items
    ItemKey - Primary Key for table - Unique Record ID
    ItemName - What ever you want to call it
    <other items> - any other data you want associated with an item

    Table2 - Effects
    EffectKey - Primary Key for table - Unique Record ID
    Effect- What ever you want to call it
    <other items> - any other data you want associated with an effect

    Table3 - ItemEffects
    ItemKey - Foreign Key to Table1
    EffectKey - Foreign Key to Table2

    The 2 items in Table3 can be indexed, but in that case should be defined as "Duplicates OK". You may want to add an extra key field to Table3 combining the 2 foreign keys to prevent an Item being linked to the same Effect more than once.

    Link Table3 to both Table1 and Table2. Table1 - 1 to many to Table3, and Table 2 - 1 to many to Table3.

    WIth this structure, an item in Table1 with 2 effects would have 2 records in Table3, with the same ItemKey, but different EffectKey fields. Similarily, and Effect could be applied to multiple items in the same way.

    The nature of the effect is defined in the Effects Table2.

  6. #6
    Join Date
    Feb 2012
    Posts
    4
    Thanks for the help! I have another question for you guys. Do you guys know how I could connect my access database to a c sharp XNA game application that I'm making? Or do you have a sites that could inform me? I've looked at a lot of sites for this and I can't seem to find the right info.

  7. #7
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Im guessing c# will connect through an ODBC connection/recordset
    so id you cannot find what you want on google then look in the help file

    strictly speaking this isn't an Access question, its more of a C# question and probably should be asked in the C section on this forum. how active that is with C# developers I don't know
    I'd rather be riding on the Tiger 800 or the Norton

  8. #8
    Join Date
    Feb 2012
    Posts
    4
    Ok thank you all for the help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •