School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,033 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,257 people online right now. Registration is fast and FREE... Join Now!




How to create a DB for navigation menu

 

How to create a DB for navigation menu

ptamzz

21 Jun, 2009 - 12:13 AM
Post #1

D.I.C Head
**

Joined: 4 Mar, 2009
Posts: 65



Thanked: 1 times
My Contributions
I want to create a DB (or multiple DBs) if reqd so that there are columns for submenus, that if a user adds a submenu, it is automatically added and if the user adds a submenu under that submenu, it is also added. Provided we dont have any information to how many submenus it will go on.

say suppose, we have this navigation

CODE

Home
Departments
--CSE
-----Department
-----Faculty
---------Mr A
---------Mr B
-----Labs
-----Library
--ECE
--Mech
--Elect
Contact
--Admin
--Director


The above navigation is an example. say suppose if i want to add another submenu under CSE>FACULTY, there is a place for that in the DB. Or if i want to add a submenu under CSE>FACULTY>MR A>m there is also a place for that in the DB. It may go on and on, i may want to add another submenu under CSE?FACULTY>MR A>SUBMENU>SUBMENU....

User is offlineProfile CardPM
+Quote Post


noorahmad

RE: How To Create A DB For Navigation Menu

21 Jun, 2009 - 12:17 AM
Post #2

Webmaster
Group Icon

Joined: 12 Mar, 2009
Posts: 2,087



Thanked: 142 times
Dream Kudos: 1350
My Contributions
*** Removed ***
Check Bellow.
Add Reply Button Was Pressed and it was uncompleted.

This post has been edited by noorahmad: 21 Jun, 2009 - 12:25 AM
User is offlineProfile CardPM
+Quote Post

ptamzz

RE: How To Create A DB For Navigation Menu

21 Jun, 2009 - 12:20 AM
Post #3

D.I.C Head
**

Joined: 4 Mar, 2009
Posts: 65



Thanked: 1 times
My Contributions
but how do i know that the particular submenu added is under which parent menu???
User is offlineProfile CardPM
+Quote Post

noorahmad

RE: How To Create A DB For Navigation Menu

21 Jun, 2009 - 12:22 AM
Post #4

Webmaster
Group Icon

Joined: 12 Mar, 2009
Posts: 2,087



Thanked: 142 times
Dream Kudos: 1350
My Contributions
I Will Give You The idea,
tblMainMenu
---MenuID //Auto Increment.
---MenuName //Text For showing in Navigation
---PageID //Page Id from Your tblPages
---Submenu //Yes-No

tblSubMenu
---SubMenuID //Auto Increment
---MenuID //Menu ID from tblMainMenu
---MenuName
---PageID
---Submenu //Yes-No


tblSubeMenu2
---SubMenu2ID
---SubMenuID //SubMenuID from tblSubMenu
---MenuName
---PageID

and i am using these tables for My Websites.

Hope it Helps You smile.gif

This post has been edited by noorahmad: 21 Jun, 2009 - 12:25 AM
User is offlineProfile CardPM
+Quote Post

ptamzz

RE: How To Create A DB For Navigation Menu

21 Jun, 2009 - 12:28 AM
Post #5

D.I.C Head
**

Joined: 4 Mar, 2009
Posts: 65



Thanked: 1 times
My Contributions
ok..thanks.. i get it.

thank u very much.
User is offlineProfile CardPM
+Quote Post

noorahmad

RE: How To Create A DB For Navigation Menu

21 Jun, 2009 - 12:44 AM
Post #6

Webmaster
Group Icon

Joined: 12 Mar, 2009
Posts: 2,087



Thanked: 142 times
Dream Kudos: 1350
My Contributions
Your Welcome. smile.gif
User is offlineProfile CardPM
+Quote Post

baavgai

RE: How To Create A DB For Navigation Menu

21 Jun, 2009 - 03:58 AM
Post #7

Dreaming Coder
Group Icon

Joined: 16 Oct, 2007
Posts: 4,348



Thanked: 411 times
Dream Kudos: 550
Expert In: C, C++, Java, C#, ASP.NET, PHP, Perl, Python, Oracle, SQL Server, MySql, HTML, JavaScript, Lua, Cheese

My Contributions
Making a table for each new level is wasteful. The application is where you worry out presentation, not the data layer.

You can model a navigation map in one simple table:
CODE

nav_item
    nav_item_id
    label
    url
    sequence
    parent_id


Here, I've made NULL top level.
CODE

1,Home,http://www.foo.com/,100,NULL
2,Departments,,200,NULL
4,CSE,,100,2
10,Department,,100,4
11,Faculty,,200,4
14,Mr A,,100,11
15,Mr B,,200,11
12,Labs,,300,4
13,Library,,400,4
5,ECE,,200,2
6,Mech,,300,2
7,Elect,,400,2
3,Contact,,300,NULL
8,Admin,,100,3
9,Director,,200,2


You want a list of everything under departments?
sql

select a.nav_item_id, a.label, a.url
from nav_item a
where a.parent_id=2
order by sequence



User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 08:36AM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month