[elephant-devel] using association slots

LukasGiessmann inf1045 at fh-worms.de
Tue Jun 17 19:23:02 UTC 2008


hello,

just in case you're wondering why i'm coming up with questions concerning
marc's topic "associations in the elephant system", i'm trying to assist
him with this topic, so there might be several questions coming up in the
next time - hope you don't mind.
to get straight to the point:

1)
i tried to work with the last person/job example and the new association
slots, so i made the following example:

---
(defpclass job()
  ((title :initarg :title :accessor title-of :index t)
   (company :initarg :company :accessor company-of :index t)))

(defpclass person()
  ((name :initarg :name :accessor name-of :index t)
   (job :initarg :job :accessor job-of :associate t)))


(defvar *max-persons* 500)
(defvar *max-jobs* 100)

(defun make-instances ()
  (with-transaction ()
    (dotimes (i *max-jobs*)
      (let ((current-job (make-instance 'job :title (string (gensym))
:company (string (gensym)))))
	(dotimes (j (/ *max-persons* *max-jobs*))
	  (make-instance 'person :name (string (gensym)) :job current-job))))))
---

after the call of make-instances there are 100 jobs and for every job
there exist 5 persons.
but i have still the following problem:
how can i get all persons which associate a certain job by using the
instance of the job which should be associated by the persons.
i thought on something like:

---
(defvar *obj* (first (get-instances-by-class 'job)))
(get-instance-by-value 'person 'job *obj*)
---


2)
what is the better way for using association slots in your opinion,
the one of the example above or a special class which contains only
associations of jobs and persons?

---
(defpclass p-j-assoc()
  ((job :initarg :job :accessor job-of :associate t)
   (person :initarg :person :accessor person-of :associate t)))
---


3)
how do i work with many-to-many association slots, since it is not
possible for me to assign a value to the slot.

thank you in advance.


best regards

lukas




More information about the elephant-devel mailing list