一对一关系建模 [英] One to One relationship modeling
问题描述
我正在使用 access 2010 来执行此操作.
I am using access 2010 to do this.
我创建了两个表,我想将它一对一地建立起来,但我似乎无法将其建立为一对一的关系.
I have created two tables and I would like to get it one to one and i don't seem to get it in to one to one relationship.
CREATE TABLE Person(
ID VARCHAR(1) UNIQUE,
Name VARCHAR(30),
PRIMARY KEY (ID)
);
CREATE TABLE Passport(
ID VARCHAR(1) UNIQUE,
Country VARCHAR(30),
PRIMARY KEY (ID),
FOREIGN KEY (ID) REFERENCES Person(ID)
);
据我所知,这应该是一对一的关系,但它是一对多的.如何通过 ACCESS 一对一获取?
From the little knowledge that I have, This should be a one to one relationship but it is a one to many. How do I get it one to one via ACCESS?
我尝试了大多数可以在书中找到的东西,但都没有成功.
I have tried most things that I can find in books but with no success.
请帮忙.
推荐答案
您可能只是被关系"窗口中关系的显示方式所误导.我运行了你的确切 DDL,当我在关系"窗口中查看关系时,它看起来就像一对多......
You may simply be misled by the way relationships are displayed in the Relationships window. I ran your exact DDL and when I view the relationship in the Relationships window it looks like one-to-many...
...但是当我右键单击连接两个表的行并选择编辑关系..."时,对话框显示它实际上是一对一的:
...but when I right-click on the line joining the two tables and choose "Edit Relationship..." the dialog shows that it is actually one-to-one:
这篇关于一对一关系建模的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!