以表格形式表示的组织结构图

发布于 2024-08-10 05:13:18 字数 201 浏览 4 评论 0原文

我有一个 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 技术交流群。

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

发布评论

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

评论(1

零度℉ 2024-08-17 05:13:18

在数据库中保存此类分层数据的一种常见方法仅使用单个表,其字段如下所示:

  1. userId(主键)
  2. userName
  3. SupervisorId(自引用“外键”,指同一个表中的另一个 userId)
  4. positionCode(可以很简单,例如 1=lakey、2=supervisor;或者指向另一个职位表等的外键)
  5. ...您需要为每个员工存储的其他内容...

然后您的应用程序使用 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:

  1. userId (primary key)
  2. userName
  3. supervisorId (self-referential "foreign key", refers to another userId in this same table)
  4. positionCode (could be simple like 1=lakey, 2=supervisor; or a foreign key pointing to another table of positions and such)
  5. ...whatever else you need to store for each employee...

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...

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