sql - Difficult oracle query -


i have database looks this:

table_students: { studentid(pk), name };  table_stu_cou:{ studentid(fk), courseid(fk) };  table_courses:{ courseid(pk), coursename };  table_tea_cou { courseid(fk), teacherid(fk) };  table_teachers:{ teacherid(pk), name}; 

the stu_cou table shows students attend courses. tea_cou tables shows teachers teach course. have list students , teachers have never met (the student has never attended course presented lecturer). can't figure out how make , i've been trying 2 days. me? i'm using oracle.

what need first compute potential pairs student,teacher, subtract student teachers have met:

the first done crossproduct of students , teachers. second join based on courses have taken:

select studentid, teacherid students, teachers  except  select studentid, teacherid stu_cou natural join tea_cou; 

if interested in student names , teacher names can use result subquery , joins students , teachers tables information. leave exercise do.

--dmg


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -