As Paul Rubin pointed out the SQL in the last post was broken – here’s some that, I think (please do not let it be wrong a second time!), by relying on SQL’s coercion of a tuple to a scalar, would work (Paul proposed an even more ambitions way of doing this in a single join):
SELECT DISTINCT U.NAME, U.EMAIL
FROM USER U, BID B, LOT L
WHERE U.USER_ID = B.BIDDER_ID AND
B.AMOUNT > 100 AND B.LOT_ID = L.LOT_ID
AND (SELECT COUNT(*) FROM
BID, LOT WHERE
BID.LOT_ID = B.LOT_ID AND BID.BIDDER_ID = U.USER_ID
AND BID.LOT_ID = LOT.LOT_ID) > 1
Still no clue as to how to do this with relational algebra though.
- Solving a relational query: part 2 (cartesianproduct.wordpress.com)
- Solving a relational query: part 1 (cartesianproduct.wordpress.com)
- Relational division again (cartesianproduct.wordpress.com)
My maths ‘A’ level is a long time ago (I actually did a further year of maths – albeit “maths for engineers” and so very cookbook like – at University) and, to be honest, I have never worked in a job where much beyond competent arithmetic has been required, so last year, when I started the MSc, the set theory rang some bells, but they were pretty muffled ones.
I got through last year and the exams, though that experience taught me that thinking “I remember this stuff” and actually putting the hours in to ensure you know it are very different. What’s more the prospect of my end of degree project and the need to read and understand a number of papers with some degree of mathematical formalism spurred me on to ensure that I had a firmer grounding in all of this.
My view has long been that books are the key that unlocks knowledge – if you can find the right book, read it and understand it then you will be most of the way there.
So, naturally enough I looked for books that would give me a good grounding/reminder over set theory, functions, relations and so on: the areas of discrete mathematics that matter most for computer scientists.
The first book I bought was Sets, Logic and Maths for Computing (Undergraduate Topics in Computer Science) but I would have to say I wasn’t hugely impressed. I could live with the description of the topic as one of the “undergraduate topics in computer science” because I suppose that is just what it is. But what annoyed me with it was the lack of worked through answers to all the exercises – what’s the point of putting exercises in a text book and then not explaining the answer? And then the explanations of some of the more complex issues was poor: there is a short, dense explanation and we move straight on to the partially explained exercises.
Happily, though, I found a better book: Discrete Mathematics for Computing.
It is a thinner (and more expensive!) volume but it does thoroughly explain the topics on which it touches and every exercise has a solution provided – it just does the job better.