# Convert query in words to relational algebra

I have a follow-up question to a question I have previously asked on SO.

Instead of the query from my initial question, I want to convert the following into relational algebra:

List the names and phone numbers of the bidders who are not always affected by double-bidding.

Note: Double-bidding occurs when two different bidders bid the same price on the same exact item.

I have some ideas as to how to proceed:

• Find all bidders that have double bid (1)
• Find all bidders who have a bid that isn't double-bidding (2)
• Find all bidders who have never placed a double-bidding bid (3)

From here, I can get the intersection of (1) and (2) and add (3) to this intersection to get the final answer. (That is my thought process, please correct me if I am wrong)

I have no issues in finding all bidders that have placed a double bid, but the consequent ideas are confusing me quite a bit. This is what I have for "all bidders that have double bid":

• BID⨝ITEM - (Q1)

• Q1 ⨝ ρbid→bid', iid→iid', price→price'(Q1) - (Q2)

• πbidbid != bid'(Q2) ∧ σprice = price'(Q2) ∧ σiid = iid'(Q2)) - (Q3)

How do I use this to find the bidders who are not always affected by double bidding?

By the way, the bolded text is merely for labeling purposes and is not part of the answer.

• "bidders who are not always affected by double-bidding", isn't that the intersection between (1) and (2)? Commented Mar 29, 2016 at 4:47
• for all x p is not exists x not p. It's not helpful to say "all xs where..." rather than just "the xs where..." because that "all" has nothing to do with "for all" or "where all"--every query (sub)expression returns "all" the rows/entities making some criterion true. "where all" in the sense of "the xs related to all the ys" ie "xs where for all y" involves relational division. But the special case of "the xs where there are at least n ys" is "xs where there exists y1,y2,..." which uses projection & n joins. Commented May 3, 2020 at 3:20