-
Notifications
You must be signed in to change notification settings - Fork 8.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Poor Index Naming Convention #71
Comments
There are 63 occurrences of this in the WideWorldImporters Sample Database. |
Hi Bruce, Thanks for the feedback. There are different schools of thought on how to name indexes – there is not a single best practice that works for everyone. As the documentation of the sample mentions, it is designed using one set of guidelines, it is not the only way you can build a database. The person who created the sample database is an experienced database developer. Their practice is to always create an index for a foreign key, and align with the name of the key, in the same way that indexes supporting primary key and unique constraints are aligned with the constraints. I realize that different folks follow different best practices, and unfortunately we cannot accommodate all in the sample DB. Thanks, From: Bruce Dunwiddie [mailto:notifications@github.com] This may seem silly, but indexes that were created to support foreign key constraints seem to have been named in this database with an FK_* prefix, which I do not think sets a good example for a preferred naming convention. Example: CREATE NONCLUSTERED INDEX [FK_Application_Cities_StateProvinceID] ON [Application].Cities This naming convention is normally used exclusively for foreign key constraints. This naming convention is also used for foreign key constraints in this database. I would suggest renaming these indexes to follow an IX_* prefix naming convention. So many people use these sample databases as a "Microsoft best practices", that I would like to prevent having to argue and fix these things in the field down the road in customer created databases. References for preferred naming standards: — |
This may seem silly, but indexes that were created to support foreign key constraints seem to have been named in this database with an FK_* prefix, which I do not think sets a good example for a preferred naming convention.
Example:
CREATE NONCLUSTERED INDEX [FK_Application_Cities_StateProvinceID] ON [Application].Cities
(
[StateProvinceID] ASC
);
This naming convention is normally used exclusively for foreign key constraints. This naming convention is also used for foreign key constraints in this database.
I would suggest renaming these indexes to follow an IX_* prefix naming convention.
So many people use these sample databases as a "Microsoft best practices", that I would like to prevent having to argue and fix these things in the field down the road in customer created databases.
References for preferred naming standards:
http://sqlmag.com/blog/sql-server-index-naming-guidelines
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/431e5cf1-56b2-4a03-a7d9-183891973946/what-should-be-the-naming-convention-for-indexes?forum=transactsql
http://stackoverflow.com/questions/2783495/sql-server-index-naming-conventions
http://blog.sqlauthority.com/2012/05/21/sql-server-renaming-index-index-naming-conventions/
The text was updated successfully, but these errors were encountered: