What will this projection be?

I am new to sql, if I run this projection on a table, will it return nothing, or the error of this projection will not be resolved (syntax)? I put all the table and projection information in this picture below to make it easier to read :)

my table and projection

+3


source to share


1 answer


In relational algebra, your difference in settings will lead to an error because the two sets are not compatible with each other:

To unite a union and a difference in a set, two interrelated relationships must be union compatible, i.e. the two relationships must have the same set of attributes. from wikipedia

In SQL, the setting difference will work because join compatibility is understood more leniently, that is, set degrees and data types must match, but not names. So this is really SQL:

SELECT X FROM A
EXCEPT
SELECT Z FROM A

      



The result will be a table with one column named X

However, even in SQL, you cannot project Y

from a given difference, so π Yimpossible, neither in SQL nor in relational algebra. This will be invalid SQL:

SELECT Y -- Y is not defined here, only X
FROM (
  SELECT X FROM A
  EXCEPT
  SELECT Z FROM A
)

      

+1


source







All Articles