OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

odata-comment message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: DiscontinuedProducts is a really bad example


Also, I believe Section 13.3.1 of the CSDL (Attribute Path) incorrectly states "navigation property bindings are only used when all related entities are known to come from a single entity set".  I believe it is pretty much the reverse --- they are only necessary when related entities are known to come from multiple entity sets; otherwise the navigation property binding can be derived and it is superfluous to explicitly specify it.

Section 7.1.4 of the CSDL (Attribute Partner) should perhaps specify something similar -- that the partner attribute is only necessary when an entity type or its subtypes that participates in the relationship on either side have more than one navigation property to the type on the other side of the relationship; otherwise the partner can be derived and it is superfluous to explicitly specify it.


On Mon, May 13, 2013 at 1:05 PM, Ron Dagostino <rndgstn@gmail.com> wrote:
I believe the example below helps to illustrate when NavigationProperty.Partner and EntitySet.NavigationPropertyBinding are superfluous vs. required.  Using Mike's example, Order and Customer instances are segmented across Eastern vs. Western region entity sets; furthermore, for illustration, Order has a relationship to Product, and Product is not segmented by region.  It seems to me that NavigationProperty.Partner is required when disambiguation between multiple possible partners is necessary, and EntitySet.NavigationPropertyBinding is required when disambiguation between multiple possible entity sets is necessary.  It is superfluous to specify when a relationship is unidirectional, but it may not be clear at a glance, so perhaps adding an optional "Unidirectional" attribute to NavigationProperty would be helpful (though its default value cannot be simply false, which means perhaps adding it isn't such a good idea after all because its value would have to match the value that it is constrained to be -- so perhaps just putting in a comment somehow is best).  Anyway, I think it would be more than helpful to eliminate the "DiscontinuedProduct" example in favor of something like Mike's example and also provide information on how/when to use Partner and NavigationPropertyBinding.

Ron

(EntityType.Order).Customer.Type = Customer
(EntityType.Order).Customer.Partner = Orders (superfluous when Customer has only 1 navigation property to Order entities)
 
(EntityType.Customer).Orders.Type = Collection(Order)
(EntityType.Customer).Orders.Partner = Customer (superfluous when Order has only 1 navigation property to Customer entities)
 
(EntitySet.EasternRegionOrders).NavigationPropertyBinding.Path = Customer
(EntitySet.EasternRegionOrders).NavigationPropertyBinding.EntitySet = EasternRegionsCustomers (required to disambiguate Eastern/WesternRegionCustomers)
(EntitySet.WesternRegionOrders).NavigationPropertyBinding.Path = Customer
(EntitySet.WesternRegionOrders).NavigationPropertyBinding.EntitySet = WesternRegionCustomers (required to disambiguate Eastern/WesternRegionCustomers)
 
(EntitySet.EasternRegionCustomers).NavigationPropertyBinding.Path = Orders
(EntitySet.EasternRegionCustomers).NavigationPropertyBinding.EntitySet = EasternRegionOrders (required to disambiguate Eastern/WesternRegionOrders)
(EntitySet.WesternRegionCustomers).NavigationPropertyBinding.Path = Orders
(EntitySet.WesternRegionCustomers).NavigationPropertyBinding.EntitySet = WesternRegionOrders (required to disambiguate Eastern/WesternRegionOrders)
 
 
(EntityType.Product).EasternRegionOrders.Type = Collection(Order)
(EntityType.Product).EasternRegionOrders.Partner = Products (superfluous when Order has only 1 navigation property to Product entities)
(EntityType.Product).WesternRegionOrders.Type = Collection(Order)
(EntityType.Product).WesternRegionOrders.Partner = Products (superfluous when Order has only 1 navigation property to Product entities)
 
(EntityType.Order).Products.Type = Collection(Product)
(EntityType.Order).Products.Partner = <<<must be omitted because it is ambiguous: both EasternRegionOrders and WesternRegionOrders are valid>>>
 
(EntitySet.Products).NavigationPropertyBinding.Path = EasternRegionOrders
(EntitySet.Products).NavigationPropertyBinding.EntitySet = EasternRegionOrders (required to disambiguate Eastern/WesternRegionOrders)
(EntitySet.Products).NavigationPropertyBinding.Path = WesternRegionOrders
(EntitySet.Products).NavigationPropertyBinding.EntitySet = WesternRegionOrders (required to disambiguate Eastern/WesternRegionOrders)
 
(EntitySet.EasternRegionOrders).NavigationPropertyBinding.Path = Products
(EntitySet.EasternRegionOrders).NavigationPropertyBinding.EntitySet = Products (superfluous when Products is the only EntitySet of type Product)
(EntitySet.WesternRegionOrders).NavigationPropertyBinding.Path = Products
(EntitySet.WesternRegionOrders).NavigationPropertyBinding.EntitySet = Products (superfluous when Products is the only EntitySet of type Product)




On Sun, May 12, 2013 at 11:37 PM, Ron Dagostino <rndgstn@gmail.com> wrote:
Section 13 of the CSDL document gives this example:

"Other entity models may expose multiple entity sets per type. For instance, an entity model may have the following entity sets:

<EntitySet Name="Products" EntityType="Self.Product"/>
<EntitySet Name="DiscontinuedProducts" EntityType="Self.Product"/>

"

This is a really bad example at best.  It means a Product instance changes its entity set when it becomes discontinued, and that means any existing relationships to it become illegal.  There are still Order instances that need to refer to it (assuming it was ordered before it was discontinued), but now they can't intuitively refer to it because it doesn't exist in the Products entity set anymore -- it moved to the DiscontinuedProducts entity set.  An Order entity would need to a DiscontinuedProduct navigation property in order to refer to it.

Mike Pizzo provides a better example of exposing a single type across multiple entity sets here (http://mailinglist.odata.org/scripts/wa-ODATA.exe?A2=ODATA;bc4700a0.1302).  Including this example would not only provide a correct example, but it would also demonstrate a situation where the new NavigationPropertyBinding element of EntitySet is required in order to disambiguate the target entity sets of navigation properties.

Way to go on the whole simplification of relationships and removal of Association and AssociationSet.

A clearly articulated example of unidirectional relationships along with when EntitySet.NavigationPropertyBinding and NavigationProperty.Partner are optional vs. required would be helpful.  Right now they are labelled SHOULD and MAY, respectively, but there are cases where they are required (Mike's example above I believe is one of them), and it would be helpful if the docs gave good examples that fully described when these optional elements are actually required.  It is also potentially confusing because the lack of a Partner attribute could be misconstrued as meaning the relationship is unidirectional.  It might be best to add a "Unidirectional" attribute to the NavigationProperty element that defaults to false but must be set to true when the relationship is unidirectional -- then the lack of a Partner attribute alone cannot be misconstrued as implying a unidirectional relationship when in fact it is simply omitted because it adds no meaning in a particular context.

Ron





[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]