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.
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
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.
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
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.