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 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了