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 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)