在Jxn Tbl中分开PK? [英] Separate PK in Jxn Tbl?

查看:72
本文介绍了在Jxn Tbl中分开PK?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我在过去创建过联结表时,我总是将联合表的PK与

的PK结合在另外两个表中。例:表1

PK = A;表2 PK = B;连接表由两个字段A和B组成,其中
一起构成了连接表的PK。


但是,我刚刚遇到了一些代码该人创建了一个交叉点

表,其中包含一个由自动编号字段组成的单独PK,然后是两个

字段。


所以我想知道其他人如何做联结表 - 用一个独立的

自动编号PK,或者用表格的PK组成的PK是什么?b $ b加入?并且,如果是独立PK,那么为什么?


谢谢!


Neil

Whenever I''ve created junction tables in the past, I always made the PK of
the junction table the combined pks from the two other tables. Ex: Table1
PK=A; Table2 PK=B; Junction table consists of two fields, A and B, which
together comprise the PK for the junction table.

However, I just came across some code in which the person created a junction
table with a separate PK consisting of an autonumber field, and then the two
fields.

So I was wondering how others did junction tables -- with a standalone
autonumber PK, or with a PK consisting of the PKs of the tables being
joined? And, if a standalone PK, then why?

Thanks!

Neil

推荐答案

我总是只使用2个主键,但....

如果我是一个图书馆,将1本书的2个无法复制的副本借给同一个

人,我想我需要一个Autonumber PK加一个BookID和

BorrowerID。


Phil


尼尔 < no **** @ nospam.netwrote in message

news:6k *************** @ newssvr14.news.prodigy.net。 ..
I always use just the 2 primary keys but....
If I were a library lending 2 undiffentiatable copies of 1 book to the same
person, I suppose I would need an Autonumber PK plus A BookID and
BorrowerID.

Phil

"Neil" <no****@nospam.netwrote in message
news:6k***************@newssvr14.news.prodigy.net. ..

每当我在过去创建过联结表时,我总是把联合表的PK作为结合表的PK来自另外两张桌子。例:表1

PK = A;表2 PK = B;连接表由两个字段A和B组成,其中
一起构成了连接表的PK。


但是,我刚刚遇到了一些代码该人创建了一个

联结表,其中包含一个由自动编号字段组成的单独PK,然后是两个字段的



所以我想知道其他人如何做联结表 - 用一个独立的

自动编号PK,或者用表格的PK组成的PK是什么?b $ b加入?而且,如果是独立PK,那么为什么呢?


谢谢!


Neil
Whenever I''ve created junction tables in the past, I always made the PK of
the junction table the combined pks from the two other tables. Ex: Table1
PK=A; Table2 PK=B; Junction table consists of two fields, A and B, which
together comprise the PK for the junction table.

However, I just came across some code in which the person created a
junction table with a separate PK consisting of an autonumber field, and
then the two fields.

So I was wondering how others did junction tables -- with a standalone
autonumber PK, or with a PK consisting of the PKs of the tables being
joined? And, if a standalone PK, then why?

Thanks!

Neil





" Neil" < no **** @ nospam.netwrote in message

news:6k *************** @ newssvr14.news.prodigy.net。 ..

"Neil" <no****@nospam.netwrote in message
news:6k***************@newssvr14.news.prodigy.net. ..

所以我想知道其他人如何使用独立的

自动编号PK,或者使用由表格的PK是否已加入?b ​​$ b?而且,如果是独立PK,为什么呢?
So I was wondering how others did junction tables -- with a standalone
autonumber PK, or with a PK consisting of the PKs of the tables being
joined? And, if a standalone PK, then why?



PK由FK组成,引用正在连接的表格。


这是你的意思吗? />

With a PK consisting of the FKs that reference the tables being joined.

Is that what you meant?



2008年1月22日星期二20:26:42 GMT,Neil < no **** @ nospam.netwrote:
On Tue, 22 Jan 2008 20:26:42 GMT, "Neil" <no****@nospam.netwrote:

>所以我想知道别人怎么做联结表 - 用独立的
自动编号PK ,或者由表格的PK组成的PK加入?而且,如果是独立PK,为什么呢?
>So I was wondering how others did junction tables -- with a standalone
autonumber PK, or with a PK consisting of the PKs of the tables being
joined? And, if a standalone PK, then why?



我做过两件事;单独的主键是(严格来说)永远不需要
,但如果联结表本身是相关的,它可以很方便

一对多的附加表或表。访问不会使多字段

所有易于使用的外键(例如,你不能在组合框中使用它们没有一些杂乱的代码而无需使用它们。) />

如果我这样做,我将始终在两个

父外键字段上指定唯一(非主要)索引。

John W. Vinson [MVP]

I''ve done both; the separate primary key is (strictly speaking) never
necessary, but it can be handy if the junction table is itself related
one-to-many to an additional table or tables. Access doesn''t make multifield
foreign keys all that easy to use (e.g. you can''t use them in a combobox
without some messy code).

If I do so, I will always specify a unique (non-primary) Index on the two
parent foreign key fields.

John W. Vinson [MVP]


这篇关于在Jxn Tbl中分开PK?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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