Home All Groups Group Topic Archive Search About

Indexes for Foreign Key Constraints?

Author
9 Nov 2007 10:51 PM
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

Author
9 Nov 2007 11:07 PM
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!  :)

Show quote
"Joel Lyons" <joell_REMO***@novarad.net> wrote in message
news:e9EWqMyIIHA.280@TK2MSFTNGP03.phx.gbl...
>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
Author
10 Nov 2007 9:35 AM
Cor Ligthert[MVP]
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
Author
12 Nov 2007 10:29 PM
Joel Lyons
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!

Show quote
"Cor Ligthert[MVP]" <notmyfirstn***@planet.nl> wrote in message
news:C605840F-3816-4314-ACD0-6773734A8899@microsoft.com...
> 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
Author
13 Nov 2007 2:52 AM
Kerry Moorman
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


Show quote
"Joel Lyons" wrote:

> 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!
>
> "Cor Ligthert[MVP]" <notmyfirstn***@planet.nl> wrote in message
> news:C605840F-3816-4314-ACD0-6773734A8899@microsoft.com...
> > 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
>
>
Author
14 Nov 2007 6:18 AM
Cor Ligthert[MVP]
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

AddThis Social Bookmark Button