MSSQL:无法为同一个表的两个外键创建关系?
您好,使用 SQL Server 2008,
我为棒球联盟构建了一个小型数据库,在创建
我想要的 团队(PK:TeamID)和 GameSchedule(PK:GameID,FK1:HomeTeamID,FK2:AwayTeamID)之间的关系时遇到问题创建 GameSchedule HomeTeamID、AwayTeamID 与 Teams(TeamID) 之间的关系
每当我尝试执行此操作时,都会收到错误:(TeamID 已经是 Teams 中的主键)
“Teams”表已成功保存 “比赛时间表”表 - 无法创建关系“FK_GameSchedule_Teams”。
ALTER TABLE 语句与 FOREIGN KEY 约束“FK_GameSchedule_Teams”冲突。冲突发生在数据库“sll_2009”、表“dbo.Teams”、列“TeamID”中。
Hi using SQL Server 2008,
I've built a small database for a baseball league, I'm having problem creating relationships between the Teams(PK: TeamID) and GameSchedule(PK: GameID, FK1: HomeTeamID, FK2: AwayTeamID)
I want to create relationships betwen the GameSchedule HomeTeamID, AwayTeamID to the Teams(TeamID)
Whenever I try to do this I get an error: (The TeamID is already the Primary Key in Teams)
'Teams' table saved successfully
'GameSchedule' table
- Unable to create relationship 'FK_GameSchedule_Teams'.
The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_GameSchedule_Teams". The conflict occurred in database "sll_2009", table "dbo.Teams", column 'TeamID'.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)