next up previous contents
Next: What is Edna's Up: Examples with the Previous: Who works for

Which manager works in admin?

 

An example, with paraphrasing, where the query gives rise to a nested SELECT statement in the SQL.

ENG: which manager works in admin
SYN: (s(np(det(which))(n(n(manager))))
      (vp(v(works))(pp(prep(in))(np(propn(admin))))))
 PT: `manager:fv1 and `in:`admin:`work:fv1
FOL: manager(fv1)&in(fv1,`work,`admin)
URC: {fv1;[*,fv1]:boss&[fv1,*,*,`admin]:emp}
DRC: {fv1:emp![name];[*,fv1]:boss&[fv1,*,*,`admin]:emp}
OP1: {fv1:emp![name];[*,fv1]:boss&[fv1,*,*,`admin]:emp}

PAR: which employee works in admin and is a manager

TRC: {fv1!name;fv1:emp;exists(tuple1:boss,tuple1!mgr=fv1!name)&
      exists(tuple2:emp,tuple2!name=fv1!name&tuple2!dept=admin)}
OP2: {fv1!name;fv1:emp;exists(tuple1:boss,tuple1!mgr=fv1!name)&
      exists(tuple2:emp,tuple2!name=fv1!name&tuple2!dept=admin)}
OP3: {fv1!name;fv1:emp;exists(sk1:boss,
      sk1!mgr=fv1!name&fv1!dept=admin)}
SQL: SELECT DISTINCT fv1.name FROM emp fv1 
      WHERE EXISTS(SELECT * FROM boss sk1 
       WHERE (sk1.mgr=fv1.name AND fv1.dept='admin'));

|name      |
|----------|
|malcolm   |
|----------|
(1 rows)



Chris Fox, September 1995