Non-unique indexes that COULD be unique

In my last post I showed a query to identify non-unique indexes that should be unique. You maybe have some other indexes that could be unique based on the data they contain, but are not. To find out, you just need to query each of those indexes and group by the whole key, filtering out those that have duplicate values. It may look like an overwhelming amount of work, but the good news is I have a script for that: [Read More]

Non-unique indexes that should be unique

Defining the appropriate primary key and unique constraints is fundamental for a good database design. One thing that I often see overlooked is that all the indexes with a key that includes completely another UNIQUE index’s key should in turn be created as UNIQUE. You could argue that such an index has probably been created by mistake, but it’s not always the case. If you want to check your database for indexes that can be safely made UNIQUE, you can use the following script: [Read More]