Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hello, I am planning a website

Status
Not open for further replies.

matejv

Programmer
Jul 30, 2003
14
0
0
SI
Hello,

I am planning a website and would like to bounce some ideas to perhaps get some new ones or get myself pointed in the right direction.

The goal and background are as follows:
- asp, access, vbscript
- table called "StructureElements" with the fields: ElementId (e.g. 020100), ElementName (e.g. Products), ElementHref (e.g. products.asp), ElementLinks (e.g. 030100#030102#040500# ...)

The ElementId has a 3x2 form code, because the elements are actually a part of a three-level navigation bar. The first two digits explain the position on level 1, the second two position on level 2 and the last two the position on level 3. For example if we would have on the first level, second place element called Products this would have ElementId 020000, then on the second level Cars (020100) and on the third Ford (020101).

On each sub-page I would have (among other) two sections:
- submenu,
- links.

For the first one I would make something like (if we were for example on the second level):

SELECT ElementName, ElementHref FROM StructureElements WHERE ElementId LIKE '02__00' AND ElementId NOT LIKE '%0000'

And then Response.Write the list with a Do... Loop.

For the links part I would do:
- get the links field,
- break it up
- put the links in an array
- make a do... loop with the SQL and get each of the links

This would also require me to either declare the ElementId of the page I am on or get it out of the db according to the title.

Am I complicating too much? Is there a simpler way to the solution?

It was suggested to me that this could be a case of bad db design, so I ask what are the dis/advantages of having the ElementId, for example, in three columns instead of one.

Also, would it be better to have the links in a separate table (e.g. Links) with a layout similar to the following exapmple:

ElementId / LinkId
1 / 5
1 / 11
1 / 24
2 / 33
2 / 6
2 / 7
... / ...

If so, I would really like to know why, so I can learn for future use.

Thanks for your views and help.
 
A question may help to demonstate why this may not be the best way to go.
----------------------------\\\///-------
say you have the site complete with a complex menu structue of, say, 10 level 1 elements,each with five level 2 elements, each with 5 level 3 elements. Now, what happens when you wish to insert a new level 1 element in the middle of this list?

Digital Soma
 
Hi, thank you for your post. I see your point... it would be a jumble.
Do you have any ideas about how to improve the 'Links' execution that I described?

Thanks
 
Ok, without sitting down and planning all this out on paper, which is really the way to go when designing your inital data structures, as so much of the later program will coalese around this.

Maybe some form of linked list would do the job (google this term)

i.e basic table struct

int listID // UNIQUE AUTO INCREMENT ID
int parentID // ID element of the parent of this item
// i.e one level above
int nextID // ID of the next element at THIS level

so, parentID is NULL for top level elements,
and nextID is null for elements at the end of the level list

rough pseudo-code might be

for each entry where parentID=NULL
obtain all records where parentID = this.listID
process each child node

The fun bit of all this is that simplest way to display a 'tree structure' like this is to use a 'recursive' function, which if your a normal person will melt your brain for a bit. Google on the above terms for plenty of examples though.

Digital Soma
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top