Privacy in simple DB system

╄→尐↘猪︶ㄣ 提交于 2020-01-08 01:51:33

问题


I am implementing a simple database system. Basically is a simple social network, everyone has his own dashboard, where you can post some random text. The problem is that I want a privacy level, I mean I want that somebody is allowed to browse only some profiles. And I'm deciding who can watch what.

The question is: How can I do that?I have to work with relation in the database or what?

Thanks for your time.

S.


回答1:


What you are looking for is called "Access Control List" (ACL): Check out Nettuts tutorial on implementing an ACL: http://net.tutsplus.com/tutorials/php/a-better-login-system/




回答2:


Create a secondary table where you keep who can access what. If in the main user table you have and id or something (preferably indexed) (like you should). Just make a 2 column table with id and view_id or something (both foreign keys and togeder should form a pk). And... you read from it.




回答3:


Most probably you would want to set a table for your privacy like

id                 type
1            View All
2            View None
3            View Something

then on your table where users can be found you could call the type

user_id    privacy_id 
1            2
2            3
4            1

where privacy_id is the id of your privacy table, something like that.



来源:https://stackoverflow.com/questions/9228157/privacy-in-simple-db-system

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!