Showing posts with label indexed. Show all posts
Showing posts with label indexed. Show all posts

Monday, March 19, 2012

Can I add a foriegn key on a indexed view to reference other table

Is there anybody familiar with indexed view here?

Can I add a foriegn key on a indexed view to reference other table?

Thanks!

No, and you wouldn't want to. Put the constraint on the table - that's the real data. The view is just that - a view, on the data in the table. The fact that you can index the view doesn't change that. You can use INSTEAD OF triggers on views to get things to happen when data is modified through the view but that wouldn't replace a foreign key constraint, rather it would be subject to the constraint as it should be.

Thursday, February 16, 2012

Can a multi-column index be used for single-column searching?

I know that in the case of some database engines a two-column index can
also be used to speed searches on the first of the two indexed columns
when searched singly, thereby making it unnecessary to create a
separate index on the first column.
For example, a two-column index in (lastname,firstname) will also be
used by those searches that search only on the 'lastname' field, so
that a separate one-column index on 'lastname' is not necessary.
Is this the case with SQL-Server?It is. Statistics are kept for the first column in a composite index.
ML
http://milambda.blogspot.com/|||Yes.
Roji. P. Thomas
Net Asset Management
http://toponewithties.blogspot.com
<quizling@.biztekinc.net> wrote in message
news:1136758766.471031.129740@.g14g2000cwa.googlegroups.com...
>I know that in the case of some database engines a two-column index can
> also be used to speed searches on the first of the two indexed columns
> when searched singly, thereby making it unnecessary to create a
> separate index on the first column.
> For example, a two-column index in (lastname,firstname) will also be
> used by those searches that search only on the 'lastname' field, so
> that a separate one-column index on 'lastname' is not necessary.
> Is this the case with SQL-Server?
>