Indexes for Foreign Key Constraints?

  • Thread starter Thread starter Joel Lyons
  • Start date Start date
J

Joel Lyons

I read recently in an ADO.NET book that I should create indexes on foreign
key constraints if they will commonly be used when joining. I can't
remember where, but I could swear that I had read somewhere else that
indexes were automatically created when you assign a foreign key constraint
to a column. What's the deal?

Joel Lyons
 
I just realized this might be better answered in a sqlserver group. I will
post there. Feel free to throw me some (related) advice anyway if you have
any! :)
 
Just to give an answer so it will be not an unanswered question when
searched by Google.

They will be created on SQL server databases.

Cor
 
Thanks for responding Cor - but now I'm confused! :)

Will you check the responses I got to this same question in
microsoft.public.sqlserver.server (question posted 11/9/07 at 4 pm MST)?
The answers I received there were not the same!
 
Joel,

I have never seen anything to indicate that SQL Server automatically creates
indexes on foreign key constraints.

Of course, it is a good idea to have such indexes on foreign keys that will
be used in joins, but as far as I know, it is up to you to create them.

Kerry Moorman
 
Kerry,

Maybe I am confused, however I see forever in the SQL Server Management
studio IDX files when there is created a constraint by the tool.

I avoid them as hell and do checking using the VB or C# code because
constraints gives for me only difficult to handle exceptions which come as
the user is completely finished with the things he has to do and does the
update of the dataset. As the constraint was fixed by the binding to the
controls (textbox etc), then this would be of course a great solution.
However this seems to me an impossibility. Because if you are doing it good
you don't have a full database in your dataset, but use almost forever where
clauses.

However, as I am understood it wrong ***Sorry***.

Cor
 
Back
Top