Best practice for Permission database structure in a 3 Level Menu


I need to create a Menu with 3 level in my web application and I want to be able to manage permission for every item in any level.

Can someone tell how should I build my database structure and queries to do so.

Ex :

      |_ Menu1_1
      |_ Menu1_2
      |_ Menu2_1
      |_ Menu2_2
                 |_ Menu2_2_1

I want user1 to have access to everything in Menu1 but only Menu2_1 of the menu 2
I want user2 to have access to Menu2_2_1 in Menu2_2 but not Menu1 and Menu2_1

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sounds complicated. Will the user with no permissions still be able to see the forbidden menu items?
If not then you could have all the menu items in a table and a column within that table that has a security level.
A separate user table could also have a column that notes their security level.
Inner join these tables on security level and you have your menu item.
Then you have to work out how to build your page around the menu items that may or may not be in your SQL results.

If you show the menu items regardless of the current users permission then you could put the permitted items in an array along with their URLs and give the permitted menu items an <a href> tag.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.