[elephant-devel] using association slots

Ian Eslick eslick at media.mit.edu
Thu Jun 19 13:01:28 UTC 2008


Hi Lukas,

Were you able to try this example again using the latest checkin?   
Early feedback is better than later!

Thanks,
Ian

On Jun 17, 2008, at 3:23 PM, LukasGiessmann wrote:

> 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
>
> _______________________________________________
> elephant-devel site list
> elephant-devel at common-lisp.net
> http://common-lisp.net/mailman/listinfo/elephant-devel




More information about the elephant-devel mailing list