mysql大神帮帮忙

问题是这样的:我用powerDesigner设计的数据库,自动导出的sql语句建的表。其中有一个t_user表的一个字段n_dept_id,它是参考两个字段的,其中一个是t_dept的n_dept_id字段,另一个是t_out_dept的n_out_dept_id字段。mysql的语句如下:
alter table t_user add constraint FK_Reference_58 foreign key (n_dept_id)
  references t_dept (n_dept_id) on delete restrict on update restrict;

alter table t_user add constraint FK_Reference_85 foreign key (n_dept_id)
  references t_out_dept (n_out_dept_id) on delete restrict on update restrict;

问题来了:当我插入一个数据的时候,t_user表的字段n_dept_id只参考t_out_dept的n_out_dept_id字段,完全无视t_dept的n_dept_id字段。我用Mysql Front 的时候,看到索引那一列有主索引,还有FK_Reference_85 ,没有FK_Reference_58。


怎么回事呢?大神帮帮忙啊。我用的mysql版本是5.X α版的。

作者: chongchongyehenmao   发布时间: 2011-05-18

t_user (n_dept_id) 做为外键只能参考一个表中的字符,无法实现同时参照两个不同表中的字段。

目前已经的其它数据库包括SQL SERVE的,ORACLE都不支持这样。

作者: ACMAIN_CHM   发布时间: 2011-05-18

chongchongyehenmao (chongchongyehenmao)
  '截至2011-05-18 20:33:21 用户结帖率0.00%

当您的问题得到解答后请及时结贴.
http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html
http://topic.csdn.net/u/20100428/09/BC9E0908-F250-42A6-8765-B50A82FE186A.html
http://topic.csdn.net/u/20100626/09/f35a4763-4b59-49c3-8061-d48fdbc29561.html

8、如何给分和结贴?
http://community.csdn.net/Help/HelpCenter.htm#结帖


作者: ACMAIN_CHM   发布时间: 2011-05-18