Relational Algebra - What is the Correct Way to Present a “Have” Sentence?

Yes, it is a matter of homework, but the names have been changed to protect the innocent. Meaning, I do not ask the question of homework itself, but rather a small part of it, so that I can understand everything.

Let's say you have an SQL query like this:

- The request will indicate prices for cars that occur more than once.

select car_price from cars group by car_price having count (car_price) > 1; 

The general form of this in relational algebra is Y (gl, al) R Where Y is a Greek symbol, GL is a list of attributes for a group, AL is a list of aggregations

Thus, relational algebra will look like this:

  Y (count(car_price)) cars 

So, how is the "having" clause in this expression? Is there an abridged version? If not, do I just need to choose from this relationship? Something like this maybe?

 SELECT (count(car_price) > 1) [Y (count(car_price)) cars] 

I worked on the Internet for hours and did not find examples of converting HAVING to relational algebra. Thanks for the help!

+6
relational-algebra
source share
2 answers

select count (*) from (select * from cars where price> 1), as cars;

also known as relational closure.

+3
source share

For a more or less accurate answer to the actual question asked: "Relational algebra - what is the proper way to represent" the presence of a sentence? ", you must first indicate that the question itself seems to suggest or suggest that there is such a thing as" THE "relational algebra, but this presumption is simply wrong!

An algebra is a set of operators, and anyone can define any set of operators that he likes, that is, anyone can define any algebra he loves! In his latest publication, Hugh Darwen mentions that RESTRICT is not a fundamental algebra operator, although many others consider it to be.

Especially with respect to clusters and summaries, there is no consensus on how these should be included in relational algebra. Defining operators such as COUNT () (which take a relation as the value of an argument and return an integer) as part of the algebra can be problematic with respect to the closure property of the algebra, precisely because such operators do not return the relation ...

So, sorry, but, nevertheless, most appropriate, the answer here seems that the final answer to this question is almost impossible to give ...

0
source share

All Articles