| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Verify Basic Algebra Properties
Apparently the following four algebraic properties (or something
similar) are considered important, possibly showing an approach is
well-grounded in mathematics.
Commutative: A and B = B and A
A or B = B or A
Associative: A and (B and C) = (A and B) and C
A or (B or C) = (A or B) or C
Idempotent: A and A = A
A or A = A
Absorbtive: (A and B) or B = B
(A or B) and B = B
...where A, B and C can be sets of anything?
How is the above implemented/demonstrated in RMDBs, Prolog, LISP, etc? Below I show how to verify it in dbd for the following data set:
A has john, mary and apple. B has john, mary and orange. C has mary, apple and orange.
And each thing in A, B and C has different classifications and attributes. See script below for details.
(new 'gender)
(new 'build)
(new 'color)
(new 'flavor)
(new 'like 'verb)
(new 'apple 'fruit)
(set+ apple color 'red)
(new 'orange 'fruit)
(set+ orange flavor 'tart)
(set+ orange color 'orange)
(new 'mary 'person 'student)
(set+ mary build 'tall)
(set+ mary build 'thin)
(set mary like orange)
(set mary like apple)
(new 'john 'person 'engineer)
(set+ john gender 'male)
(set john like mary)
(new 'A 'group)
(new 'B 'group)
(new 'C 'group)
(set A has john)
(set A has mary)
(set A has apple)
(set B has john)
(set B has mary)
(set B has orange)
(set C has mary)
(set C has apple)
(set C has orange)
(; **************************************)
(; Verify COMMUTATIVE: (= (& A B)
(& B A)) )
(& (get B has *) (get A has *)))
(; Verify COMMUTATIVE: (= (| A B)
(| B A)) )
(; Gets john, mary, apple,
john, mary, orange)
(| (get B has *) (get A has *)))
(; **************************************)
(; Demo ASSOCIATIVE: (= (& A (& B C))
(& (& A B) C)) )
(& (& (get A has *) (get B has *)) (get C has *)))
(; Demo ASSOCIATIVE: (= (| A (| B C))
(| (| A B) C)) )
(; Gets john, mary, apple,
john, mary, orange,
mary, apple, orange)
(| (| (get A has *) (get B has *)) (get C has *)))
(; **************************************)
(; Verify IDEMPOTENT: (= (& A A)
(; Verify IDEMPOTENT: (= (| A A)
(; **************************************)
(; Verify ABSORBTIVE: (= (| (& A B) B)
B) )
(; Gets john, mary
john, mary, orange)
(get B has *))
(; Verify ABSORBTIVE: (= (& (| A B) B)
B) )
(; Gets john, mary
john, mary, orange)
(get B has *))
More details at www.dbfordummies.com/example Received on Sat Jan 13 2007 - 16:13:08 CST
![]() |
![]() |