Database Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesDatabase Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 5th, 2004, 12:18 AM
prometheus prometheus is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 1 prometheus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
db structure for navigational system

Hello:

I have a navigational system which I would like to store in a database and I want to know how I can structure my database so that it will be able to, in theory, keep track of an infinite level navigational system. Let me give you an example of what I am trying to model. Below is a sample menu:




[menu1]
[section1]
[item1_1]
[subitem1_1_1]
[subitem1_1_1_1]

[...]

[subitem1_1_2]

[subitem1_1_3]

[item1_2]

[item1_3]
[item1_4]

[section2]

[section3]
[section4]

Ok think of the above navigational menu as a web menu. Each section in the first level (I am not counting the [menu] part as a level) should ideally be able to have an infinite number of [items]. And each [item] should be able to have an infinite number of [subitems]. The way that I see the database set up so far is kinda like this:

Table Name: menu
columns: id, title, permissions

Table Name: section
columns: id, menu_id, text, permissions

Table Name: items
columns: id, section_id, menu_id, text, img_path, href, permissions....

Now I have a few more fields in each table but I think you guys get the basic idea. I feel pretty confident about my menu & section tables. However the problem lies in the "items" table, it does not make sense for me to keep track of each additional level of items or sub items in separate tables otherwise I could potentially (although it would be a menu with a poor taxonomy) end up with an infinite number of tables, so what i want to do is keep track of all items AND subitems in ONE table alone. is this possible? I thought of doing something like this:

Table Name: items
columns: uid, item_id, section_id, menu_id, text, href, img_path, permissions, parent_id

In this case the uid would be a unique id for each row in the table. And the parent_id would be a reference to the uid column, in that way you could keep track of each item's parent. HOWEVER, if you notice above, how I keep track of each level by numbering it, (ie. subitem1_1_1), well I need to use that numbering system in my implementation code. So i can't end up chasing links to other fields since I have to be able to build the "1_1_1" part for each item in the table in one simple call. Is there a way to do this? any help at all would be greatly appreciatted. thank-you!

~pman

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesDatabase Development > db structure for navigational system


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway