...

View Full Version : Multiple records in one field



Killermud
03-06-2009, 04: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).

oracleguy
03-06-2009, 05: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.

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

djm0219
03-06-2009, 05: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.

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

Example:

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum