0

I have 2 tables Customer and Customerkpi

In both tables we have the column Customer_id which should contain unique values.

Customer_id in Customerkpi is a foreign key of the Customer_id of the table Customer which is the primary key.

I need to create indexes on customerkpi in the best way.

Should I create a primary key on Customer_id and mentioned also the foreign key in this way it creates automatically a clustered index, or should I just declare it as a foreign key and then I create a cluster unique index on Customer_id.

which solution give the best performance?

4

Should I create a primary key on Customer_id and mentioned also the foreign key in this way it creates automatically a clustered index, or should I just declare it as a foreign key and then I create a cluster unique index on Customer_id.

The physical indexes (clustered and unique) will be identical in both cases so it makes no difference from a performance perspective whether the index also supports the primary key constraint. I would personally use a clustered primary key index since relational tables should have a primary key and add the foreign key too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.