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.
#621. Perhaps is not snake_case - id, code, key, or nr is not preceded by an underscore
INFORMATION_SCHEMA+system catalog base tablesFind names that perhaps do not use the snake_case naming style because the name ends with the phrase "id", "uuid", "code", "kood", "key", or "nr" that is not preceded by an underscore. Prefer snake_case over PascalCase and camelCase in names.
#622. Perhaps is not snake_case - long subsections without underscores
INFORMATION_SCHEMA+system catalog base tablesFind names that perhaps do not use the snake_case naming style because the name contains a long subsection (at least 20 characters) without underscores. Prefer snake_case over PascalCase and camelCase in names.
#623. Perhaps last update time trigger is missing
INFORMATION_SCHEMA+system catalog base tablesFind base tables that have a column for last update time but the table does not have associated before update row level trigger for changing the last update time.
#624. Perhaps multiple surrogate keys
INFORMATION_SCHEMA+system catalog base tablesThis query identifies base tables with a potentially redundant key structure. It specifically targets those having more than one PRIMARY KEY or UNIQUE constraint defined on a single integer-type column whose name matches the surrogate key naming convention (id_* or *_id). This pattern is a strong indicator of multiple surrogate keys for the same entity, which can indicate an overcomplicated data model. A single entity should typically have only one system-generated identifier to maintain schema clarity, simplify join logic, and avoid redundancy. The presence of multiple such keys warrants a review to determine if one is superfluous.
#625. Perhaps searching based on a name instead of a code
INFORMATION_SCHEMA+system catalog base tablesThis query identifies derived tables (views and materialized views) whose WHERE clause filters data based on a descriptive name or label (e.g., dname = 'ACCOUNTING') rather than an immutable code or identifier (e.g., deptno = 10 or status_code = 'ACTIVE'). Descriptive names, titles, and labels are designed for human presentation and are inherently mutable—they may change over time due to terminology updates, typo corrections, organizational restructuring, or localization. Hardcoding descriptive names into view predicates creates fragile database logic: if a name is updated in the underlying lookup or base table, the derived table will silently stop matching those rows and return incomplete or empty results without raising an error.
#626. Perhaps spaces are unnecessarily restricted
INFORMATION_SCHEMA+system catalog base tablesFind base table columns that name refers to the possibility that the column is used to record names or textual descriptions but the column seems to have a simple check constraint that restricts spaces in these.
#627. Perhaps the name referes to multiple concepts
INFORMATION_SCHEMA+system catalog base tablesThis query identifies user-defined database objects (tables, views, columns, routines, parameters, constraints, triggers, domains, and types) whose names contain the coordinating conjunctions "and" (English) or "ja" (Estonian), either separated by underscores (_and_, _ja_) or written in camelCase/PascalCase (...And..., ...Ja...). The presence of a conjunction in an identifier typically indicates that a single database object is overloaded with multiple concepts or responsibilities:
- Columns: Suggests a violation of First Normal Form (1NF) and attribute atomicity (e.g., storing multiple distinct values in one column, such as phone_and_email).
- Routines and Triggers: Suggests a violation of the Single Responsibility Principle (SRP), indicating that a function or trigger performs multiple coupled tasks instead of one well-defined operation.
- Constraints: Suggests that multiple independent business rules are bundled into a single CHECK constraint, making it harder to identify which specific rule failed when an exception is raised.
- Tables and Views: Suggests poor cohesion where distinct entities are merged into a single relation.
Names where "and" or "ja" merely defines the lower and upper bounds of a single range (such as between_1_and_10 or vahemikus_3_ja_6) are excluded, as they describe one cohesive interval rule rather than multiple concepts.
#628. Perhaps the type of a base table column/domain should be BOOLEAN (based on CHECK constraints)
INFORMATION_SCHEMA+system catalog base tablesThis query identifies base table columns and domains that utilize CHECK constraints to simulate boolean logic on non-boolean data types. It targets constraints that restrict the domain of permitted values to binary sets, such as {0, 1}, {'Y', 'N'}, {'T', 'F'}, or string literals like 'true'/'false'. While functional, this "pseudo-boolean" pattern is considered suboptimal in PostgreSQL. The native BOOLEAN data type is preferred for its storage efficiency, semantic clarity, and built-in support for logical operators, rendering such manual constraints unnecessary.
#629. Perhaps the type of a base table column should be BOOLEAN (based on column names)
INFORMATION_SCHEMA+system catalog base tablesThis query identifies a semantic mismatch between a column's name and its data type. It flags base table columns that adhere to a predicate-based naming convention (i.e., starting with is_, has_, can_, or on_) but are not defined with the BOOLEAN data type. This is a design flaw as it forces developers to infer and manage truthiness through other types (e.g., INTEGER, CHAR(1)), which undermines schema clarity, requires data type coercion in queries, and can compromise data integrity by permitting non-boolean states.
#630. Perhaps the type of a base table column should be BOOLEAN (based on enumerated types)
INFORMATION_SCHEMA+system catalog base tablesFind base table columns that have an enumerated type that seems to emulate Boolean type.
#631. Perhaps the type of a parameter should be BOOLEAN (based on parameter names)
INFORMATION_SCHEMA+system catalog base tablesFind routine parameters that based on the name seem to hold truth values. Find parameters that name starts with "is_" or "has_" or "can_" or "on_" and that do not have Boolean type.
#632. Perhaps too many different prefixes in the names of database objects that have the same type
INFORMATION_SCHEMA+system catalog base tablesOne should be consistent in naming, including in the use of prefixes. If you use prefix in the name of a database object, then it should refer to the type of the database object. Do not use different prefixes in the names of database objects that have the same type. Find types of database objects in case of which there are different prefixes in different names.
#633. Perhaps too many different suffixes in the names of database objects that have the same type
INFORMATION_SCHEMA+system catalog base tablesOne should be consistent in naming, including in the use of suffixes. If you use sufix in the name of a database object, then it should refer to the type of the database object. Do not use different suffixes in the names of database objects that have the same type. Find types of database objects in case of which there are different suffixes in different names.
#634. Perhaps too many input parameters
INFORMATION_SCHEMA+system catalog base tablesToo many parameters (in this case four or more) could be a sign of not separating concerns and having a routine that has more than one task.
#635. Perhaps too many square brackets
INFORMATION_SCHEMA+system catalog base tablesCharacter classes are surrounded by two pairs of square brackets.
#636. Perhaps unnecessary DECLARE section in a PL/pgSQL routine
INFORMATION_SCHEMA+system catalog base tablesFind PL/pgSQL routines that perhaps unnecessarily contain DECLARE section. More specifically, find routines with the DECLARE section where the only task seems to be raising an exception. The query excludes the cases where the error message is constructed dynamically, i.e., in this case using a variable maybe justifiable.
#637. Perhaps unnecessary DECLARE section in a PL/pgSQL routine (2)
INFORMATION_SCHEMA+system catalog base tablesFind PL/pgSQL routines that perhaps unnecessarily contain DECLARE section. More specifically, find routines with the DECLARE section where the keyword DECLARE is followed by BEGIN, i.e., the DECLARE section is empty.
#638. Perhaps updating of modification time is missing
INFORMATION_SCHEMA+system catalog base tablesFind routines with SQL-standard body that seem to update data in a table that has a column for modification time but the routine does not seem to update the modification time while updating the row and the table does not seem to have an UPDATE trigger that changes the modification time.
#639. Perhaps USING syntax could be used for joining in the subqueries of derived tables
INFORMATION_SCHEMA+system catalog base tablesThis query identifies derived tables (views) that utilize the explicit ANSI SQL-92 join syntax with the ON clause. It specifically targets views where join conditions are defined within the FROM clause but explicitly excludes those using the simplified USING syntax. This helps to identify derived tables that subquery could be simplified.
#640. Phone number columns lacking digit validation constraints
INFORMATION_SCHEMA+system catalog base tablesThis query identifies non-foreign key base table columns intended for telephone number storage that lack essential data validation. It targets columns whose names imply phone data (e.g., containing "phone", "tel") but which have no associated simple CHECK constraint validating the presence of numeric digits. Without such a constraint (e.g., a regex check for [0-9]), the column allows for invalid entries such as purely alphabetic strings or email addresses, compromising data integrity. The query assumes that a valid phone number must minimally contain digits.
| # | 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 |
|---|---|---|---|---|---|---|---|
| 621 | Perhaps is not snake_case - id, code, key, or nr is not preceded by an underscore | Find names that perhaps do not use the snake_case naming style because the name ends with the phrase "id", "uuid", "code", "kood", "key", or "nr" that is not preceded by an underscore. Prefer snake_case over PascalCase and camelCase in names. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 622 | Perhaps is not snake_case - long subsections without underscores | Find names that perhaps do not use the snake_case naming style because the name contains a long subsection (at least 20 characters) without underscores. Prefer snake_case over PascalCase and camelCase in names. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 623 | Perhaps last update time trigger is missing | Find base tables that have a column for last update time but the table does not have associated before update row level trigger for changing the last update time. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 624 | Perhaps multiple surrogate keys | This query identifies base tables with a potentially redundant key structure. It specifically targets those having more than one PRIMARY KEY or UNIQUE constraint defined on a single integer-type column whose name matches the surrogate key naming convention (id_* or *_id). This pattern is a strong indicator of multiple surrogate keys for the same entity, which can indicate an overcomplicated data model. A single entity should typically have only one system-generated identifier to maintain schema clarity, simplify join logic, and avoid redundancy. The presence of multiple such keys warrants a review to determine if one is superfluous. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 625 | Perhaps searching based on a name instead of a code | This query identifies derived tables (views and materialized views) whose WHERE clause filters data based on a descriptive name or label (e.g., dname = 'ACCOUNTING') rather than an immutable code or identifier (e.g., deptno = 10 or status_code = 'ACTIVE'). Descriptive names, titles, and labels are designed for human presentation and are inherently mutable—they may change over time due to terminology updates, typo corrections, organizational restructuring, or localization. Hardcoding descriptive names into view predicates creates fragile database logic: if a name is updated in the underlying lookup or base table, the derived table will silently stop matching those rows and return incomplete or empty results without raising an error. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 626 | Perhaps spaces are unnecessarily restricted | Find base table columns that name refers to the possibility that the column is used to record names or textual descriptions but the column seems to have a simple check constraint that restricts spaces in these. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 627 | Perhaps the name referes to multiple concepts | This query identifies user-defined database objects (tables, views, columns, routines, parameters, constraints, triggers, domains, and types) whose names contain the coordinating conjunctions "and" (English) or "ja" (Estonian), either separated by underscores (_and_, _ja_) or written in camelCase/PascalCase (...And..., ...Ja...). The presence of a conjunction in an identifier typically indicates that a single database object is overloaded with multiple concepts or responsibilities:
Names where "and" or "ja" merely defines the lower and upper bounds of a single range (such as between_1_and_10 or vahemikus_3_ja_6) are excluded, as they describe one cohesive interval rule rather than multiple concepts. |
Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 628 | Perhaps the type of a base table column/domain should be BOOLEAN (based on CHECK constraints) | This query identifies base table columns and domains that utilize CHECK constraints to simulate boolean logic on non-boolean data types. It targets constraints that restrict the domain of permitted values to binary sets, such as {0, 1}, {'Y', 'N'}, {'T', 'F'}, or string literals like 'true'/'false'. While functional, this "pseudo-boolean" pattern is considered suboptimal in PostgreSQL. The native BOOLEAN data type is preferred for its storage efficiency, semantic clarity, and built-in support for logical operators, rendering such manual constraints unnecessary. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 629 | Perhaps the type of a base table column should be BOOLEAN (based on column names) | This query identifies a semantic mismatch between a column's name and its data type. It flags base table columns that adhere to a predicate-based naming convention (i.e., starting with is_, has_, can_, or on_) but are not defined with the BOOLEAN data type. This is a design flaw as it forces developers to infer and manage truthiness through other types (e.g., INTEGER, CHAR(1)), which undermines schema clarity, requires data type coercion in queries, and can compromise data integrity by permitting non-boolean states. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 630 | Perhaps the type of a base table column should be BOOLEAN (based on enumerated types) | Find base table columns that have an enumerated type that seems to emulate Boolean type. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 631 | Perhaps the type of a parameter should be BOOLEAN (based on parameter names) | Find routine parameters that based on the name seem to hold truth values. Find parameters that name starts with "is_" or "has_" or "can_" or "on_" and that do not have Boolean type. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 632 | Perhaps too many different prefixes in the names of database objects that have the same type | One should be consistent in naming, including in the use of prefixes. If you use prefix in the name of a database object, then it should refer to the type of the database object. Do not use different prefixes in the names of database objects that have the same type. Find types of database objects in case of which there are different prefixes in different names. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 633 | Perhaps too many different suffixes in the names of database objects that have the same type | One should be consistent in naming, including in the use of suffixes. If you use sufix in the name of a database object, then it should refer to the type of the database object. Do not use different suffixes in the names of database objects that have the same type. Find types of database objects in case of which there are different suffixes in different names. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 634 | Perhaps too many input parameters | Too many parameters (in this case four or more) could be a sign of not separating concerns and having a routine that has more than one task. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 635 | Perhaps too many square brackets | Character classes are surrounded by two pairs of square brackets. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 636 | Perhaps unnecessary DECLARE section in a PL/pgSQL routine | Find PL/pgSQL routines that perhaps unnecessarily contain DECLARE section. More specifically, find routines with the DECLARE section where the only task seems to be raising an exception. The query excludes the cases where the error message is constructed dynamically, i.e., in this case using a variable maybe justifiable. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 637 | Perhaps unnecessary DECLARE section in a PL/pgSQL routine (2) | Find PL/pgSQL routines that perhaps unnecessarily contain DECLARE section. More specifically, find routines with the DECLARE section where the keyword DECLARE is followed by BEGIN, i.e., the DECLARE section is empty. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 638 | Perhaps updating of modification time is missing | Find routines with SQL-standard body that seem to update data in a table that has a column for modification time but the routine does not seem to update the modification time while updating the row and the table does not seem to have an UPDATE trigger that changes the modification time. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 639 | Perhaps USING syntax could be used for joining in the subqueries of derived tables | This query identifies derived tables (views) that utilize the explicit ANSI SQL-92 join syntax with the ON clause. It specifically targets views where join conditions are defined within the FROM clause but explicitly excludes those using the simplified USING syntax. This helps to identify derived tables that subquery could be simplified. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 640 | Phone number columns lacking digit validation constraints | This query identifies non-foreign key base table columns intended for telephone number storage that lack essential data validation. It targets columns whose names imply phone data (e.g., containing "phone", "tel") but which have no associated simple CHECK constraint validating the presence of numeric digits. Without such a constraint (e.g., a regex check for [0-9]), the column allows for invalid entries such as purely alphabetic strings or email addresses, compromising data integrity. The query assumes that a valid phone number must minimally contain digits. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View |