Different between 'o' and arrow symbol use

2019-04-10 21:25发布

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条回答
啃猪蹄的小仙女
2楼-- · 2019-04-10 21:30

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 -->.

查看更多
登录 后发表回答