我需要连接表吗? [英] Do I need a junction table?

查看:69
本文介绍了我需要连接表吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在集装箱跟踪应用程序中标准化我的表格,并且得到了一个名为shipping的表格,该表格需要跟踪:-集装箱密封,车辆登记和拖车登记以及到来等信息.
有时,这批货物是在公路火车上行驶的,需要两个或什至三个密封件.
在这种情况下,这是建立表格的最佳方法吗?

tblShipments-ShipmentID-PK
ShipSealID-FK
卡车编号
TrailerNo

tblShipSeals-ShipSealID-PK
货件编号-FK
SealID-FK

tblSeals-SealID-PK
SealNo

请提供任何帮助,数据库是Access2007.

I am trying to normalise my tables in a container tracking application, and have got a table called shipments that needs to keep track of:- the container seal, the vehicle registration and the trailer registration as well as arrivals and such.
Sometimes the shipment goes on a road train vehicle and requires two or even three seals.
In this case would this be the best way to go about setting up the tables?

tblShipments - ShipmentID - PK
ShipSealID - FK
TruckNo
TrailerNo

tblShipSeals - ShipSealID - PK
ShipmentID - FK
SealID - FK

tblSeals - SealID - PK
SealNo

Any help would be appreciated please, Database is Access 2007.

推荐答案

建模时,要比现实世界更进一步.您的货件可能需要盖章,但是您的印章不需要知道货件吗?

When you modeling, look further than the real world it self. Your shipment may need a seal, but your seal does not need to know about the shipment, or does it?

tblShipment - ID - PK
              Description - Describes your shipment (You may or many not need this)
              TruckNo
              TrailerNo
              SealID - FK

tblSeal     - ID - PK
              Type - (Maybe there are different seals)
              Description - Describes your seal (may no be needed)




请注意,我已经提出了一些建议,而不是您需要它们.您需要考虑模型,看看什么对您有意义,什么对您没有意义.




Mind you I have thrown some more fields as suggestion, not that you need them. You need to think about your model and see what makes sense for you and what does not.


您不应显示所示的tblshipment和tblshipseals设置.在出货表中,您不需要shippesid,而无需shipeals表.
You should not have tblshipments and tblshipseals setup as displayed. In the shipments table you do not need the shipsealid us the shipseals table for that.


这篇关于我需要连接表吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆