   foreign key fk_workflowtyperesource_wid (workflowid) references workflow(workflowid)
 ) ENGINE=InnoDB charset=utf8;
 
-create table workflowresource (
-  workflowresourceid int(10)  primary key auto_increment, 
+create table workflowresourcecategory (
+  workflowresourcecategoryid int(10)  primary key auto_increment, 
   workflowid int(10) ,
-  resourceid int(10) ,
-
-  constraint unique index u_workflowresource_wid_rid (workflowid, resourceid),
-
-  foreign key fk_workflowresource_rid (resourceid) references resource(resourceid),
-  foreign key fk_workflowresource_wid (workflowid) references workflow(workflowid)
-) ENGINE=InnoDB charset=utf8;
-
-create table workflowresourcemeta (
-  workflowresourcemetaid int(10)  primary key auto_increment, 
-  workflowresourceid int(10) ,
+  resourcecategoryid int(10) ,
+
+  constraint unique index u_workflowresource_wid_rcid (workflowid, resourcecategoryid),
+
+  foreign key fk_workflowresourcecategory_rcid (resourcecategoryid) references resourcecategory(resourcecategoryid),
+  foreign key fk_workflowresourcecategory_wid (workflowid) references workflow(workflowid)
+) ENGINE=InnoDB charset=utf8;
+
+create table workflowresourcecategorymeta (
+  workflowresourcecategorymetaid int(10)  primary key auto_increment, 
+  workflowresourcecategoryid int(10) ,
   k varchar(250) , 
   v text,
   position int(10)  default 0,


create table resourcecategory (
  resourcecategoryid int(10)  primary key auto_increment, 
  iname varchar(250) ,
  name varchar(250) ,
  lastupdts timestamp  default current_timestamp,
  lastupduser int(10)  default 0,
  constraint unique index u_resourcecategory_i(iname),
  constraint unique index u_resourcecategory_n(name)
) ENGINE=InnoDB charset=utf8;

  constraint unique index u_jobresource_rid_jdid (resourceid, jobid)
) ENGINE=InnoDB charset=utf8;

create table jobresourcecategory (
  jobresourcecategoryid int(10)  primary key auto_increment,
  jobid int(10) ,
  resourcecategoryid int(10) ,

  lastupdts timestamp  default current_timestamp,
  lastupduser int(10)  default 0,

  foreign key fk_jobresourcecategory_jdid (jobid) references job(jobid),
  foreign key fk_jobresourcecategory_rid (resourcecategoryid) references resource(resourcecategoryid),
  constraint unique index u_jobresource_rcid_jdid (resourcecategoryid, jobid)
) ENGINE=InnoDB charset=utf8;

create table jobsoftware (
  jobsoftwareid int(10)  primary key auto_increment,
  jobid int(10) ,
  softwareid int(10) ,

  lastupdts timestamp  default current_timestamp,
  lastupduser int(10)  default 0,

  foreign key fk_jobsoftware_jdid (jobid) references job(jobid),
  foreign key fk_jobsoftware_sid (softwareid) references software(softwareid),
  constraint unique index u_jobsoftware_rid_jdid (softwareid, jobid)
) ENGINE=InnoDB charset=utf8;

--
-- job draft
--
