dongrouyuan5685 2012-05-09 12:37
浏览 40
已采纳

在具有多个用户的php / mysql应用程序中实现文件夹共享

I have a php/mysql application. There are users who have folders. Folders can only be one level deep. Each folder can have unlimited number of documents. The relevant tables are as follows:

user_table:

user_id(PK), name, password, etc

folder_table:

folder_id(PK), name, user_id(FK into user_table)

document_table

document_id(PK), user_id(FK), folder_id(FK), date, name, etc

All queries to operate on folders and documents are of the form

select/update/insert <blah, blah, bhah>
where user_id = %d

Now, I'm looking to allow users to share they folders with other users. I want to do this in the least disruptive way possible. I also want to minimize run time overheads of resulting WHERE clause.

I've been wracking my brains and googling but haven't found a simple enough solution. I can think of implementing it in a manner similar to unix's (read, write, execute) along with (owner, group, others) mechanism. But it seems a bit too complicated for my humble system.

I would really appreciate if someone could give me pointers as to which approach I could possibly take. My goals are simple:

  1. The system doesn't require a whole lot of reworking
  2. At a minimum users should be able to share folders with other users or groups (I will add concept of groups if needed)
  3. There should not be too much overhead in SQL statement's WHERE clause as opposed to what it is now (as simple as: WHERE user_id = %d)
  • 写回答

1条回答 默认 最新

  • dongpang1898 2012-05-09 12:43
    关注

    Sharing folder(s) with user(s)

    You can to add a table *folder_user* with columns folder_id(FK), user_id (FK)

    The user_id in *folder_table* represents the owner of the folder. When the owner shares this folder with another user, you add folder_id and user_id (with whom folder is shared) into folder_user table.

    Later, you can add column access (enum 'READ', 'READ_WRITE') to the same table, to see if a user is allowed to edit documents in the folder or not.

    Sharing folder(s) with group(s)

    1. You need a table group
    2. Then you need to add users to groups, so add a table *user_group* : user_id(FK), group_id(FK)
    3. Then, to give access to of a folder to a group add table *folder_group*: folder_id(FK), group_id(FK) to give access for a folder to a group.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因