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)? – Lennart Mar 29 '16 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 at 3:20

I think the key point here is the fact 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 bids you will get the bids those are duplicates..

I am not sure though.. Would you please comment on how you feel about this approach?

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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