Hi Brian, Welcome to the OFBiz community.
It seems to me that you are mixing two different things, but I might be misunderstanding you. The one thing is related to creating a unique key based on the fromDate in combination with the other elements of the primary key. As an example, have a look at the following (excerpt) of the entity ProductCategoryMember : <prim-key field="productCategoryId"/> <prim-key field="productId"/> <prim-key field="fromDate"/> When looking at following data definitions, you'll see that nothing more is needed to create a unique primary key: 1. <ProductCategoryMember productCategoryId="100" productId="GZ-1000" fromDate="2001-05-13 12:00:00.0"/> 2. <ProductCategoryMember productCategoryId="100" productId="GZ-1001" f romDate="2001-05-13 12:00:00.0"/> 3. <ProductCategoryMember productCategoryId="101" productId="GZ-1001" f romDate="2001-05-13 12:00:00.0"/> 4. <ProductCategoryMember productCategoryId="101" productId="GZ-1001" f romDate="2002-05-13 12:00:00.0"/> 5. <ProductCategoryMember productCategoryId="100" productId="GZ-1001" f romDate="2002-05-13 12:00:00.0"/> Item 1 and 2 are different because the productIds are different. Item 2 and 3 are different because the productCategoryIds are different Item 3 and 4 are different because the fromDates are different Now, items 2 and 5 are a bit odd, as both productCategoryIds and productIds are the same, but the fromDates are different. One could say that there is not enough information to determine uniqueness. Thus here comes the thruDate field into play. So let us extend those two data definitions. 1. <ProductCategoryMember productCategoryId="100" productId="GZ-1001" f romDate="2001-05-13 12:00:00.0" thruDate="2005-05-13 12:00:00.0" /> 2. <ProductCategoryMember productCategoryId="100" productId="GZ-1001" f romDate="2001-05-13 12:00:00.0" thruDate="2006-05-13 12:00:00.0" /> 3. <ProductCategoryMember productCategoryId="100" productId="GZ-1001" f romDate="2006-05-13 12:00:00.0" thruDate="2011-05-13 12:00:00.0" /> But does that make any sense? In the case of items 1 and 2 the end date (thruDate) is different, but basically the same information set. It would be sufficient to just have 1 record with having the correct end date, as the start date doesn't change. 1. <ProductCategoryMember productCategoryId="100" productId="GZ-1001" f romDate="2001-05-13 12:00:00.0" thruDate="2006-05-13 12:00:00.0" /> 2. <ProductCategoryMember productCategoryId="100" productId="GZ-1001" f romDate="2006-07-13 12:00:00.0"/> Now item 2 defines a new unique record that supersedes item 1 (based on fromDate), but that also determines a new applicability (in/over time) as item 1 is valid from 2001-05-13 up to 2006-5-13. So have following (hypothetical) current dates into play: 1. current date = 2000-06-13 2. current date = 2002-05-13 3. current date = 2006-06-01 4. current date = 2006-08-01 5. current date = 2016-08-09 - with current date 1: items 1 and 2 are both in the future, both not valid at current date - with current date 2: item 1 is valid at current date, item 2 is in the future - with current date 3: item 1 is in the past and item 2 is in the future, both not valid at current date - with current date 4: item 1 is in the past, and item 2 is valid at current date - with current date 5: item 1 and 2 are both in the past, but item 2 is superseding item 1 and has an no thruDate. This makes item 1 not valid at current date but item 2 valid (as it has an open end). As you can see from above examples, the thruDate is not required to determine record uniqueness. It only determines applicability in time. With respect to OFBiz, the UDM regarding the lifespan fields (fromDate - thruDate) defined by Len Silverston are not applied to its fullest in various entity definitions to determine the applicability/relationship between two records from different entities. I have created a JIRA issue for this (with some sub tasks), see https://issues.apache.org/jira/browse/OFBIZ-5959 I trust the above will help you understand. Should you have any more questions and/or remarks, feel free to post them here or contact me directly. Best regards, Pierre Smits ORRTIZ.COM <http://www.orrtiz.com> OFBiz based solutions & services OFBiz Extensions Marketplace http://oem.ofbizci.net/oci-2/ On Tue, Aug 9, 2016 at 1:02 AM, Brian Ghidinelli <br...@vfive.com> wrote: > > I'm a big fan of Silverston and his UDM books and have been studying OfBiz > extensively. I was wondering if anyone can explain why his entities with > from/thru date use the from date instead of the thru date in the composite > keys? It seems like you would want to enforce only one version is ever > active at a time by uniquely indexing the thru date as null (or a magic end > date, or infinity in Postgres). > > I'd be very appreciative of any theory explanations on the use of from > date instead of thru date? > > Brian >