create table ProductType ( id int primary key, title varchar(200), description varchar(2000) not null, size int not null ); create table Product ( id int primary key, started date not null, completed date, label varchar(200), type int not null, foreign key(type) references ProductType(id) on update cascade on delete no action ); create table Factory ( id int primary key, address varchar(200) not null unique ); create table Machine ( id int primary key, code varchar(200) not null, partOf int, foreign key(partOf) references Factory(id) on update cascade on delete no action, unique(code, partOf) ); create table Employee ( id int primary key, name varchar(200) not null ); create table Qualification ( canRepair int, foreign key(canRepair) references ProductType(id) on update cascade on delete cascade, canBeRepairedBy int, foreign key(canBeRepairedBy) references Employee(id) on update cascade on delete cascade, primary key(canRepair, canBeRepairedBy), level enum(""Novice"", ""Intermediate"", ""Expert"") -- Enumeration strategy: fixed enumeration ); create table ProductProcessor ( -- Implementation of the Product-Machine association processes int primary key, foreign key(processes) references Product(id) on update cascade on delete cascade, processedBy int not null unique, foreign key(processedBy) references Machine(id) on update cascade on delete cascade );
要求:Develop a Java program using JDBC that assigns employees to repair broken machines. The input is a list of pairs, each of which specifies a factory address and machine code. The output is a map from employees to machines. No employee can be assigned to more than one machine. Assign as many expert employees as possible first, then assign as many intermediate employees as possible to the remaining machines and finally as many novice employees as possible to any machines that are still remaining.
尤其有一点很困惑,该怎么处理这一问题:本人开始是想对每个工人对应不同种类产品的等级进行遍历,每次遇到expert level的就把工人和对应种类输出,但是想到可能工人1对ABCD等等产品的等级都是expert,而工人2只对A产品是expert,假如把工人1提取出来了占据了产品A,那么工人2的expert就没有了,无法满足使expert尽可能多这一条件。
请各位高手不吝赐教,十分感谢!
解决方案:40分
这个应该是个算法问题。不是数据库上的问题。
好像以前在算法课上,或是图论的课上听到过相似的例题, 是老师安排课程的例子,有些老师可以教四门,有些老师仅能教一门。应该是离散二分图中的东西。建议参考一下。 好像是先把二分图画好,全部连线画好,之后开始去重复的。
好像以前在算法课上,或是图论的课上听到过相似的例题, 是老师安排课程的例子,有些老师可以教四门,有些老师仅能教一门。应该是离散二分图中的东西。建议参考一下。 好像是先把二分图画好,全部连线画好,之后开始去重复的。