开发者

Selecting DISTINCT rows in relational algebra

There is a DISTINCT operator in SQL. However, I have an assignment in which I need to get some disti开发者_运维知识库nct values from a table, and I can only use relational algebra. Is there a way?


Relational operators always return distinct tuples so DISTINCT is never needed. Duplicate tuples are not permitted in the RA - that being one major difference between the relational model and the SQL model.


Relational Algebra is based on set theory. SQL is an implementation of multi-set theory. Set always has distinct elements. So tuples are distinct by default in Relational Algebra.


The projection in relational algebra is equivalent to select distinct. In select statement of sql, duplicates are allowed as it is based on multiset theory but in projection of relational algebra, which is based on set theory, duplicates are not allowed.

Hence, relational algebra equivalent of select distinct is projection.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜