存储和访问 WebApp 用户隐私设置的最佳实践?

发布于 2024-08-18 22:05:23 字数 548 浏览 7 评论 0原文

如果您允许人们确定谁可以查看他们的用户信息,那么存储和访问该信息的最佳方式是什么?

他们将通过以下任何一种方式设置其偏好:

  • 基于用户(选择特定用户 - 即阻止:“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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你没皮卡萌 2024-08-25 22:05:24

我认为最好的选择是基于单选按钮的选择。
浏览你一直认识的用户列表也是非常痛苦的。复选框听起来也不错。

出色地。看这个例子:您在单选按钮组中选择“所有人” - 那么为什么有人想要向他的朋友隐藏它呢?

单选按钮对于用户和您来说都是最简单的方法。

此致,
喇嘛

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

错々过的事 2024-08-25 22:05:23

我会将结果预先计算到“无法查看”表中,即如果 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文