Programming a one-to-many relationship

后端 未结 8 794
醉话见心
醉话见心 2020-12-25 08:16

So I am surprised that doing a search on google and stackoverflow doesn\'t return more results.

In OO programming (I\'m using java), how do you correctly implement a

8条回答
  •  甜味超标
    2020-12-25 08:34

    I know this is late but I think another way to this would be to look at the problem a bit differently. Since customer holds a collection of all jobs assigned by or completed for a customer, you could consider the job class to be a sub class of customer with extra information of having all the jobs completed by the customer. Then you would only have to maintain customer id in the main class and it would be inherited. This design would ensure that each job can be linked to a customer. Also if for a customer you want to find out how many jobs are present that too also would be got.

提交回复
热议问题