Different between 'o' and arrow symbol used in .cto file?

馋奶兔 提交于 2019-12-12 08:56:42

问题


I am bit confused between 'o' and '-->' used in Model file, For example :

asset Field identified by assetId {
    o String assetId
    o Customer owner
    --> Customer custId
}

participant Customer identified by customerId {
    o String customerId
} 

what is difference between "o Customer owner" and "--> Customer custId"?


回答1:


The o indicates that this is an owned property of a class. Aka a "field". That means that when the instance of the class is removed, so are all its properties.

The --> indicates that this is a relationship to another addressable resource. Aka a pointer or primary/foreign key entity relationship.

In your example, your asset Field has a property or type Customer called owner. When instances of Field are deleted the instances of Customer that they are storing in the owner property are also deleted.

The Field asset also has a relationship to a Customer instance stored in a property called custId. Deleting an instance of Field will not delete the instance of Customer that is being pointed to by the relationship.

Composer relationships are essentially typed-pointers. They are a fully-qualified type name of the resource that is being pointed to, as well as the identified of the instance that is being pointed to.

In Composer relationships do not cascade-delete, and there is no referential integrity checking for relationships. It is up to the application to check whether the resource that is at the end of a relationship exists or not, and to respond appropriately.

Note that in the future we may prevent using o with assets and participants. It really doesn't make much sense and is confusing for people that expect to find them in their respective registries. For assets and participants people should use -->.



来源:https://stackoverflow.com/questions/44410459/different-between-o-and-arrow-symbol-used-in-cto-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!