第一句里所填的引导词在定语从句----you visited last year中做 visited 的宾语,所以用关系代词that或which,也可以省略不填,第二句中所填的词在定语从句----you worked 中作地点状语,所以用关系副词where,不懂再问
第一句定语从句visited 是及物动词缺宾语,当然选关系代词which/ that 了
第二句定语从句worked 是不及物动词,可见从句缺的是状语, 用where (=in which) 【 worked in the factory】