以表格形式表示的组织结构图
我有一个 Access 应用程序,其中有一个员工表。员工属于组织中多个不同级别的成员。该组织有总经理1名,部门负责人5名,每个部门负责人下有若干主管,这些主管下有工人。
根据员工的职位,他们只能访问其下属的记录。
我想用某种级别系统在表格中表示组织。我看到的问题是,同一级别有许多人(例如主管),但他们不应该访问其他部门主管的记录。我应该如何解决这个问题?
I have an Access application, in which I have an employee table. The employees are part of several different levels in the organization. The orgranization has 1 GM, 5 department heads, and under each department head are several supervisors, and under those supervisors are the workers.
Depending on the position of the employee, they will only have access to records of those under them.
I wanted to represent the organization in a table with some sort of level system. The problem I saw with that was that there are many ppl on the same level (for example supervisors) but they shouldn't have access to the records of a supervisor in another department. How should I approach this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在数据库中保存此类分层数据的一种常见方法仅使用单个表,其字段如下所示:
然后您的应用程序使用 SQL 查询来计算出权限。要找出允许主管“X”(例如,其 userId 为“3”)查看的员工,您可以查询supervisorId=3 的所有员工。
如果你想让上级老板能够看到他们下面的所有人,最简单的方法就是进行递归搜索。即查询向这个大老板报告的每个人,并为每个人查询谁向他们报告,一直到树下。
这有道理吗?您让数据库完成对所有用户进行排序的工作,因为计算机擅长这种事情。
我在此示例中放置了positionCode,以防您希望某些人具有不同的权限...例如,您可能为人力资源员工设置了代码“99”,他们有权查看所有员工的列表。
也许我会让其他人尝试更好地解释它......
One common way of keeping this kind of hierarchical data in a database uses only a single table, with fields something like this:
Then your app uses SQL queries to figure out permissions. To figure out the employees that supervisor 'X' (whose userId is '3', for example) is allowed to see, you query for all employees where supervisorId=3.
If you want higher-up bosses to be able to see everyone underneath them, the easiest way is just to do a recursive search. I.e. query for everyone that reports to this big boss, and for each of them query who reports to them, all the way down the tree.
Does that make sense? You let the database do the work of sorting through all the users, because computers are good at that kind of thing.
I put the positionCode in this example in case you wanted some people to have different permissions... for example, you might have a code '99' for HR employees which have the right to see the list of all employees.
Maybe I'll let some other people try to explain it better...