View Full Version : Multiple records in one field

03-06-2009, 05:57 PM
Is there any way for multiple record to be stored into one field?

Im trying to make a forum permission system where a user can view parts of the forum depending on their permissions. So is it possible to have a record with say multiple ids in, then php can identify each id? (e.g. a field with 1 3 6).

03-06-2009, 06:07 PM
You do not want to do that, it is bad database design. What you need to do is create a permissions table.

You can have two columns, one is the user ID and the second is the forum ID they can access. Those two keys can then be a composite primary key.

Then you can easily query if the user can access a certain forum easily as well.

03-06-2009, 06:11 PM
But what about multiple forums?

03-06-2009, 06:14 PM
But what about multiple forums?

You'd have a row in the second table for each forum a user has permissions for. That allows you to check the permissions for a forum with a single query.

03-06-2009, 06:15 PM
You can have multiple rows with the same user ID and different forum IDs in your permissions table.


User ID | Forum ID
1 | 1
1 | 2
2 | 1
3 | 1
3 | 2