Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Basic Laws of Algebra / dbd Example

 
   Database Forums (Home) -> Object-Oriented RSS
Next:  Network Example: Siblings of Opposite Build  
Author Message
neo55592

External


Since: Dec 06, 2004
Posts: 480



(Msg. 1) Posted: Tue Jan 16, 2007 9:02 am
Post subject: Basic Laws of Algebra / dbd Example
Archived from groups: comp>databases>object (more info?)

The following basic laws of algebra can be found in many text books:

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.

Dbd example below shows the above with following data:

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)) )
(; Gets john and mary)
(= (& (get A has *) (get B has *))
(& (get B has *) (get A has *)))

(; Verify COMMUTATIVE: (= (| A B)
(| B A)) )
(; Gets john, mary, apple,
john, mary, orange)
(= (| (get A has *) (get B has *))
(| (get B has *) (get A has *)))

(; **************************************)
(; Demo ASSOCIATIVE: (= (& A (& B C))
(& (& A B) C)) )
(; Gets mary)
(= (& (get A has *) (& (get B has *) (get C has *)))
(& (& (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 *)))
(| (| (get A has *) (get B has *)) (get C has *)))

(; **************************************)
(; Verify IDEMPOTENT: (= (& A A)
A) )
(; Gets john, mary, apple)
(= (& (get A has *) (get A has *))
(get A has *))

(; Verify IDEMPOTENT: (= (| A A)
A) )
(; Gets john, mary, apple
john, mary, apple)
(= (| (get A has *) (get A has *))
(get A has *))

(; **************************************)
(; Verify ABSORBTIVE: (= (| (& A B) B)
B) )
(; Gets john, mary
john, mary, orange)
(= (| (& (get A has *) (get B has *)) (get B has *))
(get B has *))

(; Verify ABSORBTIVE: (= (& (| A B) B)
B) )
(; Gets john, mary
john, mary, orange)
(= (& (| (get A has *) (get B has *)) (get B has *))
(get B has *))

More examples at www.dbfordummies.com/example

 >> Stay informed about: Basic Laws of Algebra / dbd Example 
Back to top
Login to vote
Display posts from previous:   
   Database Forums (Home) -> Object-Oriented All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]