Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP/MySQL website with users table, need to add usergroup functionality
    primarykey
    data
    text
    <p>I have working website in PHP with a MySQL backend which has several tables for different purposes. This site is based on different parts or 'environments' like a bugtracker, project management, etc. There is one central 'users' database which has all the users with the associated details in them.</p> <p>In each of previously mentioned 'environments', which all have their own set of tables, it is possible to specify a user ID in certain fields. e.g. the bugtracker table has a column called <code>AssignedTo</code> which contains the user ID's of users to whom bugs have been assigned.</p> <p>The field type of these 'user ID' columns (like the <code>AssignedTo</code> example) is the same as the <code>UserId</code> field in the central users table, which is an unsigned, zerofilled INT(5) field.</p> <p>Now I have a request from the users of this site to also allow to specify user groups in certain of these user ID fields.</p> <p>So again reffering to the <code>AssignedTo</code> example, it should now be possible to also assigned a bug to a user group, instead of a specific user.</p> <p>What's the best way to do this regarding the PHP scripting and the database layout? Now I have all these fields set to the same type as the <code>UserId</code> of the central users table, which is INT(5). However my <code>UserGroupId</code> field in the UserGroups table, is of a different format, INT(3).</p> <p>I could make this field also into an INT(5) field, but that would not solve the 2nd issue I'm having: how to see whether the <code>AssignedTo</code> value is reffering to a specific user, or to a usergroup.</p> <p>I was thinking about make the UserGroupId field start from 99999 and counting downwards, while the UserId field is starting from 00001 and counting upwards, thus assuming that if the <code>AssignedTo</code> starts with 9, it's reffering to a usergroup. But this doesn't seem like a clean solution to me...</p> <p>Any better ideas? Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload