博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
人力资源匹配数据表设计
阅读量:4562 次
发布时间:2019-06-08

本文共 3159 字,大约阅读时间需要 10 分钟。

最近一直在看《SQL puzzles and answers》,其中EMPLOYMENT AGENCY一文让我眼前一亮。在这里把我对此文的概括与理解写下来与大家分享(代码在SQL Server 2005中测试通过)。

需求描述

对于人力资源网站或职业中介,会保存大量求职者的简历信息。通过让求职者勾选技能关键字或对简历进行分词都可以得到求职者所掌握的技能列表,而且可提供的技能关键字很多(书中提到的系统中的关键字来自于某职业字典,超过250000个)。

求职者的技能列表如下:

create table CandidateSkills(	candidate_id int not null,	skill_code char(15) not null,	primary key(candidate_id, skill_code));insert into	CandidateSkillsselect 100, 'accounting'union allselect 100, 'inventory'union allselect 100, 'manufacturing'union allselect 200, 'accounting'union allselect 200, 'inventory'union allselect 300, 'manufacturing'union allselect 400, 'inventory'union allselect 400, 'manufacturing'union allselect 500, 'accounting'union allselect 500, 'manufacturing';

另一方面,人力资源网站还会存储企业开放出来的职位信息,这些职位对于技能有不同的要求。例如:某职位要求技能为('inventory’ and ‘manufacturing’) or 'accounting’。现在的问题是:

1. 如何设计职位技能要求表(JobOrders)?

2. 如何把求职者技能(CandidateSkills)与职位技能要求(JobOrders)进行匹配?

职位要求表设计

首先我们来解决JobOrders表设计的问题。要表达技能间的逻辑关系,我们可以引入了skill_group列。JobOrders表的脚本如下:

create table JobOrders(	job_id int not null,	skill_group int not null,	skill_code char(15) not null,	primary key(job_id, skill_group, skill_code));

假设有如下职位需求:

Job 1 = (‘inventory’ and ‘manufacturing’) or ‘accounting’

Job 2 = (‘inventory’ and ‘manufacturing’) or (‘accounting’ and ‘manufacturing’)

Job 3 = ‘manufacturing’

Job 4 = (‘inventory’ and ‘manufacturing’ and ‘accounting’)

插入上述需求的脚本如下:

insert into	JobOrdersselect 1, 1, 'inventory'union allselect 1, 1, 'manufacturing'union allselect 1, 2, 'accounting'union allselect 2, 1, 'inventory'union allselect 2, 1, 'manufacturing'union allselect 2, 2, 'accounting'union allselect 2, 2, 'manufacturing'union allselect 3, 1, 'manufacturing'union allselect 4, 1, 'inventory'union allselect 4, 1, 'manufacturing'union allselect 4, 1, 'accounting';

JobOrders中数据的规则如下:

  • 对于相同job_id,相同skill_group的skill_code之间为‘与’关系。对于相同job_id,不同skill_group的skill_code之间为‘或’关系。
  • 除此之外,还有一条约束为‘与’关系优先‘或’关系。

对于'manufacturing’ and (‘inventory’ or ‘accounting’)逻辑,可以转化为('manufacturing’ and ‘inventory’) or (‘manufacturing’ and ‘accounting’)。

职位要求与求职者的匹配

现在我们来解决如何匹配职位要求和求职者技能。

  • 解决方案1
select distinct	J1.job_id,	C1.candidate_idfrom	JobOrders as J1	inner join	CandidateSkills as C1	on		J1.skill_code = C1.skill_codegroup by	C1.candidate_id,	J1.skill_group,	J1.job_idhaving	count(*) >= (select count(*) from JobOrders as J2 where J1.skill_group = J2.skill_group and J1.job_id = J2.job_id);
  • 解决方案2
With JobRequirementCnt as(	select		job_id,		skill_group,		count(*) grp_cnt	from		JobOrders	group by		job_id,		skill_group),CandidateSkillGrpCnt as(	select		CS.candidate_id,		JO.job_id,		JO.skill_group,		count(*) grp_cnt	from		CandidateSkills CS		inner join		JobOrders JO		on			CS.skill_code = JO.skill_code	group by		CS.candidate_id,		JO.job_id,		JO.skill_group)select distinct	CandidateSkillGrpCnt.candidate_id,	CandidateSkillGrpCnt.job_idfrom	JobRequirementCnt	inner join	CandidateSkillGrpCnt	on		JobRequirementCnt.job_id = CandidateSkillGrpCnt.job_id		and		JobRequirementCnt.skill_group = CandidateSkillGrpCnt.skill_group		and		JobRequirementCnt.grp_cnt = CandidateSkillGrpCnt.grp_cnt;

转载于:https://www.cnblogs.com/DBFocus/archive/2010/09/30/1839587.html

你可能感兴趣的文章
如何轻松培养孩子流利说英语
查看>>
Matlab 重命名
查看>>
js call
查看>>
1.7 单例模式
查看>>
.net三步配置错误页面,让你的站点远离不和谐的页面
查看>>
编程学习要讲究效率和经验
查看>>
关于hibernate中多对多关系
查看>>
InstallShield12豪华版破解版下载|InstallShield下载|软件打包工具
查看>>
魔兽RPG仿魔兽世界:基尔加丹的末日V1.0
查看>>
V8引擎实现标准ECMA-262(三)
查看>>
前端面试题集锦(一)
查看>>
php下载文件的代码示例
查看>>
js鼠标及对象坐标控制属性详细解析
查看>>
Java封装servlet发送请求(二)
查看>>
python基础复习汇总
查看>>
go pkg
查看>>
解剖 CPU
查看>>
404 Note Found 队-课堂实战-项目UML设计
查看>>
HTTP协议(收藏)
查看>>
(原创)如何获取网页URL的source code (Android)
查看>>