Many to Many in Access

爱⌒轻易说出口 提交于 2019-12-24 06:07:09

问题


I'm trying to ether get rid of a real world many-to-many relationship (and just feeling stupid for not being able to) or find the proper way to input it into Access. I've tried several junction table setups and only seem to pass the many-to-many problem on to another table.

Here is an abbreviated sample of the two tables:

Table 1:

Amp_Number      Amp_S.Name
103             Rag1
194             Osd4
230             Lew6
321             Ooi4
550             Qwd3
629             Crd5
687             Rab4
879             Pra2

Table 2:

Plas_Number         Plas_Amp
55                  Rab4
82                  Osd4 & Qwd3 & Lew6
94                  Rab4 & Rag1 & Ooi4
102                 Ooi4 & Lew6
125                 Pra2 & Rag1 & Crd5
142                 Qwd3 & Ooi4 & Rag1
146                 Lew6 & Osd4 & Rab4
154                 Rab4 & Lew6 & Ooi4

回答1:


You need a junction table mapping the Plas_Number to Amp_Number, which can have one or more records for either Table 1 or Table 2:

Table 1:

Amp_Number      Amp_S.Name
103             Rag1
194             Osd4
230             Lew6
321             Ooi4
550             Qwd3
629             Crd5
687             Rab4
879             Pra2

Table 2:

Plas_Number
55
82
94
102
125
142
146
154

Junction Table:

Plas_Number    Amp_Number
55             687
82             194
82             550
82             230
etc.
  • There is a one-to-many between Table 1 and Junction Table
  • There is a one-to-many between Table 2 and Junction Table


来源:https://stackoverflow.com/questions/15347722/many-to-many-in-access

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!