我该如何处理这种参照完整性情况? [英] How do I handle this referential integrity situation?

查看:60
本文介绍了我该如何处理这种参照完整性情况?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用2003.我为员工提供了简单的1:M关系和

分类。可以为许多员工分配分类/

员工只能有一个分类。我创建了一个表格,用于添加

员工/分类。如果不知道
,则分类可以留空。我创建了第二个表单来修改员工/分类。

如果分类留空,或者它是空白的,则会发生3201

参照完整性错误。我知道分类表中没有

空白记录,这就是错误的原因。但

是否有办法将分类留空或将其删空?我是否需要在分类查找表中添加记录,例如(没有

分类)?感谢您提供任何帮助或建议。

Using 2003. I''ve got a simple 1:M relationship for employees and
classifications. A classification can be assigned to many employees/an
employee can only have one classification. I created a form for adding
employees/classifications. The classification can be left blank if not
known. I created a 2nd form for modifying employees/classification.
If the classification is left blank, or it''s blank out, the 3201
referential integrity error occurs. I understand that there is not a
blank record in the classifications table so that''s why the error. But
is there a way to leave the classification blank or blank it out? Do I
have to put a record in the classifications lookup table, like (no
classification)? Thanks for any help or advice.

推荐答案

如果员工没有分类(并且它有效),那么你

不能强制员工之间的参照完整性和

分类。如果你将RI约束设置为none,那么

就可以了。

if an employee can have no classification (and it''s valid), then you
can''t enforce referential integrity between employees and
classifications. If you set the RI constraint to none, then everything
will be fine.


< ma ***** *****@hotmail.com>在消息中写道

news:11 ********************** @ f14g2000cwb.googlegr oups.com ...
<ma**********@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
使用2003.我为员工提供了简单的1:M关系和分类。可以为许多员工分配分类/
员工只能有一个分类。我创建了一个用于添加员工/分类的表单。如果不知道,分类可以留空。我创建了第二个表单来修改员工/分类。
如果分类留空,或者它是空白的,则会发生3201
参照完整性错误。我知道分类表中没有空白记录,所以这就是错误的原因。但是有没有办法将分类留空或将其删空?我是否必须在分类查找表中记录,如(无
分类)?感谢您提供任何帮助或建议。
Using 2003. I''ve got a simple 1:M relationship for employees and
classifications. A classification can be assigned to many employees/an
employee can only have one classification. I created a form for adding
employees/classifications. The classification can be left blank if not
known. I created a 2nd form for modifying employees/classification.
If the classification is left blank, or it''s blank out, the 3201
referential integrity error occurs. I understand that there is not a
blank record in the classifications table so that''s why the error. But
is there a way to leave the classification blank or blank it out? Do I
have to put a record in the classifications lookup table, like (no
classification)? Thanks for any help or advice.



这完全可能 - 正如您所描述的那样 - 无需任何需要

定义''无分类''记录在分类表中。还有

其他你做错了。

我的猜测是你有类似

tblEmployee.ClassificationID这是一个长整数默认值为

零。当你创建记录时,它会尝试在此字段中输入零,并且

当然你没有匹配的记录,其中tblCalssification.ID = 0.

因此,请务必检查表格设计中的任何默认值。


This is perfectly possible - just as you describe - without any need to
define a ''no classification'' record in the classifications table. There is
something else you are doing wrong.
My guess is that you have something like
tblEmployee.ClassificationID which is a long integer with a default value of
zero. When you create the record, it tries to put zero in this field, and
of course you don''t have a matching record where tblCalssification.ID=0.
So, certainly check any default values in your table design.


< pi ******** @ hotmail.com>在消息中写道

news:11 ********************** @ z14g2000cwz.googlegr oups.com ...
<pi********@hotmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
如果员工没有分类(并且它是有效的),那么您不能强制执行员工之间的参照完整性和分类。如果你将RI约束设置为无,那么一切都会没问题。
if an employee can have no classification (and it''s valid), then you
can''t enforce referential integrity between employees and
classifications. If you set the RI constraint to none, then everything
will be fine.



你确定你在说什么吗?


Are you sure of what you are saying?


这篇关于我该如何处理这种参照完整性情况?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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