如何设计 Z 表示法中的搜索操作,搜索功能至少需要一个细节?
How do I design a search operation in Z notation whereby the search function requires at least one details?
这是我的约会数据库的 Z 架构。
|--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)
|-----------------------------
我想创建一个搜索功能,根据 attendees
的姓名查找约会。
- 我希望搜索功能return约会对象的所有详细信息。
如何设计?
这是我的看法:
|--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?}|)
|----------------------------------------------------------------------
您是否检查过规格?
您的声明 subject? : P Person
声明 subject?
是一组人,但 subject? : dom(attendees)
暗示 subject?
是一个人。
如果你想要 none 或一个给定的人,你可以引入一种类似于函数式编程语言中的 Maybe monad 的数据类型(或其他编程语言中的空值):
MaybePerson ::= NoPerson | JustPerson <<Person>>
然后你可以像这样声明一个输入
subject? : MaybePerson
那么我会建议限制一个输入的可能解决方案
subject? : ran(JustPerson) => schedule! : schedule(|{ JustPerson~ subject? }|)
如果 subject?
是一组人,您可以通过以下方式实现相同的目标:
subject? /= {} => schedule! : schedule(|subject?|)
然后对其他可能的输入做同样的事情。您还可以添加一个条件,即不是两个条目都应该是 NoPerson
resp。并非两个输入集都应为空。
这是我的约会数据库的 Z 架构。
|--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)
|-----------------------------
我想创建一个搜索功能,根据 attendees
的姓名查找约会。
- 我希望搜索功能return约会对象的所有详细信息。
如何设计?
这是我的看法:
|--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?}|)
|----------------------------------------------------------------------
您是否检查过规格?
您的声明 subject? : P Person
声明 subject?
是一组人,但 subject? : dom(attendees)
暗示 subject?
是一个人。
如果你想要 none 或一个给定的人,你可以引入一种类似于函数式编程语言中的 Maybe monad 的数据类型(或其他编程语言中的空值):
MaybePerson ::= NoPerson | JustPerson <<Person>>
然后你可以像这样声明一个输入
subject? : MaybePerson
那么我会建议限制一个输入的可能解决方案
subject? : ran(JustPerson) => schedule! : schedule(|{ JustPerson~ subject? }|)
如果
subject?
是一组人,您可以通过以下方式实现相同的目标:subject? /= {} => schedule! : schedule(|subject?|)
然后对其他可能的输入做同样的事情。您还可以添加一个条件,即不是两个条目都应该是 NoPerson
resp。并非两个输入集都应为空。