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.
#501. Length and char_length functions are used within the same expression
INFORMATION_SCHEMA+system catalog base tablesThis query identifies expressions that use both the length() and char_length() functions, which is a strong indicator of a logical flaw. Since these functions are functional synonyms in PostgreSQL (both returning the character count), an expression that compares their results (e.g., length(col) > char_length(col)) may be either tautological or will always evaluate to false. Such code is typically written under the mistaken assumption that length() returns bytes, a behavior seen in other database management systems.
#502. Lifecycle not initiated
INFORMATION_SCHEMA+system catalog base tablesFind non-primary key and non-unique base table foreign key columns that name refers to the possibility that these are used to register references to a state classifier. The column must belong to a foreign key and does not have a default value.
#503. LIKE instead of =
INFORMATION_SCHEMA+system catalog base tablesFind expressions that use LIKE predicate for precise comparison.
#504. LIKE with a regular expression pattern
INFORMATION_SCHEMA+system catalog base tablesFind expressions that use LIKE (including ILIKE) predicate with a regular expression patterns. In a LIKE pattern one can use only _ and % metasymbols to construct a pattern.
#505. LIKE without a pattern with % or _
INFORMATION_SCHEMA+system catalog base tablesFind expressions that use LIKE predicate witout a pattern that contains at least one % or _ sign.
#506. Logical size of a schema
INFORMATION_SCHEMA+system catalog base tablesThe schema size is the sum of the sizes of all tables in the schema.
#507. Logical size of a table
INFORMATION_SCHEMA+system catalog base tablesThe table size is the sum of the total size of the simple columns and the total size of the complex columns in the table. In case of SQL databases large base tables in terms of number of columns could be a side effect of the problems with cloned columns or multiple columns for the same attribute. A base table with a low normalization level, which is meant to hold data that corresponds to multiple entity types has typically also relatively large number of columns compared with other base tables. Thus, the normalization level of base tables with a large number of columns should be checked as well.
#508. Mandatory columns for holding large textual values (comments, descriptions, etc.)
INFORMATION_SCHEMA+system catalog base tablesFind mandatory (NOT NULL) base table columns that name, column type, and field size refers to the possibility that these are used to register large textual values like comments, descriptions, and explanations.
#509. Mandatory non-primary key columns
INFORMATION_SCHEMA+system catalog base tablesFind mandatory non-primary key columns, i.e., the columns that have NOT NULL constraint.
#510. Many-to-many relationship types that do not have additional attributes
INFORMATION_SCHEMA+system catalog base tablesFind base tables that implement many-to-many relationship types that do not permit repeating relationships. More specifically find tables that have two or more foreign keys and all the columns of the table are either foreign key columns or a surrogate key column. It could be that during the system analysis a mistake has been made and some attributes of the entity type that represents the relationship type have not been discovered.
#511. Many-to-many relationship types that do not permit repeating relationships and do not have additional attributes
INFORMATION_SCHEMA+system catalog base tablesFind base tables that implement many-to-many relationship types that do not permit repeating relationships. More specifically find tables that have two or more foreign keys and all the columns of the table belong to a foreign key. In addition, all the table columns must be covered by a primary key or unique constraint. It could be that during the system analysis a mistake has been made and some attributes of the entity type that represents the relationship type have not been discovered.
#512. Many-to-many tables that need conceptual renaming
system catalog base tables onlyThis query identifies junction tables (implementing a binary relationship via two foreign keys) whose names are simple concatenations of the parent table names (e.g., Course_Lecturer). This naming style is flagged as a design smell because it merely describes the physical implementation rather than the conceptual relationship being modeled. The recommended best practice is to rename such tables to reflect the domain concept they represent. For instance, the relationship between Course and Lecturer should be named after the activity it represents, such as Teaching or Course_Assignment.
#513. Many-to-many tables that perhaps need conceptual renaming
system catalog base tables onlyThis query identifies junction tables (implementing a binary relationship via two foreign keys) whose names are simple concatenations of the parent table names, often with minor variations (e.g., Courses_Lecturer). This naming convention is a design smell as it describes the physical implementation rather than the conceptual relationship being modeled. The recommended best practice is to rename such tables to reflect the domain concept they represent. For instance, the relationship between Course and Lecturer should be named after the activity it represents, such as Teaching or Course_Assignment.
#514. Maximum field size of code columns
INFORMATION_SCHEMA onlyThis query determines the maximum field size of text columns whose names suggest they store some type of code.
#515. Meaningless terms in derived tables
INFORMATION_SCHEMA+system catalog base tablesFind derived tables that subquery contains terms "foo", "bar", "foobar", or "baz".
#516. Meaningless terms in names
INFORMATION_SCHEMA+system catalog base tablesFind names of database objects that contain terms "foo", "bar", "foobar", or "baz".
#517. Meaningless terms in routines
INFORMATION_SCHEMA+system catalog base tablesFind routines that subquery contains terms "foo", "bar", "foobar", or "baz".
#518. Median and average number of subcomponents in the names of database objects
INFORMATION_SCHEMA+system catalog base tables"Names in software are 90 percent of what make software readable. You need to take the time to choose them wisely and keep them relevant. Names are too important to treat carelessly. Names should not cause confusion." (Robert C. Martin, Clean Code) Names should be expressive. Find the median and average (arithmetic mean) number of subcomponents in the names of user-defined database objects. The values could be used to compare different databases.
#519. Median and average of the length of names of database objects
INFORMATION_SCHEMA+system catalog base tables"Names in software are 90 percent of what make software readable. You need to take the time to choose them wisely and keep them relevant. Names are too important to treat carelessly. Names should not cause confusion." (Robert C. Martin, Clean Code) Names should be expressive. Find the median length and average (arithmetic mean) length of the names (identifiers) of user-defined database objects. The values could be used to compare different databases.
#520. Median and average of the length of names of database objects by the object type
INFORMATION_SCHEMA+system catalog base tables"Names in software are 90 percent of what make software readable. You need to take the time to choose them wisely and keep them relevant. Names are too important to treat carelessly. Names should not cause confusion." (Robert C. Martin, Clean Code) Names should be expressive. Find the median length and average (arithmetic mean) length of the names (identifiers) of user-defined database objects by the object type. The values could be used to compare different databases.
| # | Name(sorted ascending, activate to sort descending) | Goal(activate to sort ascending) | Type(activate to sort ascending) | Data source(activate to sort ascending) | Last update(activate to sort ascending) | License | Actions |
|---|---|---|---|---|---|---|---|
| 501 | Length and char_length functions are used within the same expression | This query identifies expressions that use both the length() and char_length() functions, which is a strong indicator of a logical flaw. Since these functions are functional synonyms in PostgreSQL (both returning the character count), an expression that compares their results (e.g., length(col) > char_length(col)) may be either tautological or will always evaluate to false. Such code is typically written under the mistaken assumption that length() returns bytes, a behavior seen in other database management systems. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 502 | Lifecycle not initiated | Find non-primary key and non-unique base table foreign key columns that name refers to the possibility that these are used to register references to a state classifier. The column must belong to a foreign key and does not have a default value. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 503 | LIKE instead of = | Find expressions that use LIKE predicate for precise comparison. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 504 | LIKE with a regular expression pattern | Find expressions that use LIKE (including ILIKE) predicate with a regular expression patterns. In a LIKE pattern one can use only _ and % metasymbols to construct a pattern. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 505 | LIKE without a pattern with % or _ | Find expressions that use LIKE predicate witout a pattern that contains at least one % or _ sign. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 506 | Logical size of a schema | The schema size is the sum of the sizes of all tables in the schema. | Sofware measure | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 507 | Logical size of a table | The table size is the sum of the total size of the simple columns and the total size of the complex columns in the table. In case of SQL databases large base tables in terms of number of columns could be a side effect of the problems with cloned columns or multiple columns for the same attribute. A base table with a low normalization level, which is meant to hold data that corresponds to multiple entity types has typically also relatively large number of columns compared with other base tables. Thus, the normalization level of base tables with a large number of columns should be checked as well. | Sofware measure | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 508 | Mandatory columns for holding large textual values (comments, descriptions, etc.) | Find mandatory (NOT NULL) base table columns that name, column type, and field size refers to the possibility that these are used to register large textual values like comments, descriptions, and explanations. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 509 | Mandatory non-primary key columns | Find mandatory non-primary key columns, i.e., the columns that have NOT NULL constraint. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 510 | Many-to-many relationship types that do not have additional attributes | Find base tables that implement many-to-many relationship types that do not permit repeating relationships. More specifically find tables that have two or more foreign keys and all the columns of the table are either foreign key columns or a surrogate key column. It could be that during the system analysis a mistake has been made and some attributes of the entity type that represents the relationship type have not been discovered. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 511 | Many-to-many relationship types that do not permit repeating relationships and do not have additional attributes | Find base tables that implement many-to-many relationship types that do not permit repeating relationships. More specifically find tables that have two or more foreign keys and all the columns of the table belong to a foreign key. In addition, all the table columns must be covered by a primary key or unique constraint. It could be that during the system analysis a mistake has been made and some attributes of the entity type that represents the relationship type have not been discovered. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 512 | Many-to-many tables that need conceptual renaming | This query identifies junction tables (implementing a binary relationship via two foreign keys) whose names are simple concatenations of the parent table names (e.g., Course_Lecturer). This naming style is flagged as a design smell because it merely describes the physical implementation rather than the conceptual relationship being modeled. The recommended best practice is to rename such tables to reflect the domain concept they represent. For instance, the relationship between Course and Lecturer should be named after the activity it represents, such as Teaching or Course_Assignment. | Problem detection | system catalog base tables only | MIT (opens in new tab) | View | |
| 513 | Many-to-many tables that perhaps need conceptual renaming | This query identifies junction tables (implementing a binary relationship via two foreign keys) whose names are simple concatenations of the parent table names, often with minor variations (e.g., Courses_Lecturer). This naming convention is a design smell as it describes the physical implementation rather than the conceptual relationship being modeled. The recommended best practice is to rename such tables to reflect the domain concept they represent. For instance, the relationship between Course and Lecturer should be named after the activity it represents, such as Teaching or Course_Assignment. | Problem detection | system catalog base tables only | MIT (opens in new tab) | View | |
| 514 | Maximum field size of code columns | This query determines the maximum field size of text columns whose names suggest they store some type of code. | General | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 515 | Meaningless terms in derived tables | Find derived tables that subquery contains terms "foo", "bar", "foobar", or "baz". | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 516 | Meaningless terms in names | Find names of database objects that contain terms "foo", "bar", "foobar", or "baz". | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 517 | Meaningless terms in routines | Find routines that subquery contains terms "foo", "bar", "foobar", or "baz". | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 518 | Median and average number of subcomponents in the names of database objects | "Names in software are 90 percent of what make software readable. You need to take the time to choose them wisely and keep them relevant. Names are too important to treat carelessly. Names should not cause confusion." (Robert C. Martin, Clean Code) Names should be expressive. Find the median and average (arithmetic mean) number of subcomponents in the names of user-defined database objects. The values could be used to compare different databases. | Sofware measure | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 519 | Median and average of the length of names of database objects | "Names in software are 90 percent of what make software readable. You need to take the time to choose them wisely and keep them relevant. Names are too important to treat carelessly. Names should not cause confusion." (Robert C. Martin, Clean Code) Names should be expressive. Find the median length and average (arithmetic mean) length of the names (identifiers) of user-defined database objects. The values could be used to compare different databases. | Sofware measure | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 520 | Median and average of the length of names of database objects by the object type | "Names in software are 90 percent of what make software readable. You need to take the time to choose them wisely and keep them relevant. Names are too important to treat carelessly. Names should not cause confusion." (Robert C. Martin, Clean Code) Names should be expressive. Find the median length and average (arithmetic mean) length of the names (identifiers) of user-defined database objects by the object type. The values could be used to compare different databases. | Sofware measure | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View |