Tuesday, October 23, 2007

what is the disadvantages of having foreign keys


What is the disadvantage of having more foreign keys

There is no any disadvantage in particular and in fact it supports the referential integrity which is the major advantage.
But internally when there is a foreign key means there is a overhead on the SQL Server system:
Before delete a master record, the engine will look at the existence of the child record in foreign key table internally and to insert or updating a primary key on child record; the engine will look into the master record in the primary key table


Conclusion: so ,it’s always better to create a clustered index on the primary key and a non-clustered index on a foreign key


No comments:

Post a Comment

Featured Post

SQL Server AWS Migration BCP

stored procedure to generate BCP scritps to migrate the SQL Server database. Developed this stored procedure on my labs to simulate t...

Contributors