How to imagine “does not exist” in relational algebra?

How can I imagine a SQL sentence "does not exist" in relational algebra?

+3
source share
2 answers

I think you are looking for an existential quantifier (∃), which could then be undone (~ ∃).

Reply to comment: I don’t remember much of my relational algebra, but if I were going to strike, I would suggest something along the lines of: σ ∃ σ (Y) sub> (S). Or perhaps π ∃π (Y) (S); I don’t quite remember if you want to select or project for this.

0
source

In my case, I solved this problem by rewriting the request,

SELECT *
FROM contactperson
WHERE EXISTS(
   SELECT *
   FROM person
   WHERE contactperson.personId = person.id)

at

SELECT *
FROM contactperson
WHERE personId = (
   SELECT id
   FROM person
   WHERE contactperson.personId = person.id)

It returns the same result and is more easily rewritten in relational algebra with the help of union.

-1
source

Source: https://habr.com/ru/post/1765349/


All Articles