存储和访问 WebApp 用户隐私设置的最佳实践?
如果您允许人们确定谁可以查看他们的用户信息,那么存储和访问该信息的最佳方式是什么?
他们将通过以下任何一种方式设置其偏好:
- 基于用户(选择特定用户 - 即阻止:“Munch”、“Dummy”)
- 基于复选框(选择一组或多组用户 - 即“我的朋友”、“我的网络中的任何人”)
- 基于单选按钮(仅选择一组用户 - 即“每个人”)
我当前的想法是,因为该信息与正在查看的用户相关,而不是与在网站上单击的用户相关,所以您会必须将这些选项存储在数据库中,并根据结果的任何特定组合运行特定的查询。
唯一的问题是,可能存在看似大量的不同查询:
- 7 个复选框最多可以有 128 种不同的组合 (2^7)
- 128 种组合 = 128 种不同的优化查询
这对于编写查询所花费的时间似乎效率不高或者每个页面视图的查询量(查询以运行另一个查询......哎呀!)。
因为我确信以前已经做过这样的事情,所以我觉得我一定忽略了一些事情。有没有更好的方法使用 PHP/MySQL 来做到这一点?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为最好的选择是基于单选按钮的选择。
浏览你一直认识的用户列表也是非常痛苦的。复选框听起来也不错。
出色地。看这个例子:您在单选按钮组中选择“所有人” - 那么为什么有人想要向他的朋友隐藏它呢?
单选按钮对于用户和您来说都是最简单的方法。
此致,
喇嘛
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
我会将结果预先计算到“无法查看”表中,即如果 usera 以某种形式阻止 userb (直接或因为他在组中),则该表会得到一条记录来说明这一点。这是一种古老的做法,即把繁重的工作放在写作而不是阅读上。
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.