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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:45:33+00:00 2026-05-28T03:45:33+00:00

I am not a professional web developer, however I dabbled in php in high

  • 0

I am not a professional web developer, however I dabbled in php in high school. I am currently working on updating the website for one of the organizations I belong to in college. I really do not have a succinct way to ask my quesetion, so I will give an example:

For the offices in our organization, the tables are something like this:

officeid_officename
+------------+------------+
| officeid   | officename |
+------------+------------+
| 1          | president  |
| ...        | ...        |
+------------+------------+

officeid_memberid
+------------+----------+
| officeid   | memberid |
+------------+----------+
| 1          | 234      |
| ...        | ...      |
+------------+----------+

memberid_memberdata
+------------+------------+-----+
| memberid   | membername | ... |
+------------+------------+-----+
| ...        | ...        | ... |
| 234        | John Smith | ... |
| ...        | ...        | ... |
+------------+------------+-----+

As far as I can tell, this would be a proper design for the tables because it allows 1) For office names to be arbitrarily changed (e.g. If “President” were to become “Supreme Overlord”) 2) it allows for members to arbitrarily be added to and removed from offices 3) in the end the data about each member can change without the member’s link to an office being affected.

The issue I have is, in the code I am writing, I have authorization that depends on what offices a member holds. I can think of three options of representing what offices are allowed to perform what actions.

1) Use “President”, etc. as the identifier to check for (e.g. if($officename === "president") { ... do something ... } )

  • However, this seems to defeat the purpose of the table design, as a change in the office name will break the authorization.

2) Use the officeid as the identifier to check for (e.g. if($officeid === 1) { ... do something ... } )

  • However, this seems to lack maintainability, as developers constantly will have to reference the database to see what id refers to which office when they are editing current code or writing future code.

3) Define constants in a config file such that PRESIDENT_CONSTANT = 1, or something of the like, and check against the constant (e.g. if($officeid === PRESIDENT_CONSTANT) { ... do something ... } )

  • However a) this shares issues with (1) in that the name of the position might change b) this is essentially recreating the officeid_officename table in the config file

Out of the three options, I feel like number two is the most correct, but I have lingering feelings concerning the maintainability issues. Is there a better way to accomplish what I need to do here?

Thanks.

  • 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-28T03:45:34+00:00Added an answer on May 28, 2026 at 3:45 am

    Yes, #2 is correct.

    I’m not really sure why you are concerned that you “constantly will have to reference the database.”

    Assuming you are writing a classical PHP web app, each page load executes your script from the beginning. If you check the office at the beginning and store the result you can get away with a single query per page load. And in any event, databases are highly optimized for queries – doing a few of them isn’t going to hurt you.

    The only downside to the above model is that you have a potential race condition: if the database changes during a single execution then you have a form of a privilege escalation vulnerability.

    To address this, one approach is to authenticate (i.e. check the office) through the database at the beginning, cache the result, then run your code and queue up any database work inside an SQL transaction. Then re-authenticate before sending the page to the user. If the authentication fails, you send the user an error and roll back the transaction. If it succeeds (i.e. the office matches the cached result), send the user the page contents and commit the transaction.

    This might be a lot to think about if you aren’t a professional web developer, but software (even for college organizations) has a way of getting used in unintended places, so best to consider the security ramifications before you start writing.

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

Sidebar

Related Questions

I am not a professional web-developer but I am designing one to help out
I am not a professional web developer, but I like to wrench on websites
I am not a professional web developer but I love web development as a
I'm currently developing for a handheld device running Windows XP Professional (not Tablet PC
According to Professional Javascript for Web developers array is not a datatype in Javascript:
I currently have VS 2008 Web Developer SP1 installed on my machine and I've
I am not professional programmer so i can not be sure about this.How many
First, let me say I'm not a professional programmer, but an engineer who had
I'm talking about VS 2010 Professional/Ultimate RTM (not express versions). Google doesn't show much
I have searched around a bit, and have not really found a professional type

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.