开发者

Relational algebra syntax

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 (chan开发者_开发百科nelID, 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)


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜