PDA

View Full Version : how to build db for using in listboxes in ASP



gilgalbiblewhee
10 May 2006, 05:21 PM
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...
I have MSAccess 2000. How do you recommend me to build it? I want to use it with a combination of listboxes in ASP.

DanInManchester
17 May 2006, 05:19 PM
Didn't you already post this ?

I'd do something like this depending on how different each level is

tbl_Section
SectionID (primary Key)
ParentSectionID (foreign key)
SectionName

data would be stored like this :

1 0 Preface
2 0 Introduction
3 2 -subtitle1
4 2 -subtitle2
5 0 Chapter 1
6 5 -subtitle 1
7 5 -subtitle 2...

To get all the top level sections you would do

SELECT * FROM tbl_Sections WHERE ParentSectionId = 0

An alternative aproach where you want differnt information depending on the level would be to havea separate table for the top level and sub levels.