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 304163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:15:18+00:00 2026-05-12T07:15:18+00:00

I’m creating a blog, and am storing user permissions (to post/edit/delete blog posts) in

  • 0

I’m creating a blog, and am storing user permissions (to post/edit/delete blog posts) in a mysql table.

Should I create one column per permission, or combine all percussions into a string in one column such as 101 would mean that a user could post and delete but not edit.

The reason I ask is that I am worried about having too many column in my table.

  • 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-12T07:15:18+00:00Added an answer on May 12, 2026 at 7:15 am

    First of all, I would rule out combining all permissions into a single field. It seems economical at first, but it can turn into a bit of a problem if you will ever need to expand or modify your permissions structure.

    Creating a column for each permission in the user table is a good design for a simple system, but may limit your future expandability.

    I recommend implementing a many-to-many relationship between users and permissions. This allows you to add as many types of permissions you want without changing the schema. It is very easy to query with a simple join, and is portable to other databases.

    You accomplish this by creating two new tables. Assuming the following schema:

    CREATE TABLE `users` (
        `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
        `username` VARCHAR(100),
        -- other user fields --
    );
    

    We can add the m2m permissions schema like this:

    CREATE TABLE `permissions` (
        `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
        `name` VARCHAR(50) NOT NULL UNIQUE,
    );
    
    CREATE TABLE `users_permissions` (
        `id` INT NOT NULL AUTO_INCREMENT PRIMARY_KEY,
        `user_id` INT NOT NULL,
        `permission_id` INT NOT NULL 
    );
    

    You might then add some sample users and permissions:

    INSERT INTO `users` (DEFAULT, 'joe');
    INSERT INTO `users` (DEFAULT, 'beth');
    INSERT INTO `users` (DEFAULT, 'frank');
    
    INSERT INTO `permissions` (DEFAULT, 'Administrator');
    INSERT INTO `permissions` (DEFAULT, 'Write Blog');
    INSERT INTO `permissions` (DEFAULT, 'Edit Blog');
    INSERT INTO `permissions` (DEFAULT, 'Delete Blog');
    

    And finally you can associate users with permissions like so:

    -- joe gets all permissions
    INSERT INTO `permissions` (DEFAULT, 1, 1);
    INSERT INTO `permissions` (DEFAULT, 1, 2);
    INSERT INTO `permissions` (DEFAULT, 1, 3);
    INSERT INTO `permissions` (DEFAULT, 1, 4);
    
    -- beth can write and edit
    INSERT INTO `permissions` (DEFAULT, 2, 2);
    INSERT INTO `permissions` (DEFAULT, 2, 3);
    
    -- frank can only write
    INSERT INTO `permissions` (DEFAULT, 3, 2);
    

    For a smaller blog, you may not need a flexible schema like this, but it is a proven design. If you like, you can also take this one step further and create a role system. This works by giving each user a role (one-to-many), and each role has a number of permissions (many-to-many). This way permissions don’t need to be set on a per-user basis, and you can simply assign them a role like “Administrator”, or “Editor” or “Contributor”, along with the associated permissions for that role.

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

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I have a bunch of posts stored in text files formatted in yaml/textile (from
I'm making a simple page using Google Maps API 3. My first. One marker
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.