Seq nr | Name▲ | Goal | Type | Data source | Last update | License | ... |
---|---|---|---|---|---|---|---|
1 | All the non-primary key columns are optional | Find base tables where all he non-primary key columns are optional. Avoid too many optional columns. You have to be extra careful with NULLs in case of formulating search conditions of data manipulation statements. | Problem detection | INFORMATION_SCHEMA only | 2021-02-25 17:30 | MIT License | |
2 | All unique keys have at least one optional column | Find base tables where all unique keys (sets of columns covered by a unique constraint, or a unique index) have at least one optional column. In this case there can be rows in the table where the values that should identify the row are missing. Because NULL is not a value and is not duplicate of another NULL the, follwing is possible: CREATE TABLE Uniq(a INTEGER NOT NULL, b INTEGER, CONSTRAINT ak_uniq UNIQUE (a, b)); INSERT INTO Uniq(a, b) VALUES (1, NULL); INSERT INTO Uniq(a, b) VALUES (1, NULL); | Problem detection | INFORMATION_SCHEMA+system catalog base tables | 2023-10-21 11:54 | MIT License | |
3 | A non-parameterized table function instead of a view | Find table functions that do not have any parameters. Prefer simpler and more portable solutions. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | 2021-11-03 21:16 | MIT License | |
4 | A table has the same name as a routine | Find table names that are the same as some routine name. Use different names to avoid confusion. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | 2021-02-25 17:30 | MIT License | |
5 | Base tables and materialized views without any index | Find base tables and materialized views that do not have any index. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | 2023-11-05 19:39 | MIT License | |
6 | Base tables that have a surrogate key and all its unique constraints have an optional column | A surrogate key is a primary key that consist of one column. The values of this column do not have any meaning for the user and the system usually generates the values (integers) automatically. In case of defining a surrogate key in a table it is a common mistake to forget declaring existing natural keys in the table. If a key covers an optional column then it does not prevent duplicate rows where some values are missing and other values are equal. Because NULL is not a value and is not duplicate of another NULL the, follwing is possible: CREATE TABLE Uniq(a INTEGER NOT NULL, b INTEGER, CONSTRAINT ak_uniq UNIQUE (a, b)); INSERT INTO Uniq(a, b) VALUES (1, NULL); INSERT INTO Uniq(a, b) VALUES (1, NULL); | Problem detection | INFORMATION_SCHEMA+system catalog base tables | 2023-10-21 11:54 | MIT License | |
7 | Base tables that have a surrogate key and do not have any uniqueness constraints | A surrogate key is a key that consist of one column. The values of this column do not have any meaning for the user and the system generates the values (integers) automatically. In case of defining a surrogate key in a table it is a common mistake to forget declaring existing natural keys in the table. The query discards tables with only one column. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | 2023-10-26 17:47 | MIT License | |
8 | Base tables that have a unique constraint but not the primary key | A common style is to declare in each base table one of the candidate keys as the primary key. All the other candidate keys would be alternate keys that will be enforce with the help of UNIQUE + NOT NULL constraints. | Problem detection | INFORMATION_SCHEMA only | 2021-02-25 17:30 | MIT License | |
9 | Base tables that have neither a unique constraint nor the primary key | Find base tables without any unique constraints and the primary key. In such tables there are no restrictions for recording duplicate rows. Each row represents a true proposition about the real world. It does not make the proposition truer if one presents it more than once. Moreover, duplicate rows increase data size. Without keys the DBMS lacks vital information about data in the database that it can internally use to choose better execution plans and in this way improve performance of database operations. The only legitimate reason of such a table is if it is an abstract table that is used to define common columns of subtables. | Problem detection | INFORMATION_SCHEMA only | 2021-02-25 17:30 | MIT License | |
10 | Base tables that have no uniqueness requirement for rows whatsoever | Find base tables without any unique constraints and primary key as well as any unique index, whether it is created explicitly by a developer or automatically by the DBMS. The only legitimate reason of such a table is if it is an abstract table that is used to define common columns of subtables. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | 2022-10-21 10:16 | MIT License | |
11 | Base tables that have only the surrogate key and do not have any other column | Do not create unnecessary tables. If a table has cardinality 1 (one column), then most probably the values in this column should not be system generated unique values. | Problem detection | INFORMATION_SCHEMA only | 2021-03-08 00:41 | MIT License | |
12 | Base tables where all the columns are optional | Find base tables where all the columns are optional, i.e., permit NULLs. In such tables can be rows with no identity value and thus indistinguishable from other rows. | Problem detection | INFORMATION_SCHEMA only | 2021-02-25 17:30 | MIT License | |
13 | Base tables where all the unique columns are optional | Find the base tables where all the unique columns are optional. In such tables there can be rows without values that identify these rows. In this case there can be rows in the table where the values that should identify the row are missing. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | 2022-10-21 01:47 | MIT License | |
14 | Base tables where uniqueness is achieved by using only unique indexes | Find base tables where uniqueness is achieved by using only unique indexes, i.e., there is at least one unique index but no uniqueness constraints (PRIMARY KEY, UNIQUE, EXCLUDE) | Problem detection | INFORMATION_SCHEMA+system catalog base tables | 2022-10-21 01:54 | MIT License | |
15 | Base tables, which statistics is probably not up to date | Find base tables where statistics has not been collected at all or it has been lastly collected more than 40 days ago. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | 2021-02-25 17:30 | MIT License | |
16 | Boolean column for gender | Find base table columns that have Boolean type and based on the column name are meant for recording data about gender. | Problem detection | INFORMATION_SCHEMA only | 2022-04-18 00:57 | MIT License | |
17 | Cannot accommodate all the fractional seconds in case of table columns | The precision of a timestamp type of a column must be able to accommodate all the fractional seconds of the default value of the column. Find table columns with the type timestamp without time zone(m) or timestamp with time zone(m) that have a default value LOCALTIMESTAMP(n) or CURRENT_TIMESTAMP(n) WHERE n>m. | Problem detection | INFORMATION_SCHEMA only | 2021-02-25 17:30 | MIT License | |
18 | Cascading update is not needed (based on surrogate keys) | Find foreign key constraints that reference to a candidate key that is a surrogate key, i.e., its values are generated by the system by using sequence generators. Do not use ON UPDATE CASCADE, ON UPDATE SET NULL, and ON UPDATE SET DEFAULT in case of foreign keys that reference to surrogate keys. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | 2024-11-28 12:31 | MIT License | |
19 | CHAR columns have a default value that length is shorter from the character maximum length of the column | Choose a suitable data type, field size, and default value. If the default value is shorter from the character maximum length, then spaces will be added to the end of the registered value. | Problem detection | INFORMATION_SCHEMA only | 2021-02-25 17:30 | MIT License | |
20 | CHAR or VARCHAR columns have a default value that length is longer from the character maximum length of the column | Find table columns with CHAR or VARCHAR type that have a default value that length is longer from the character maximum length of the column. Choose a suitable data type, field size, and default value. If the value is longer, then it is impossible to register it in a field, i.e., it makes registration of data impossible (except if the excessive characters are spaces). | Problem detection | INFORMATION_SCHEMA only | 2022-10-31 10:19 | MIT License |