Post

3 followers Follow
1

Improve metric "avoid table without primary key"

Hello. The metric "Avoid Tables without primary key" (https://technologies.castsoftware.com/rules?s=primary|qualityrules|8082) is set as critical for performances. But we observe a lot of defensive reactions about it, as a table often have indexes defined, but no primary key. If an index is defined, then, having no primary key is not considered that dangerous.

This is also to be considered in a context where modifying a table to add a PK is a heavy task.

FR would be to duplicate this metric, having a critical one "Avoid tables without primary key and without index" and a non-critical one "Avoid tables without primary key".

Thanks

Please sign in to leave a comment.

2 comments

0
Avatar

I agree with you Christophe when we talk about Performance.

We have implemented a critical custom rule for a customer named

"Avoid Tables not having at least one not nullable column and part of unique index", less strict, and the default rule "Avoid tables without primary" was set to non critical.

I'm also surprised that "Avoid tables without primary key" is not impacting robustness. When we have data corruption because no primary key is used, it's not only a problem of performance.

0 votes
Comment actions Permalink
0
Avatar

The case Christophe refers to is tables 

without primary key

having unique constraint on not null columns

In this context the absence of primary key is less critical since the unique constraints ensure the unicity of the rows. One of these constraint can be turned into a primary key. 

 

0 votes
Comment actions Permalink