Modelling Persons with Variable Classifications, Attributes and Values (with XDb3)

From: Neo <neo55592_at_hotmail.com>
Date: 16 Mar 2005 09:53:26 -0800
Message-ID: <1110995606.814603.269600_at_f14g2000cwb.googlegroups.com>



The following script for a small experimental db (XDb3) models three persons with variable number of classifications, attributes and values. Some of the classifications and attributes are created on the fly at run time. Sample queries at end.

// Create directory items to organize things.
(CREATE dir item *person)
(CREATE dir item *teacher)
(CREATE dir item *engineer)

// Create properties for persons.
(CREATE dir item *gender)
(CREATE dir item *age)
(CREATE dir item *weight)
(CREATE dir item *height)
(CREATE dir item *ss#)

// Create things for address.
(CREATE dir item *address)
(CREATE dir item *street)
(CREATE dir item *apt)
(CREATE dir item *city)
(CREATE dir item *state)
(CREATE dir item *zip)

// Create things for phone, etc.
(CREATE dir item *phone)
(CREATE dir item *fax)
(CREATE dir item *cell)
(CREATE dir item *email)

// Create qty and units
(CREATE dir item *qty)
(CREATE dir item *unit)

// Create John and his attributes.
(CREATE person inst *john

      & it gender +male
      & it height (CREATE height inst *
                        & it qty +60
                        & it unit +inch)
      & it ss# +333-44-5555
      & it fax +222-3333
      & it address (CREATE address inst *
                         & it street +"123 main st"
                         & it city +chicago
                         & it state +illinois
                         & it zip +12345))

// Create Mary and her attributes.
(CREATE person inst *mary

      & teacher inst it
      & it age +30
      & it weight (CREATE weight inst *
                        & it qty +135
                        & it unit +lb)
      & it phone +123-4567
      & it phone +333-7000
      & it address (CREATE address inst *
                         & it street +"678 elm ave"
                         & it apt +D81
                         & it city +tulsa
                         & it state +oklahoma
                         & it zip +34567))

// Create Bob and his attributes.
(CREATE person inst *bob

        & (CREATE dir item *student) inst it
        & engineer inst it
        & it age (CREATE age inst *
                       & it qty +22
                       & it unit +yr)abc
        & it (CREATE dir item *race) +chinese
        & it race +japanese
        & it cell +888-9999
        & it email +bob_at_hotmail.com
        & it email +bob_at_yahoo.com
        & it address (CREATE address inst *
                           & it street +"555 silicon dr"
                           & it city +"cupertino"
                           & it (CREATE dir item *county) +willis
                           & it state +calfornia
                           & it zip +95006)
        & it address (CREATE address inst *
                           & it street +"2-1-67 sakuragi"
                           & it city +naka
                           & it (CREATE dir item *region) +yokohama
                           & it phone +045-683-3111))

// Find faxes for persons whose height is 60 in. // Finds 222-3333.
(SELECT (person inst *

         & * height (* qty 60
                     & * unit inch)) fax *)

// Find zips for teachers who weigh 135 lb. // Finds 34567.
(SELECT ((teacher inst *

          & * weight (* qty 135
                      & * unit lb)) address *) zip *)

// Find persons who live in willis county and yokohama region. // Find bob.
(SELECT person inst *

      & * address (* county willis)
      & * address (* region yokohama))
Received on Wed Mar 16 2005 - 18:53:26 CET

Original text of this message