Filter Queries

Found 1053 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 relatively small amount of data, which is in the system catalog of a database.
  • Statistics about the catalog content and project home in GitHub that has additional information.

#381. Do not specify a list of values in a table column definition

INFORMATION_SCHEMA+system catalog base tables

Find cases where the list of valid data values in the column is specified in the column definition (in addition to specifying the type of the column) by using, for instance, check constraints or enumerated types. The check constraint is either associated directly with a table or is associated with a domain.

Problem detection License: MIT (opens in new tab)

#382. Do not use a generic attribute table

INFORMATION_SCHEMA only

Find base tables that implement a highly generic database design (EAV design - Entiry-Attribute-Value design), according to which attribute values are recorded in a generic table that contains attribute-value pairs.

Problem detection License: MIT (opens in new tab)

#383. Do not use approach that one size fits all (primary key columns)

INFORMATION_SCHEMA+system catalog base tables

Find base base tables have the simple primary key that contains the column with the (case insensitive) name id and an integer type. In addition, the primary key values are generated automatically by the system by using a sequence generator.

Problem detection License: MIT (opens in new tab)

#384. Do not use approach that one size fits all (unique index columns)

INFORMATION_SCHEMA+system catalog base tables

Find base base tables have a simple unique index (not associated with a constraint) that contains the column with the (case insensitive) name id and an integer type. In addition, the key values are generated automatically by the system by using a sequence generator.

Problem detection License: MIT (opens in new tab)

#385. Do not use dual-purpose foreign keys

INFORMATION_SCHEMA only

Find cases where the same column of a base table T is used to record references to multiple base tables. In addition, one has to add additional column to T for holding metadata about the parent table, referenced by the current row.

Problem detection License: MIT (opens in new tab)

#386. Do not use FLOAT Data Type

INFORMATION_SCHEMA only

Find base table columns that have FLOAT, REAL, or DOUBLE PRECISION type. "The data types real and double precision are inexact, variable-precision numeric types. On all currently supported platforms, these types are implementations of IEEE Standard 754 for Binary Floating-Point Arithmetic (single and double precision, respectively), to the extent that the underlying processor, operating system, and compiler support it." (PostgreSQL documentation) Do not use the approximate numeric types FLOAT, REAL, and DOUBLE PRECISION in order to present fractional numeric data. Due to the use of the IEEE 754 standard the results of calculations with the values, which have one of these types, can be inexact because out of necessity some numbers must be rounded to a value, which is very close. "Comparing two floating-point values for equality might not always work as expected." (PostgreSQL documentation)

Problem detection License: MIT (opens in new tab)

#387. Do not use the money data type

INFORMATION_SCHEMA only

Find base table columns with the Money data type. Each value of the money type has associated currency sign that depends on server settings. It could be $. Moreover, using the values for arithmetic operations requires casts that makes the code more complicated.

Problem detection License: MIT (opens in new tab)

#388. Double checking of the maximum character length

INFORMATION_SCHEMA+system catalog base tables

This query identifies superfluous CHECK constraints where a programmatic length check duplicates a declarative, data type-based length limit. For instance, a CHECK constraint like char_length(column) <= 100 on a column already defined as VARCHAR(100) is redundant.

Problem detection License: MIT (opens in new tab)

#389. Double negatives in Boolean expressions

INFORMATION_SCHEMA+system catalog base tables

Write code that is simple to understand and not confusing. A double negative is a grammatical construction occurring when two forms of negation are used in the same expression (https://en.wikipedia.org/wiki/Double_negative). Double negatives in Boolean expressions make it more difficult to understand and maintain the code.

Problem detection License: MIT (opens in new tab)

#390. Double negatives in regular expressions

INFORMATION_SCHEMA+system catalog base tables

Fing regular expression patterns that use [^\S] instead of \s or [^\D] instead of \d or [^\W] instead of \w.

Problem detection License: MIT (opens in new tab)

#391. Do you really need fractional seconds?

INFORMATION_SCHEMA only

Find default values that return current timestamp with the maximum number of fractional seconds (6).

Problem detection License: MIT (opens in new tab)

#392. Duplicate CHECK constraints that are connected directly to a table

INFORMATION_SCHEMA only

The same table should not have multiple CHECK constraints with exactly the same Boolean expression. Do remember that the same task can be solved in SQL usually in multiple different ways. Thus, the exact copies are not the only possible duplication.

Problem detection License: MIT (opens in new tab)

#393. Duplicate CHECK constraints that are connected to a domain

INFORMATION_SCHEMA only

The same domain should not have multiple CHECK constraints with exactly the same Boolean expression. Do remember that the same task can be solved in SQL usually in multiple different ways. Thus, the exact copies are not the only possible duplication.

Problem detection License: MIT (opens in new tab)

#394. Duplicate comments

INFORMATION_SCHEMA+system catalog base tables

Find comments that have been registered with a COMMENT statement and that are associated with more than one object. It would probably mean that a comment is incorrect or missing.

Problem detection License: MIT (opens in new tab)

#395. Duplicate DEFAULT values of base table columns

INFORMATION_SCHEMA only

Find base table columns that have both default value determined through a domain and default value that is directly attached to the column. Do not duplicate specifications of default values to avoid confusion and surprises. If column and domain both have a default value, then in case of inserting data the default value that is associated directly with the column is used.

Problem detection License: MIT (opens in new tab)

#396. Duplicate domains

INFORMATION_SCHEMA only

Find domains that have the same properties (base type, character length, not null + check constraints, default value, collation). There should not be multiple domains that have the same properties. Do remember that the same task can be solved in SQL usually in multiple different ways. Therefore, the domains may have syntactically different check constraints that solve the same task. Thus, the exact copies are not the only possible duplication.

Problem detection License: MIT (opens in new tab)

#397. Duplicate enumerated types

INFORMATION_SCHEMA+system catalog base tables

Find enumerated types with exactly the same values. There should not be multiple types that have the same values.

Problem detection License: MIT (opens in new tab)

#398. Duplicate foreign key constraints

system catalog base tables only

Find duplicate foreign key constraints, which involve the same columns and refer to the same set of columns.

Problem detection License: MIT (opens in new tab)

#399. Duplicate independent (i.e., not created based on a table) composite types

system catalog base tables only

Find composite types with the same attributes (regardless of the order of attributes). Make sure that there is no duplication.

Problem detection License: MIT (opens in new tab)

#400. Duplicate keys

system catalog base tables only

Find completely overlapping key (primary key, unique, and exclude where all operators are =) constraints. This is a form of duplication. It leads to the creation of multiple indexes to the same set of columns.

Problem detection License: MIT (opens in new tab)
# Name Goal Type (sorted ascending) Data source Last update License Actions
381 Do not specify a list of values in a table column definition Find cases where the list of valid data values in the column is specified in the column definition (in addition to specifying the type of the column) by using, for instance, check constraints or enumerated types. The check constraint is either associated directly with a table or is associated with a domain. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
382 Do not use a generic attribute table Find base tables that implement a highly generic database design (EAV design - Entiry-Attribute-Value design), according to which attribute values are recorded in a generic table that contains attribute-value pairs. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
383 Do not use approach that one size fits all (primary key columns) Find base base tables have the simple primary key that contains the column with the (case insensitive) name id and an integer type. In addition, the primary key values are generated automatically by the system by using a sequence generator. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
384 Do not use approach that one size fits all (unique index columns) Find base base tables have a simple unique index (not associated with a constraint) that contains the column with the (case insensitive) name id and an integer type. In addition, the key values are generated automatically by the system by using a sequence generator. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
385 Do not use dual-purpose foreign keys Find cases where the same column of a base table T is used to record references to multiple base tables. In addition, one has to add additional column to T for holding metadata about the parent table, referenced by the current row. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
386 Do not use FLOAT Data Type Find base table columns that have FLOAT, REAL, or DOUBLE PRECISION type. "The data types real and double precision are inexact, variable-precision numeric types. On all currently supported platforms, these types are implementations of IEEE Standard 754 for Binary Floating-Point Arithmetic (single and double precision, respectively), to the extent that the underlying processor, operating system, and compiler support it." (PostgreSQL documentation) Do not use the approximate numeric types FLOAT, REAL, and DOUBLE PRECISION in order to present fractional numeric data. Due to the use of the IEEE 754 standard the results of calculations with the values, which have one of these types, can be inexact because out of necessity some numbers must be rounded to a value, which is very close. "Comparing two floating-point values for equality might not always work as expected." (PostgreSQL documentation) Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
387 Do not use the money data type Find base table columns with the Money data type. Each value of the money type has associated currency sign that depends on server settings. It could be $. Moreover, using the values for arithmetic operations requires casts that makes the code more complicated. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
388 Double checking of the maximum character length This query identifies superfluous CHECK constraints where a programmatic length check duplicates a declarative, data type-based length limit. For instance, a CHECK constraint like char_length(column) <= 100 on a column already defined as VARCHAR(100) is redundant. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
389 Double negatives in Boolean expressions Write code that is simple to understand and not confusing. A double negative is a grammatical construction occurring when two forms of negation are used in the same expression (https://en.wikipedia.org/wiki/Double_negative). Double negatives in Boolean expressions make it more difficult to understand and maintain the code. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
390 Double negatives in regular expressions Fing regular expression patterns that use [^\S] instead of \s or [^\D] instead of \d or [^\W] instead of \w. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
391 Do you really need fractional seconds? Find default values that return current timestamp with the maximum number of fractional seconds (6). Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
392 Duplicate CHECK constraints that are connected directly to a table The same table should not have multiple CHECK constraints with exactly the same Boolean expression. Do remember that the same task can be solved in SQL usually in multiple different ways. Thus, the exact copies are not the only possible duplication. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
393 Duplicate CHECK constraints that are connected to a domain The same domain should not have multiple CHECK constraints with exactly the same Boolean expression. Do remember that the same task can be solved in SQL usually in multiple different ways. Thus, the exact copies are not the only possible duplication. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
394 Duplicate comments Find comments that have been registered with a COMMENT statement and that are associated with more than one object. It would probably mean that a comment is incorrect or missing. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
395 Duplicate DEFAULT values of base table columns Find base table columns that have both default value determined through a domain and default value that is directly attached to the column. Do not duplicate specifications of default values to avoid confusion and surprises. If column and domain both have a default value, then in case of inserting data the default value that is associated directly with the column is used. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
396 Duplicate domains Find domains that have the same properties (base type, character length, not null + check constraints, default value, collation). There should not be multiple domains that have the same properties. Do remember that the same task can be solved in SQL usually in multiple different ways. Therefore, the domains may have syntactically different check constraints that solve the same task. Thus, the exact copies are not the only possible duplication. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
397 Duplicate enumerated types Find enumerated types with exactly the same values. There should not be multiple types that have the same values. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
398 Duplicate foreign key constraints Find duplicate foreign key constraints, which involve the same columns and refer to the same set of columns. Problem detection system catalog base tables only MIT (opens in new tab) View (opens in new tab)
399 Duplicate independent (i.e., not created based on a table) composite types Find composite types with the same attributes (regardless of the order of attributes). Make sure that there is no duplication. Problem detection system catalog base tables only MIT (opens in new tab) View (opens in new tab)
400 Duplicate keys Find completely overlapping key (primary key, unique, and exclude where all operators are =) constraints. This is a form of duplication. It leads to the creation of multiple indexes to the same set of columns. Problem detection system catalog base tables only MIT (opens in new tab) View (opens in new tab)