Recursive Table Hierarchy?

  • I am working on a OLTP system that will be used for online gaming. The struggle I am having deals with how i should setup my Class table. to understand the system better I'll give you a high level over view of the structure so far.

    The game consists of Characters who can choose between different classes based on their current level. For example if I create a new character named Envision then my default class will be "beginner" once I have reached level 10 i can be promoted to a class that i desire (There will be classes to choose from). Under each class there will be a hierarchy of which path they wish to go down (again based on the level). For example, If Envision reaches level 10 he can become a Bowman, once he reaches level 30 he has a choice. He can choose the path of a Hunter or a sniper, once his level reaches 70 he can become a ranger if he had chosen the path or ranger or he can become a sharpshooter if he had chosen the path of the sniper. And this continues for 1 more advancement once they reach level 120.

    Currently I have a Character class TABLE, and a Job Class TABLE. Since the column Level is depending on both the Job and the Character would it be wise to place that in a separate table? or should i have the column placed in with the character table?

    Also, When i get up my tables for the job advancements would it be practical to store them within a table as a hierarchy structure or, should i be breaking them down into further tables?

  • Since you start "from scratch" you might want to consider storing the hierarchy data as nested sets. For details please search for "Celko nested sets hierarchy". It might be a faster concept compared to the "standard hierarchy".

    Or, if you use SQL2008 you could use the hierarchy data type.



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • You do not describe anywhere what the differences and relationships are between a character-class and a job-class. We cannot really answer your question without knowing that.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • I'd have a table of prerequisites, most likely. Lists "If you are" and "then you can become".

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Thanks for all your input so far guys.

    To address the relationship between the character table and the class table.

    Each character can be assigned 1 class per level range. For example. If My character name is Sharp and he is level 10 then he can pick from a range of classes. So, this is a many to many relationship that addressed through another table called Char_class which will host the primary keys of the 2 tables as foreign keys.

    So my structure is as follows

    CharTable (CharId, CharName,DateCreated)

    Char_Class (CharId, ClassId)

    ClassTable (ClassId, ClassName)

    What i thought of doing was having a level table with a PK that would be referenced by the Char_class Table, but I'm not sure if that would be an optimal solution?

    Furthermore i struggle with the hierarchy of classes that still needs to be invoked, and how i can address the issue. I'm thinking at this point the "snow flake" structure would be better than a hierarchy structure.

    Hope this help!

    thanks in advanced!

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply