30 Jul 2012 20:51
Collections versus Relational Approach in Fact Model
BenjaminWolfe <benjamin.e.wolfe <at> gmail.com>
2012-07-30 18:51:04 GMT
2012-07-30 18:51:04 GMT
I'm learning Java and Drools at the same time; please be gentle if my question is misdirected. I'm working on creating my first nontrivial fact model. A policy can have multiple vehicles; a vehicle can have multiple coverages. My data will come into the rules engine via an XML file, and be output to XML after all rules are fired. I'm looking for best practices. I've seen it suggested to use a relational approach to my object graph. A policy will have policyID 12345; its vehicles will have a policyID field, and each will have a different vehicleNumber (e.g. 1, 2 and 3). A coverage will have policyID (12345) and vehicleNumber(1), and a coverage identifier of its own. That seems simple, sleek and elegant. I hope to use it to write rules. But I wonder if it will be resource-intensive when I get to outputting the XML. I'm imagining having to write the policy node, then search all vehicles for the 3 that are related to this policy, then search through all coverages for the ones corresponding to each vehicle, etc. Is it better to include some sort of collection? (Policy 12345 might include a collection of vehicles, each of which would include a collection of coverages.) If so, what kind of collection: an implementation of set? list? map? More specifically, are there drawbacks or advantages to one approach or another? I'm very thankful for any guidance you'd like to offer. Best regards, Benjamin(Continue reading)
RSS Feed