Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6475031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:39:24+00:00 2026-05-25T06:39:24+00:00

I am setting up a database and am at a place where I am

  • 0

I am setting up a database and am at a place where I am confusing myself on some many-to-many tables. I am looking for some advice on the best way to design this for performance and scalability.

I will lay out an example of my setup and what I am trying to do below.

I have the main object table…

Account

AccountID| AccountName
-----------------------
   1     | First Account

…and then the child objects to be given permissions to.

Page

PageID | PageName
------------------
   1   | First Page

Control

ControlID | ControlName
-----------------------
   1      | First Control

MenuItem

MenuItemID | MenuItemName
-------------------------
    1      | Menu Item 1

I have a permissions table for read/write etc…

Permission

PermissionID | PermissionName
------------------------------
    1        | CanRead
    2        | CanWrite
    3        | CanDelete

So I’m trying to tie the permission table in a many-to-many between the main objects and the child objects. I will list below what I’ve come up with and why I don’t think it’s right.

One table to rule them all

PermissionAccount

AccountID | PermissionID | ControlID | MenuItemID | PageID
----------------------------------------------------------
      1   |     2        | NULL      | NULL       | NULL
      2   |   NULL       | 2         | NULL       | NULL

*this solution is just ugly. There can be many MenuItemID‘s assigned to a single account

One table for every object

PermissionAccountControl

AccountID | ControlID | PermissionID
------------------------------------
    1     |    1      |     1
    1     |    2      |     1

PermissionAccountMenuItem

AccountID | MenuItemID | PermissionID
-------------------------------------
    1     |     1      |     2
    1     |     2      |     1

PermissionPage

AccountID | PageID | PermissionID
---------------------------------
    1     |   1    |    3
    1     |   2    |    1

I am leaning more toward option two. Any thoughts or suggestions are appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:39:25+00:00Added an answer on May 25, 2026 at 6:39 am

    You could also use polymorphic association

    +------------+------------+----------+--------------+
    | AccountID  | ObjectType | ObjectID | PermissionID |
    +------------+------------+----------+--------------+
    |     1      | Page       |    1     |      1       |
    |     1      | MenuItem   |    1     |      2       |
    +------------+------------+----------+--------------+
    

    This method might be useful if you need to handle permissions for additional objects in your software at a later point of time. Then you won’t have to create new tables or add new columns in existing tables if you use this table structure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm setting up a database using PHPMyAdmin and many fields will be large chunks
I have been looking at the new database server we are setting up for
Some guys where I work are setting up a new database server for SQL
This might be wrong place to ask this question. I spent effort in setting
In an app that uses MongoDB, when/where is the best place to make database
I have a setting stored in database which has a value .jpg|.gif|.png . I
My database schema has a 'locked' setting meaning that the entry can not be
I am setting up a very small MySQL database that stores, first name, last
We have SQL Server database setup. We are setting up a replication scenarios where
I am re-using ListPreference for a setting which I store only in the database.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.