Database design issue

  • I am using sql server 2008. I am building a website in ASP.net and querying my db. I have a table called "groups" and it contains 2 columns among several others. However only these 2 columns are of primary importance to me right now.

    col1 is a string and the length of which denotes a level. Example, "GRD" denotes that this node is at level 3 because length(GRD) = 3 and so on.

    col2 is also a string which is just a description , like "Grid is Open". nothing more to it.

    Now this is a live site which mean that I cannot change any records in the table. However I can insert a new column in this table. I want to achieve the following:

    display NEW level 2 nodes on my webpage. NEW means that I do not have them in the table yet but will need to somehow incorporate them. I cant insert a record but I can create a new column and use it. I now have a design/implementation issue as follows:

    If a insert col3 with new strings in it (for the the description as in col2) how do I relate it to the col1 levels? Also I am not able to explain here but if needed please tell me if you guys need more info on the table. The col1 also has string like U" and "TH" in it to denote the code and levels 1 and 2 of the node under which my level 3 nodes would be displayed. I hope that my question is clear.

  • virpan_17 (10/26/2010)


    I hope that my question is clear.

    As mud.

    Alright, you have a table. Col1 is varchar with an assumed column indicating level that's calculated by LEN(Col1). Easy enough. Col2 means... nothing, other then a descriptor. So we don't care.

    display NEW level 2 nodes on my webpage. NEW means that I do not have them in the table yet but will need to somehow incorporate them.

    You find these level 2 nodes from where? We've described one table... well, kinda described... and this record isn't in there. So, where are you getting it from to compare?

    After that, you're simply going to check the current table's Col1 (say, with an 'exists' or 'left join') and see if the Level 2's you've got are in the table. Considering you're comparing Varchar to varchar... you don't even care that they're level 2's, except for how you're going to extract them from the source.

    I think that will answer your question for what information we actually have. Otherwise, schema and sample data, as seen below in the links in my signature, please. You're trying to be careful and cagey about your actual data and schema in public. I understand. Also understand that vague descriptions get vague answers.


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • virpan_17 (10/26/2010)


    I am using sql server 2008. I am building a website in ASP.net and querying my db. I have a table called "groups" and it contains 2 columns among several others. However only these 2 columns are of primary importance to me right now.

    col1 is a string and the length of which denotes a level. Example, "GRD" denotes that this node is at level 3 because length(GRD) = 3 and so on.

    col2 is also a string which is just a description , like "Grid is Open". nothing more to it.

    Now this is a live site which mean that I cannot change any records in the table. However I can insert a new column in this table. I want to achieve the following:

    display NEW level 2 nodes on my webpage. NEW means that I do not have them in the table yet but will need to somehow incorporate them. I cant insert a record but I can create a new column and use it. I now have a design/implementation issue as follows:

    If a insert col3 with new strings in it (for the the description as in col2) how do I relate it to the col1 levels? Also I am not able to explain here but if needed please tell me if you guys need more info on the table. The col1 also has string like U" and "TH" in it to denote the code and levels 1 and 2 of the node under which my level 3 nodes would be displayed. I hope that my question is clear.

    Ok... let me rephrase it.

    Shall I understand you have a table where you cannot "update" but you need to somehow let the system know that a particular row has a NEW value, is that correct?

    If this is correct this pretty much defines what we call SCD (Slowly Changing Dimensions) of the Type 2

    The general idea is that a particular col1 row changes the value of col2 over time. SCD Type 2 solves the issue by tracking the changes and exposing the newest one by default.

    Plenty of documentation in the net, just bing "slowly changing dimension type 2"

    Hope this helps.

    _____________________________________
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at Amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
  • Also I am not able to explain here but if needed please tell me if you guys need more info on the table.

    Yes, more info would help a ton. Please post your table DDL along with some sample data (in a readily consumable form) that demonstrates your dilemma. See the article in my signature line for etiquette on posting sample data.

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

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

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