select name
from person, author, article
where name != "John Doe" AND
person.pid = author.pid AND
author.aid = article.aid AND
title = select title
from author, person, article
where person.name = "John Doe" AND
author.pid = person.pid AND
article.aid = author.aid
The above are the nested queries I wrote in sqlite for a relational algebra that outputs the names of the people who coauthored an article with John Doe.
Here's the relational schema:
Article(aid, title, year, confid, numpages) Author(aid, pid) Person(pid, name, affiliation).
My question how can I simplify the nested queries?