0

This is my Z schema for Appointment DB.

|--AppointmentDB----------------
|attendees : P Person /** those involved in the appointment **/
|
|/** a new TYPE object to store attendees, schedule and purpose **/
|appointments : P APPOINTMENT
|hasAppointment : Person <-> APPOINTMENT
|schedule : APPOINTMENT -> DateTime
|purpose : APPOINTMENT -> Report 
|
|/** a forward relation compositions to relate attendees with purpose and schedule **/
|attendeePurpose : hasAppointment;purpose 
|attendeeSchedule : hasAppointment;schedule 
|-----------------------------
|attendees ⊆ dom(hasAppointment)
|attendees ⊆ dom(attendeePurpose)
|appointments ⊆ ran(hasAppointment)
|-----------------------------

I would like to create a search function that finds an appointment based on the name of the attendees.

  1. I want the search function to return all the details of the appointment object.

How do I design it?


Here is my take :

|--FindAppointment---------------------------------------------------
|ΞAppointmentDB
|attendees? : Person
|appointmentAttendees! : P Person
|appointmentPurpose! : Report
|appointmentSchedule! : DateTime
|-----------------------------
|/** if name of any attendees is given, then it must exist in appointments' domain
|respectively before this function can run**/
|attendees? ∈ dom(attendees)
|
|/** return the set of attendees of the same APPOINTMENT using attendees? as input **/
|appointmentAttendees! = hasAppointment~(|{attendees?}|)
|
|/** Get the image of both forward relational compositions according to set of 
|attendees?**/
|appointmentPurpose! =  attendeePurpose(|{attendees?}|)
|appointmentSchedule! = attendeeSchedule(|{attendees?}|)
|----------------------------------------------------------------------
John Evans Solachuk
  • 1,953
  • 5
  • 31
  • 67
  • You have a variable `attendees` defined which is a set of persons. Your comment says "those involved in the appointment". But which appointment? – danielp Apr 21 '15 at 19:12

1 Answers1

1

Have you type checked your specification? Your declaration subject? : P Person states that subject? is a set of persons, but subject? : dom(attendees) implies that subject? is a single person.

  • If you want to have either none or one person given you could introduce a datatype analogous to the Maybe monad in functional programming languages (or null values in other programming languages):

    MaybePerson ::= NoPerson | JustPerson <<Person>>
    

    Then you can declare an input like

    subject? : MaybePerson
    

    Then I would to suggest to restrain the possible solutions for one input

    subject? : ran(JustPerson) => schedule! : schedule(|{ JustPerson~ subject? }|)
    
  • If subject? is a set of persons you can achieve the same with:

    subject? /= {} => schedule! : schedule(|subject?|)
    

And then just do the same for the other possible input. You can add also a condition that not both entries should be NoPerson resp. not both input sets should be empty.

danielp
  • 1,179
  • 11
  • 26
  • I have edited my schema. Instead of having subject and object, I have combined them into attendees to make it easier. Please have a look. Thanks! – John Evans Solachuk Apr 20 '15 at 17:40