Question

First time i encounter a relational algebra for databases question today, and i can't seem to find the answer.

I have 3 tables, Batch, Channel and Market.

Batch is connected to Channel and Market by foregein keys (channelID, marketID).

What is the correct notation for a query of this sort:

select * from batch, channel, market 
where batch.channelID=channel.channelID AND batch.marketID=market.marketID

Thanks


If i understood correctly, i need to write as follows:

π...(Batch⋈                                   Channel⋈                                Market
           (batch.channelID=channel.channelID)        (batch.marketID=market.marketID)
Was it helpful?

Solution

That would be batch ⋈ channel ⋈ market (natural joins are associative and commutative).

EDIT: since the attribute names are the same for each join (you're comparing batch.channelID with channel.channelID), you're in a situation where the query can be written with natural joins, and there's no need to write (xxx = yyy) beneath the ⋈ operator when it's representing a natural join.

You could write it as θ-joins instead, in which case your syntax would be almost correct, but I feel that using θ-joins to represent natural joins kind of misses the point. The change you need to do is that, since θ-joins are not associative, you need to add brackets : (batch ⋈ channel) ⋈ market

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top