一个crm系统数据设计问题

WBOY
Release: 2016-06-23 14:20:29
Original
1066 people have browsed it

crm 数据库 优化

如题,有个员工表,里面有员工ID,名字,电话,地址,部门等等信息。如果部门不是总部,则需继续向上汇报。

现在需要设计一下数据库:
1.选择一个员工,写出该员工的汇报链。
2.如果一个部门经理,列出该部门下所有的员工。


我想到的思路使用递归解决,但是考虑到量大的话,可能效率不行。

请问有什么好的优化方法。如果用递归,请给出一些例子,如何做。谢谢

回复讨论(解决方案)

不知道你是想问数据库设计还是想实现什么


不知道你是想问数据库设计还是想实现什么

想问数据库设计

什么官僚机构?你打算做多少次递归?

递归一次后将你所有的部门写入数组存文件。

员工表里存 depid, 
部门表:
id pid title

什么官僚机构?你打算做多少次递归?

有不是递归的方法解决吗?

主要考虑到 递归量大的话 效率不行,有没有其他的方法能解决呢

员工表里存 depid, 
部门表:
id pid title

能详细点吗

部门表里加一个部门经理

部门编码
01
0101
010101

版主方法可行,数据库不需要怎么设计,部门编码设计合理以后,直接分割,就能找到汇报链。

部门编码
01
0101
010101

那如果要从数据库层面来设计,是不是就只能是用递归了?

一个表就行    parentID 区分

其实我想要详细一点的步骤,
最好有个详细点的例子。各位大神

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!