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.

  • 1
    "bidders who are not always affected by double-bidding", isn't that the intersection between (1) and (2)? 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.
    – philipxy
    May 3, 2020 at 3:20

1 Answer 1


The key point here is that relational algebra eliminates duplicates from its result. So if you use a Project operator to get only iid and price, it will give you the list of bids excluding the duplicate bids. If you subtract this list from the whole set of bids you will get the bids that are duplicates.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.