views:

38

answers:

2

If you allowed people to determine who could view their user information, what would be the best way in which to store and access that information?

They would be setting their preferences in any of these ways:

  • User Based (select specific users - ie. Block: "Munch", "Dummy")
  • Checkbox Based (select one or many groups of users - ie. "My Friends", "Anyone in my Network")
  • Radio Button Based (select only one group of users - ie. "Everyone")

My current thought is that, because the information is relevant to the user being viewed and not the one clicking around the site, you would have to store these options in a database, and based on the any particular combination of results, run a certain query.

The only issue is there could be a seemingly huge number of different queries:

  • 7 checkboxes could have up to 128 different combinations (2^7)
  • 128 combinations = 128 different optimized queries

This does not seem to be efficient in either time spent writing the queries or in the amounts of queries for every page view (querying to get another query to run...blech!).

And because I'm sure this has been done before, I feel like I must be overlooking something. Is there a better way to do this using PHP/MySQL?

A: 

I think the best option would be the Radio Button based one. It would be quite painful going through a list of users you know all the time, too. The checkbox one doesn't sound so bad either.

Well. Look at this example: You select "Everyone" in the Radio Button group - why would someone want to hide it from his friends then?

Radio Buttons would be both the easiest way for the user and you.

best regards, lamas

lamas
I think you misunderstood the question. I'll try to make it more clear. The user has to be able to do any of those three options for various settings. What I'd like to know is how to optimally store them and access them in a manner that doesn't take a huge amount of processing and without writing 128 queries
munch
Oh I see - sorry for that D:It is a bit late in my country, too
lamas
Not a problem. You're response does make me rethink whether I can get all the information into Radio Buttons. Thanks for the input
munch
+1  A: 

I would precalculate results into a table of 'can not views', ie if usera in some form blocks userb (directly or because hes in a group), the table gets a record saying just that. its the age old one of doing the heavy lifting on writing rather than reading.

devians