Filter Queries
- All the queries about database objects contain a subcondition to exclude from the result information about the system catalog.
- Although the statements use SQL constructs (common table expressions; NOT in subqueries) that could cause performance problems in case of large datasets, it shouldn't be a problem in case of the relatively small amount of data in the system catalog of a database.
#161. Perhaps the type of a base table column/domain should be VARCHAR (based on column names)
INFORMATION_SCHEMA onlyFind base table columns that have CHAR type, where character maximum length is bigger than 1 and the name of the column does not refer to the possibility that the column holds some kind of codes or flags or hash values.
#162. Perhaps the type of a base table column should be an integer type (based on column names)
INFORMATION_SCHEMA onlyFind columns of base tables where the name of the column has prefix or suffix "id" or has the name "id" but the column does not have an integer type or uuid type. A convention is to use the phrase "id" in the names of surrogate key columns.
#163. Perhaps the type of a base table column should be TIMESTAMPTZ
INFORMATION_SCHEMA onlyThis query identifies all base table columns defined with the timestamp without time zone data type. Use of this data type is a potential design flaw as it can lead to ambiguity and bugs when handling data from multiple time zones.
#164. Perhaps the type of a base table column should be TSTZRANGE
INFORMATION_SCHEMA onlyThis query identifies all base table columns defined with the range of timestamp without zone data type. Use of this data type is a potential design flaw as it can lead to ambiguity and bugs when handling data from multiple time zones.
#165. Perhaps the type of a base table column should be XML, JSON, or JSONB (based on column names)
INFORMATION_SCHEMA onlyFind base table columns that name refers to the possibility that these are used to register XML/JSON values. Find the columns that do not have an appropriate data type (xml, json, jsonb). One shouldn't use columns with a textual type to register such data.
#166. Perhaps too many subconditions in a CHECK constraint
INFORMATION_SCHEMA onlyFind check constraints of base table and foreign table columns that are either associated with more than one column and have at least one AND operation or are associated with exactly one column and have two or more AND operations.
#167. Permitting in a column only empty strings and strings that consist of whitespace characters
INFORMATION_SCHEMA onlyThis query identifies logically flawed CHECK constraints on table columns. It specifically searches for constraints that are defined in such a way that they only permit the insertion of an empty string or strings composed entirely of whitespace characters. This behavior is invariably a bug, likely a typo in the constraint's logic (e.g., using ~ instead of !~), which effectively renders the column unusable for storing meaningful data.
#168. Potential duplication of sequence generators
INFORMATION_SCHEMA onlyDo not create unnecessary sequence generators.
#169. Potentially unused sequence generators
INFORMATION_SCHEMA onlyFind sequence generators that are not associated with any column through the default value mechanism. Please note, that it is also possible to refer to a sequence generator from a routine or from an application. If these are indeed not used, then these should be dropped, otherwise these are dead code.
#170. Precision of a timestamp or a time column is too big
INFORMATION_SCHEMA onlyFind columns with a timestamp or a time type where the precision (the permitted maximum number of fractional sections) is bigger than the precision in the default value of the column.
#171. Prefixes of base table names
INFORMATION_SCHEMA onlyFind base tables that name starts with a prefix. Do not use prefixes in case of base table names. Derive the names from the names of entity types. Do not use "_", "t_", "tab_", "t11_" etc as prefixes of a table.
#172. Preventing strings that consist of only spaces instead of strings that consist of only whitespace characters
INFORMATION_SCHEMA onlyFind columns of base tables and foreign tables where one uses a check constraint to prevent values that consist of only spaces. Make sure that this is the correct constraint and there is no need to prevent values that consist of only whitespace characters.
#173. Publicly accessible system catalog tables
INFORMATION_SCHEMA onlyFind privileges to use system catalog base tables or views that have been granted to public.
#174. Redundant trim() function in whitespace constraints
INFORMATION_SCHEMA onlyThis query identifies superfluous trim() function calls within CHECK constraints where the validation is performed by a regular expression that disallows whitespace-only strings. A constraint using the pattern column !~ '^[[:space:]]*$' already provides comprehensive validation against empty or whitespace-only strings by anchoring the check to the start (^) and end ($) of the string. The trim() function is a pre-processing step that does not alter the boolean outcome of this specific regex match, making the expression trim(column) !~ '^[[:space:]]*$' functionally equivalent to the simpler column !~ '^[[:space:]]*$'. Removing the unnecessary function call improves clarity and simplifies the constraint.
#175. Reference to the numeric type is too imprecise, i.e., precision and scale are missing
INFORMATION_SCHEMA onlyFind base table columns that have the DECIMAL/NUMERIC type, but do not have precision and scale specified. "Specifying: NUMERIC without any precision or scale creates a column in which numeric values of any precision and scale can be stored, up to the implementation limit on precision. A column of this kind will not coerce input values to any particular scale, whereas numeric columns with a declared scale will coerce input values to that scale."
#176. Referential degree of a schema
INFORMATION_SCHEMA onlyReferential degree of a schema is defined as the number of foreign keys in the database schema.
#177. Referential degree of tables
INFORMATION_SCHEMA onlyThis metric represents the number of foreign keys in a base table.
#178. Registration/modification time is optional
INFORMATION_SCHEMA onlyThis query identifies columns intended to store registration or modification timestamps that are currently defined as optional (nullable). Since creation and update times are crucial for data auditing, these columns should typically have a NOT NULL constraint.
#179. Semantic mismatch: non-textual data types for classifier codes
INFORMATION_SCHEMA onlyThis query identifies a semantic mismatch in data types for columns intended to store standard codes, such as country, language, currency, or airport codes. It flags columns whose names suggest they contain these codes, but which are defined using non-text data types (e.g., integer, numeric, bigint). Since these codes often contain letters or leading zeros and are not used in mathematical calculations, they are semantically strings. Storing them as numeric types can lead to data loss—such as the truncation of leading zeros—and reduces formatting flexibility.
#180. Semantic mismatch: non-textual data types for phone numbers
INFORMATION_SCHEMA onlyThis query identifies a semantic mismatch in data type selection for columns intended to store telephone numbers. It flags columns whose identifiers imply phone number content (e.g., names containing "phone", "mobile", "telef") but are defined with non-textual data types (e.g., INTEGER, NUMERIC, BIGINT). Telephone numbers are semantically strings, as they may contain leading zeros, international prefixes (+), and formatting characters (-, (), ext.), and are not subject to arithmetic operations. Storing them as numeric types leads to data loss (truncation of leading zeros) and formatting inflexibility.
| # | Name(activate to sort ascending) | Goal(activate to sort ascending) | Type(activate to sort ascending) | Data source(sorted ascending, activate to sort descending) | Last update(activate to sort ascending) | License | Actions |
|---|---|---|---|---|---|---|---|
| 161 | Perhaps the type of a base table column/domain should be VARCHAR (based on column names) | Find base table columns that have CHAR type, where character maximum length is bigger than 1 and the name of the column does not refer to the possibility that the column holds some kind of codes or flags or hash values. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 162 | Perhaps the type of a base table column should be an integer type (based on column names) | Find columns of base tables where the name of the column has prefix or suffix "id" or has the name "id" but the column does not have an integer type or uuid type. A convention is to use the phrase "id" in the names of surrogate key columns. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 163 | Perhaps the type of a base table column should be TIMESTAMPTZ | This query identifies all base table columns defined with the timestamp without time zone data type. Use of this data type is a potential design flaw as it can lead to ambiguity and bugs when handling data from multiple time zones. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 164 | Perhaps the type of a base table column should be TSTZRANGE | This query identifies all base table columns defined with the range of timestamp without zone data type. Use of this data type is a potential design flaw as it can lead to ambiguity and bugs when handling data from multiple time zones. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 165 | Perhaps the type of a base table column should be XML, JSON, or JSONB (based on column names) | Find base table columns that name refers to the possibility that these are used to register XML/JSON values. Find the columns that do not have an appropriate data type (xml, json, jsonb). One shouldn't use columns with a textual type to register such data. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 166 | Perhaps too many subconditions in a CHECK constraint | Find check constraints of base table and foreign table columns that are either associated with more than one column and have at least one AND operation or are associated with exactly one column and have two or more AND operations. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 167 | Permitting in a column only empty strings and strings that consist of whitespace characters | This query identifies logically flawed CHECK constraints on table columns. It specifically searches for constraints that are defined in such a way that they only permit the insertion of an empty string or strings composed entirely of whitespace characters. This behavior is invariably a bug, likely a typo in the constraint's logic (e.g., using ~ instead of !~), which effectively renders the column unusable for storing meaningful data. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 168 | Potential duplication of sequence generators | Do not create unnecessary sequence generators. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 169 | Potentially unused sequence generators | Find sequence generators that are not associated with any column through the default value mechanism. Please note, that it is also possible to refer to a sequence generator from a routine or from an application. If these are indeed not used, then these should be dropped, otherwise these are dead code. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 170 | Precision of a timestamp or a time column is too big | Find columns with a timestamp or a time type where the precision (the permitted maximum number of fractional sections) is bigger than the precision in the default value of the column. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 171 | Prefixes of base table names | Find base tables that name starts with a prefix. Do not use prefixes in case of base table names. Derive the names from the names of entity types. Do not use "_", "t_", "tab_", "t11_" etc as prefixes of a table. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 172 | Preventing strings that consist of only spaces instead of strings that consist of only whitespace characters | Find columns of base tables and foreign tables where one uses a check constraint to prevent values that consist of only spaces. Make sure that this is the correct constraint and there is no need to prevent values that consist of only whitespace characters. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 173 | Publicly accessible system catalog tables | Find privileges to use system catalog base tables or views that have been granted to public. | General | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 174 | Redundant trim() function in whitespace constraints | This query identifies superfluous trim() function calls within CHECK constraints where the validation is performed by a regular expression that disallows whitespace-only strings. A constraint using the pattern column !~ '^[[:space:]]*$' already provides comprehensive validation against empty or whitespace-only strings by anchoring the check to the start (^) and end ($) of the string. The trim() function is a pre-processing step that does not alter the boolean outcome of this specific regex match, making the expression trim(column) !~ '^[[:space:]]*$' functionally equivalent to the simpler column !~ '^[[:space:]]*$'. Removing the unnecessary function call improves clarity and simplifies the constraint. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 175 | Reference to the numeric type is too imprecise, i.e., precision and scale are missing | Find base table columns that have the DECIMAL/NUMERIC type, but do not have precision and scale specified. "Specifying: NUMERIC without any precision or scale creates a column in which numeric values of any precision and scale can be stored, up to the implementation limit on precision. A column of this kind will not coerce input values to any particular scale, whereas numeric columns with a declared scale will coerce input values to that scale." | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 176 | Referential degree of a schema | Referential degree of a schema is defined as the number of foreign keys in the database schema. | Sofware measure | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 177 | Referential degree of tables | This metric represents the number of foreign keys in a base table. | Sofware measure | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 178 | Registration/modification time is optional | This query identifies columns intended to store registration or modification timestamps that are currently defined as optional (nullable). Since creation and update times are crucial for data auditing, these columns should typically have a NOT NULL constraint. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 179 | Semantic mismatch: non-textual data types for classifier codes | This query identifies a semantic mismatch in data types for columns intended to store standard codes, such as country, language, currency, or airport codes. It flags columns whose names suggest they contain these codes, but which are defined using non-text data types (e.g., integer, numeric, bigint). Since these codes often contain letters or leading zeros and are not used in mathematical calculations, they are semantically strings. Storing them as numeric types can lead to data loss—such as the truncation of leading zeros—and reduces formatting flexibility. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 180 | Semantic mismatch: non-textual data types for phone numbers | This query identifies a semantic mismatch in data type selection for columns intended to store telephone numbers. It flags columns whose identifiers imply phone number content (e.g., names containing "phone", "mobile", "telef") but are defined with non-textual data types (e.g., INTEGER, NUMERIC, BIGINT). Telephone numbers are semantically strings, as they may contain leading zeros, international prefixes (+), and formatting characters (-, (), ext.), and are not subject to arithmetic operations. Storing them as numeric types leads to data loss (truncation of leading zeros) and formatting inflexibility. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View |