duanaozhong0696 2016-02-05 10:02
浏览 60
已采纳

将Vehicle Entity连接到ProductinOrder实体中的Product Entity

I'm building a shop for a roadhelp company an I'm stuck on how to connect two of my Entities in the best way.

Here is a brief summary of the Entities:

Orders: This is where all the basic order data is. (PK = orderid, ipaddress, etc)

Product: This contains a productid as PK, name, price etc. This can be a subscription to a Roadhelp product but it can also be a showel you buy together with a subscription.

ProductinOrders: This contains foreign keys to Orders and Product. The PK is orderid, productid and weight. It also contains a field for whether or not the product can be removed from the order.

And now for the "bastard"...

I also have a Vehicle Entity where the PK are orderid (from Orders) and Licenseplate. The Entity contains data like Make, Model, Variant etc. (This data is retrieved when the customer enters the licenseplate in the form).

The customer should be able to buy as many subscriptions as he/she wants to in the same "flow". Therefore I need to keep Vehicle and the subscription Product in the ProductinOrders in sync.

To make a long story short... sigh

When the customer as entered the Licenseplate I need to be able to connect the licenseplate with a specific product.

Regards, Lars Hansen

  • 写回答

1条回答 默认 最新

  • douba9654 2016-02-05 11:19
    关注

    My advice is that you should connect your entities like in real world. So: Orders ManyToMany Product, User OneToMany/ManyToMany Vehicle (it depends), Vehicle ManytoMany Product

    You'll be able to find Vehicle for signed User, Products for the specified Vehicle and also Products in the specified Order

    Of course you have to think about updating and persisting both sides of relatinships of entites in your entities methods.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog