mysql - How to implement sql "where not in" in tuple relational calculus? -


i want convert sql query has not in clause tuple relational calculus.existential , universal quantifier implements exists , not exists clause want know how implement not in?

my tables serves(bar,beer),frequents(drinker,bar),likes(drinker,beer).the following query selects drinkers frequent bars serve beer like.

select distinct f2.drinker frequents f2 f2.drinker not in (select f1.drinker frequents f1 (f1.bar,f1.drinker) not in (select f.bar,f.drinker frequents f,serves s,likes l l.beer=s.beer , f.bar=s.bar , f.drinker=l.drinker)) 

it's enough if can explain me how implement not in in trc no need convert entire query.i using http://www-rohan.sdsu.edu/~eckberg/relationalcalculusemulator.html
check relational calculus , convert sql query.

note:

if use implications in query.

it not support implication.for example implication can implemented follows.(p==>q) can written (not p or q) form both logically equivalent.

your query equal inner query friend,because said f2 not in f1 , f1 not in f , of them got 1 source frequents , means f2=f , query returns this:

select f.bar,f.drinker frequents f,serves s,likes l  l.beer=s.beer , f.bar=s.bar , f.drinker=l.drinker; 

but think query can give better results friend:

select f.bar,f.drinker frequents f  left outer join serves s on  f.bar=s.bar  left outer join likes l on l.beer=s.beer , f.drinker=l.drinker; 

tack @ sql fiddle, better.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -