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?
I don't see how your question relates to regular expressions at all. If you want the names of the persons that co-authored with John Doe though, I would recommend joins:
The query starts from person John Doe, and brings the corresponding rows in
author
; then, it searches for all co-authors, and finally brings their names.