我知道现在可以做到! [英] I know it can be done now!

查看:78
本文介绍了我知道现在可以做到!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在业余时间,我一直在尝试为我的小组中的

员工创建一个Access数据库超过一个月。当我在访问圣经中读到$ 2 $
表中的主键之间的关系必须是1:1时,我感到很惊讶!我无法想象为什么存在这种限制!

我甚至在这里问过,但没有得到满意的答案。我的情况是

我有一份员工列表,每个员工都有一个Employee

ID的主键,以及一个计算机列表,每个计算机都有一个主键是Computer ID 。

但是有些电脑是笔记本电脑,并借给台式电脑借给人们b / b
。所以我需要在

员工ID和计算机ID之间建立一对多的关系。 Access 2000圣经说我不能这样做

如果它们都是他们表中的主键,那就是它们。

今天,我加载了示例文件这本书附带的。猜猜是什么?

两张桌子之间有一段关系,在他们的主要
键之间,就是1:很多!我知道完全禁止这样的关系是没有意义的。

所以现在我想知道,我该如何建立这种关系?我注意到

示例文件中的一个表有多个主键。我不知道怎么可能,但我想你可以在

Access中做到这一点,所以它没有任何意义。那部分诀窍

在主键之间创建1:很多关系?如果是这样的话,

其余部分是什么?

感谢您的帮助!

Have been trying, in my spare time, to create an Access db for the
employees in my group for over a month. It surprised me when I read in
the Access Bible that a relationship between the Primary Keys in 2
tables had to be 1:1! I couldn''t imagine why this restriction existed!
I even asked here, but didn''t get satisfactory answers. My situation is
that I have a list of employees, each having a primary key of Employee
ID, and a list of computers, each having a primary key of Computer ID.
But some of the computers are laptops, and get loaned out to people
with desktops. So I need to create a one to many relationship between
employee ID and computer ID. The Access 2000 Bible says I can''t do it
if they are both the primary key in their table, which they are.
Today, I loaded the sample files that come with the book. Guess what?
There is a relationship between 2 of the tables, between their primary
keys, that is 1:many! I knew it didn''t make sense to prohibit such a
relatsionship entirely.
So now I want to know, how do I create such a relationship? I noticed
that the one table in the sample file had multiple primary keys. I
don''t understand how that''s possible, but I guess you can do it in
Access, so it doesn''t have to make any sense. Is that part of the trick
to create a 1:many relationship between primary keys? If so, what is
the rest of it?
Thanks for your help!

推荐答案

davegb< da **** @ safebrowse.com>写道:
davegb <da****@safebrowse.com> wrote:
在业余时间,我一直在尝试为我的团队中的
员工创建一个Access数据库超过一个月。当我在访问圣经中读到2
表中的主键之间的关系必须是1:1时,我感到很惊讶!


你确定吗?或者他们是说你不能拥有多对多的b
关系?

我无法想象为什么存在这种限制!


它没有。

我甚至在这里问过,但没有得到满意的答案。我的情况
是我有一份员工清单,每个员工都有一个
员工ID的主键,以及一个计算机列表,每个计算机都有一个主键为
计算机ID。但是有些计算机是笔记本电脑,并且可以借给台式机的人借出。所以我需要在员工ID和计算机ID之间创建一对多的关系。 Access 2000
圣经说,如果它们都是他们
表中的主键,我就不能这样做。


tblEmployee - < tblComputers


您当然可以在

tblEmployee.EmployeeID和tblComputers.EmployeeID之间建立一对多的关系。这允许每个

员工与许多计算机相关联,但每台计算机只能与一名员工关联



注意:


- 如果表中已有数据,则可能会阻止创建关系

(例如,如果你有一个tblComputers.EmployeeID值,那么

在tblEmployees中不存在。)


- 你没有关联主键。您将
tblEmployee(EmployeeID)中的主键与tblComputers(EmployeeID)中的字段相关联。

今天,我加载了来自
的示例文件书。你猜怎么着?
表之间,主键之间有一个关系,就是1:很多!我知道完全禁止这种关系是没有意义的。
所以现在我想知道,我该如何建立这种关系呢?我注意到示例文件中的一个表有多个主键。


不是。你不可能有多个主键,但是你可以有其他

键不是主键。

我不知道怎么做这是可能的,但我想你可以在访问中做到这一点,所以它没有任何意义。是否可以在主键之间创建1:多关系?如果是这样的话,
剩下的是什么?
感谢您的帮助!
Have been trying, in my spare time, to create an Access db for the
employees in my group for over a month. It surprised me when I read in
the Access Bible that a relationship between the Primary Keys in 2
tables had to be 1:1!
You sure? Or were they saying that you can''t have many-to-many
relationships?
I couldn''t imagine why this restriction existed!
It doesn''t.
I even asked here, but didn''t get satisfactory answers. My situation
is that I have a list of employees, each having a primary key of
Employee ID, and a list of computers, each having a primary key of
Computer ID. But some of the computers are laptops, and get loaned
out to people with desktops. So I need to create a one to many
relationship between employee ID and computer ID. The Access 2000
Bible says I can''t do it if they are both the primary key in their
table, which they are.
tblEmployee -< tblComputers

You can certainly create a one-to-many relationship between
tblEmployee.EmployeeID and tblComputers.EmployeeID. This allows each
employee to be associated with many computers, but each computer can
only be associated with one employee.

Note:

- If you already have data in the table it may prevent a relationship
being created (eg. if you have an tblComputers.EmployeeID value that
doesn''t exist in tblEmployees).

- You aren''t relating the primary keys. Your relating the primary key in
tblEmployee (EmployeeID) to a field in tblComputers (EmployeeID).
Today, I loaded the sample files that come
with the book. Guess what? There is a relationship between 2 of the
tables, between their primary keys, that is 1:many! I knew it didn''t
make sense to prohibit such a relatsionship entirely.
So now I want to know, how do I create such a relationship? I noticed
that the one table in the sample file had multiple primary keys.
It isn''t. You can''t have mutliple primary keys, but you can have other
keys that aren''t primary.
I
don''t understand how that''s possible, but I guess you can do it in
Access, so it doesn''t have to make any sense. Is that part of the
trick to create a 1:many relationship between primary keys? If so,
what is the rest of it?
Thanks for your help!




听起来你需要更多关于数据库理论的研究: 0

-

问候,


布拉德利


基督徒的回应
http://www.pastornet.net.au/response


听起来你需要创建一个第三个表来保存这些字段

外键EmployeeID,ComputerID,(可选 - 解释性文本 -

解释链接的原因)。现在将您的EmployeeID从

员工表(主键)链接到第3表的EmployeeID(1-many)和

将ComputerID从计算机表(主键)链接到ComputerID of第3页

表(1-many)。除此之外,在第3个表格中,使用

EmployeeID和ComputerID组合一个唯一键。实际上,第3张
表是连接表或连接表。


HTH


Steve。

Sounds like you need to create a 3rd table which holds these fields as
foreign keys EmployeeID, ComputerID, (optional - explanatory text -
explaining reason for the link). Now link your EmployeeID from
Employee table (primary key) to EmployeeID of 3rd table (1-many) AND
link ComputerID from Computer table (primary key) to ComputerID of 3rd
table (1-many). Further to this, within the 3rd table, make
EmployeeID and ComputerID a combine unique key. Effectively the 3rd
table is a linking table or joining table.

HTH

Steve.


su ********* @ gmail.com 写道:
听起来你需要创建一个第三个表,它将这些字段保存为外键EmployeeID,ComputerID,(可选 - 解释性文本 -
解释链接的原因)。现在将您的EmployeeID从
员工表(主键)链接到第3表的EmployeeID(1-many)并将计算机表(主键)中的ComputerID链接到3rd表的ComputerID(1 -许多)。此外,在第3个表中,使EmployeeID和ComputerID成为组合唯一键。实际上,第3张表是连接表或连接表。

HTH

史蒂夫。
Sounds like you need to create a 3rd table which holds these fields as
foreign keys EmployeeID, ComputerID, (optional - explanatory text -
explaining reason for the link). Now link your EmployeeID from
Employee table (primary key) to EmployeeID of 3rd table (1-many) AND
link ComputerID from Computer table (primary key) to ComputerID of 3rd
table (1-many). Further to this, within the 3rd table, make
EmployeeID and ComputerID a combine unique key. Effectively the 3rd
table is a linking table or joining table.

HTH

Steve.



这是怎么回事实现多对多关系。我不认为

是必要的,因为计算机一次只能与一个

员工相关联(这就是我如何理解他是什么无论如何说:)。

因此你只需要将EmployeeID添加到计算机表中并且

有一个(员工)对多(计算机)关系。

-

问候,


布拉德利


基督徒的回应
http://www.pastornet.net.au/response


这篇关于我知道现在可以做到!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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