# Thread: Seven non-trivial logic relationships

1. Registered User
Join Date
Feb 2009
Posts
2

## Unanswered: Seven non-trivial logic relationships

Hello all! First post to this forum.

I had a mini-epiphany when I learned SQL had a lot in common with set theory. I know that there are 16 two value logic functions (most are trivial). Using that knowledge I came up with a list of seven non-trivial SQL functions:

p AND q ::: p INNER JOIN q
p - q ::: p LEFT OUTER JOIN q WHERE q IS NULL
q - p ::: p RIGHT OUTER JOIN q WHERE p IS NULL
p OR q ::: (p R.O.J. q) UNION (p L.O.J. q) [[FULL OUTER JOIN]]
p ::: p L.O.J. q
q ::: p R.O.J. q
p XOR q ::: (p - q) UNION (q - p)

I found it interesting to figure these out. If anyone finds them useful, cool :-D

2. SQL Consultant
Join Date
Apr 2002
Location
Posts
20,002
Originally Posted by carnright
I had a mini-epiphany when I learned SQL had a lot in common with set theory.
OMFG you're right!!!

p.s. a couple of those don't look right, but you have the general idea

hang on, it'll be only a few minutes while our theorists scurry out from under their rocks and prepare a more detailed critique

Last edited by r937; 02-12-09 at 11:26.

3. Registered User
Join Date
Feb 2009
Posts
2
Thanks :-)

Could you elaborate on the ones that do not look right? I kind of summarized the SQL portion, that may be what you mean. I tried each one out on a set of data and they seemed correct.

Here is the p - q more defined

CREATE VIEW loj AS SELECT pe.p AS p, qu.que AS q FROM pe LEFT OUTER JOIN qu ON pe.p = qu.que;
CREATE VIEW p_minus_q AS SELECT * FROM loj WHERE q IS NULL;
Last edited by carnright; 02-12-09 at 11:41.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•