为内容建模的设计模式

Design pattern to model content

我正在寻找解决这种情况的最佳方法:

一件商品P可以从X家不同的Shops购买,每家商店对商品P的价格不同。

以下是我的模型,什么是存储和显示所有商店给定产品价格的最佳方式。 .

@Entity
public class Product extends Model {
    @Required
    public String name;
    @Required
    double price;
}


@Entity
public class Shop extends Model {
@Required
    public String name;
    public ArrayList<Product> products = new ArrayList<>();

}

因此,在此模型中,productsshops 之间存在多对多关系。 现在在您的模型中,它仅从 Shops 端反映出来,但您也可以创建代表此产品的商店的 link ( List )。