0

I have an entity Person with property employers which is collection (and other profile information such as full name). Also I have an entity Employers with property employers which is collection too (and also some general information such as name). It is a many-to-many bidirectional association (I want both to get employers associated with a person and employees associated with the employer). Now I want to associate some data with a mapping (e.g. job position or when the person was hired).

The original idea was to create a class which extends Employer and adds required properties. But this is not possible because it is a bidirectional association.

Other idea is to create a new Entity which has references to Person, Employer and required properties (e.g. job position). I can't see any disadvantages at the moment in this solution.

Is there a better way to do it (in other words, are there potential disadvantage that I missed)?

4

1 に答える 1

0

この多対多の例はほとんど教科書です。ほぼ確実に、「リンクテーブル」を指す2つの1対多の関係に分解する必要があります。欠点は余分な結合ですが、ほとんどのデザインはOLTPデータベースでこのパターンを利用します。

于 2012-05-31T22:22:39.033 に答える