2

I received this error while deploying a SQL Server DBProject

DBProj.dbschema(0,0): Warning SQL01271: The unnamed foreign key between tables [dbo].[Match] and [dbo].[Team] will be checked by checking the table. Name the foreign key to avoid checking the entire table and only check the new constraint.

My table definition is

CREATE TABLE [dbo].[Match]
(
    MatchID         int identity(11,2) PRIMARY KEY, 
    TournamentID    int not null REFERENCES Tournament(TournamentID),
    Team1_ID        int not null REFERENCES Team(TeamID),
    Team2_ID        int not null REFERENCES Team(TeamID),
    MatchDate       date,
    MatchTime       time
)

What does this error means? What is the implication?

update

actually, am concerned about the warning that it will check the entire table. Is it at creation time or every time? how does this affect performance?

codingbiz
  • 123
  • 1
  • 6

1 Answers1

2

Try the more verbose syntax

...
Team1_ID int not null CONSTRAINT FK_Match_Team1 FOREIGN KEY (TeamID) REFERENCES Team (TeamID),
Team1_ID int not null CONSTRAINT FK_Match_Team2 FOREIGN KEY (TeamID) REFERENCES Team (TeamID),
...

I'd suggest the lack of explicit constraint name is confusing VS because you have 2 match-team constraints. That is, it is a Visual Studio error not a SQL Server error. You won't get it in SSMS

gbn
  • 70,237
  • 8
  • 167
  • 244