I have Customer object and Loan object. It is a one-to-many relationship (Customer <–>> Loan). Each loan has exactly 5 type of Payoff plans (exactly 5 and will not change for the next 100 years) for customer to select and to see the payment projection. Each Payoff plan consist of type, initial-payment, monthly-payment, interest, number-installments, total-payment, total-interest and payoff-date. What’s the best way to model the Payoff object?
Option 1:
Each Loan has five relationship to Payoff object representing the five different payoff plan. i.e. inside Loan object, there are 5 relationships payoffPlanA, payoffPlanB, payoffPlanC, payoffPlanD, payoffPlanE to Payoff object.
Option 2:
Each loan has a one-to-many relationship (Loan <–>> Payoff). To obtain a particular Payoff plan, the app will check from the list of Payoff objects for the type attribute of Payoff object. For example, for the app to display the content of Payoff Plan C, the app will need to traverse the list of Payoff objects for the loan and check if the type is Plan C, then retrieve the details.
Are there other options? Thanks
It doesn’t sound to me like the Payoff Plans are actually data. They sound like chunks of logic that will operate on the data supplied by
CustomerandLoanobjects. In other words, the logic of each the five plan types is generic and only the provided data produce different outputs.If so, then you probably don’t need or want Core Data entities representing the Payoff Plans. Instead, you should create ordinary i.e. non-managed objects, that accept have methods that accept a
CustomerandLoanobjects as inputs. If necessary, you can attach those to unmanaged properties (ones that don’t appear in the entity) for theCustomerandLoanclasses.If the Payoff Plans are in fact data and unique in the object graph then choice (2) is best.