how to build db for using in listboxes in ASP

Discussion in 'Databases' started by gilgalbiblewheel, May 10, 2006.

  1. #1
    I want to have a database on a book where this is how it goes:
    Preface
    Introduction
    -subtitle1
    -subtitle2
    Chapter 1
    -subtitle 1
    -subtitle 2...
    Code (markup):
    I have MSAccess 2000. How do you recommend me to build it? I want to use it with a combination of listboxes in ASP.
     
    gilgalbiblewheel, May 10, 2006 IP
  2. jaymcc

    jaymcc Peon

    Messages:
    139
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You seem to have a chapter to section relationship, only 2 levels, 1 for the chapter and 1 for the section or subtitle as you call it.

    I would create the following:

    Table: Chapters
    ID - Autonumber
    Name - String(255)

    Table: Sections
    ID - Autonumber
    ChapterID - LongInt
    Name - String(255)

    Then relate the chapterID field in sections to the id field in chapters. This will work well if only 2 levels, if 3 or more there is another way I would do it.

    BTW: The mention about listboxes confused me a little, a tend to look at the raw data and the best normalised way of storing the information regardless of the format of how it will be presented on screen. Is there something specific about the interface that is forcing you to change your data structure?

    Hope this helps.

    J
     
    jaymcc, May 10, 2006 IP
  3. gilgalbiblewheel

    gilgalbiblewheel Well-Known Member

    Messages:
    435
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #3
    Oh. In that case then make three or more.

    Introduction-
    |
    - title-
    |
    -subtitle
    Chapter 1-
    ...
     
    gilgalbiblewheel, May 10, 2006 IP
  4. DanInManchester

    DanInManchester Active Member

    Messages:
    116
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #4
    Depending on how distinct thetypes are for introduction, title, subtitle, etc are you could roll it up into one table.

    tbl_Contents
    ContentID (primary key)
    ParentContentID (foreign key)
    ContentName

    This would allow you to represent the full hierachy in one table that is self referencing.

    Obviously if title is hugely different to say the chapet then you would probably need a separate table but if all you want to do is list the names of each part then this would probably be the most sensible approach.
     
    DanInManchester, May 11, 2006 IP
  5. jaymcc

    jaymcc Peon

    Messages:
    139
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I would recommend what DanInManchester suggests if you have more than 2 levels, This great greater flexability in design and heirarchy etc. It's a little more work programatically sometimes (cause you never really know how deep the level go, they could go forever) but it IS a better way of doing it.

    Jay
     
    jaymcc, May 11, 2006 IP
  6. gilgalbiblewheel

    gilgalbiblewheel Well-Known Member

    Messages:
    435
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #6
    Is there an online tutorial that explains this? Because I don't know how to work this out. I don't understand what you're explaining.
     
    gilgalbiblewheel, May 11, 2006 IP