If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Seven non-trivial logic relationships

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-12-09, 08:48
carnright carnright is offline
Registered User
 
Join Date: Feb 2009
Posts: 2
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
Reply With Quote
  #2 (permalink)  
Old 02-12-09, 10:22
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
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

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book

Last edited by r937; 02-12-09 at 10:26.
Reply With Quote
  #3 (permalink)  
Old 02-12-09, 10:30
carnright carnright is offline
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 10:41.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On