Filter Queries

Found 1091 queries.

Page 51 of 55
  • 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.

#1001. Not inherited CHECK constraints

system catalog base tables only

Find CHECK constraints that have been defined in a supertable (parent table) but not in its subtables. An entity that belongs to a subtype should also belong to its supertype. If a subtype entity satisfies some constraint, then logically it must also satisfy the constraints of the supertype as well. If CHECK constraints are not inherited, then this is not guaranteed. If you implement subtyping not merely reuse implementation in the subtables, then the subtables must have at least the same CHECK constraints as the supertable. CHECK(false) on a supertable is an appropriate CHECK constraint if one wants to prevent registering data directly to the supertable, i.e., data can only be added to the subtables.

General License: MIT (opens in new tab)

#1002. Not inherited CHECK constraints that are recreated in the immediate subtable

system catalog base tables only

Find base table CHECK constraints that have been defined as NOT INHERITED but the constraint with the same Boolean expression has been defined in the immediate subtable of the table.

Problem detection License: MIT (opens in new tab)

#1003. Not inherited CHECK constraints that cover at least one column

system catalog base tables only

Find CHECK constraints that cover at least one column and that have been defined in a supertable (parent table) but not in its subtables. An entity that belongs to a subtype should also belong to its supertype. If a subtype entity satisfies some constraint, then logically it must also satisfy the constraints of the supertype as well. If CHECK constraints are not inherited, then this is not guaranteed. If you implement subtyping not merely reuse implementation in the subtables, then the subtables must have at least the same CHECK constraints as the supertable.

Problem detection License: MIT (opens in new tab)

#1004. NOT VALID foreign key constraints

system catalog base tables only

Find not valid foreign key constraints. These constraints have been created so that the existing data has not been checked against the constraint. It could be deliberate in case of legacy systems that have data quality problems. However, ideally all the data in the table conforms to the constraint.

Problem detection License: MIT (opens in new tab)

#1005. Number of rows in base tables

system catalog base tables only

Find the number of rows in base tables.

General License: MIT (opens in new tab)

#1006. Number of system-generated and user-defined constraint names by constraint type (constraints that involve more than one column)

system catalog base tables only

Find the number of system-generated constraint names by constraint type. Names should follow the same style. If there is a mix of system-generated and user-defined names, then the style is most probably different.

Sofware measure License: MIT (opens in new tab)

#1007. Number of system-generated and user-defined constraint names by constraint type (constraints that involve one column)

system catalog base tables only

Find the number of system-generated constraint names by constraint type. Names should follow the same style. If there is a mix of system-generated and user-defined names, then the style is most probably different.

Sofware measure License: MIT (opens in new tab)

#1008. ON DELETE CASCADE is probably missing (based on the multiplicity of the relationship)

system catalog base tables only

This query identifies foreign key constraints that likely require an ON DELETE CASCADE action. It targets a specific pattern: where the foreign key constraint's columns are identical to a candidate key (Primary Key or Unique constraint) of the same table. This structure implements a one-to-one identifying relationship, where the child entity is existentially dependent on the parent (a weak entity depending on a strong entity). The absence of ON DELETE CASCADE in this scenario is a design flaw, as it prevents the parent row from being deleted and breaks the conceptual model.

Problem detection License: MIT (opens in new tab)

#1009. ON DELETE CASCADE is probably not needed (based on the relationship type)

system catalog base tables only

This query identifies foreign key constraints that use ON DELETE CASCADE in a non-identifying relationship. A relationship is considered non-identifying if the foreign key columns in the child table are not part of the child table's candidate key. In such cases, the child entity has its own independent identity, and using ON DELETE CASCADE is often a design flaw that can lead to unexpected and catastrophic data loss.

Problem detection License: MIT (opens in new tab)

#1010. ON DELETE SET NULL is probably missing

system catalog base tables only

Find implementations of the adjacency list design pattern, where the corresponding foreign key columns are optional but the foreign key constraint does not have ON DELETE SET NULL compensating action. Implement adjacency list correctly.

Problem detection License: MIT (opens in new tab)

#1011. One-to-one relationships

system catalog base tables only

Find one-to-one relationships between base tables. In this case the foreign key columns must have primary key or unique constraint. These tables could implement inheritance hierarchy that has been specified in the conceptual data model.

General License: MIT (opens in new tab)

#1012. One true lookup table

system catalog base tables only

This query identifies central classifier (reference) tables that store all or most of the system's reference values, along with the dependent tables that reference them.

Problem detection License: MIT (opens in new tab)

#1013. ON UPDATE CASCADE is perhaps missing (based on the compensating actions of other foreign key constraints)

system catalog base tables only

This query detects inconsistencies in the application of ON UPDATE CASCADE for foreign keys referencing the same candidate key. It identifies sets of foreign key constraints where a proper, non-empty subset is configured with ON UPDATE CASCADE. Such a mixed configuration is a functional flaw, as any attempt to update the parent key will be blocked by the non-cascading constraints, rendering the CASCADE action ineffective and preventing the intended data modification. The principle of atomicity requires that for any given key, either all referencing foreign keys have ON UPDATE CASCADE, or none do.

Problem detection License: MIT (opens in new tab)

#1014. ON UPDATE CASCADE is probably missing (based on column names)

system catalog base tables only

This query identifies foreign key constraints that are likely missing an ON UPDATE CASCADE action. It operates on the heuristic that foreign keys referencing a natural key should permit cascading updates. The query uses a naming convention to identify probable natural keys, specifically flagging foreign key columns having the suffix or prefix "code" on the assumption that such values are user-defined and may require modification. The absence of ON UPDATE CASCADE on these keys can lead to referential integrity violations when the parent key is updated.

Problem detection License: MIT (opens in new tab)

#1015. ON UPDATE CASCADE is probably not needed (based on column names)

system catalog base tables only

This query identifies foreign key constraints with a superfluous ON UPDATE CASCADE action. It operates on the heuristic that foreign keys referencing surrogate keys should not permit cascading updates, as their values are immutable by definition. The query uses a naming convention to identify probable surrogate keys, specifically flagging foreign key columns with the prefix or suffix "id". The presence of ON UPDATE CASCADE on such keys is not only unnecessary but also misrepresents the nature of the relationship to a schema observer.

Problem detection License: MIT (opens in new tab)

#1016. Optional composite foreign keys that do not have MATCH FULL specified

system catalog base tables only

Find optional composite foreign keys that do not have MATCH FULL specified. Without MATCH FULL the system will permit partial foreign key values

Problem detection License: MIT (opens in new tab)

#1017. Overlapping non-function based indexes that have the same leading column but with different operator class

system catalog base tables only

Find non-function based indexes (both unique and non-unique) that have identical first column but the operator class that is used in case of the first column is different. Include unique indexes that support a constraint (primary key, unique, exclude), i.e., these indexes have been automatically created due to the constraint declaration.

General License: MIT (opens in new tab)

#1018. Patterns of the names of columns of simple primary keys

system catalog base tables only

Find the patterns of the names of columns of simple primary keys. Make sure that the naming is consistent. Ideally, the names should indicate as to whether the column is a surrogate or a natural key column. PostgreSQL 14 added primary keys, unique constraints, and foreign keys to system catalogs. Thus the query was modified to exclude the results from the system catalog.

General License: MIT (opens in new tab)

#1019. Percentage of the total index storage size from the total database storage size (system catalog included)

system catalog base tables only

Get overview of disk usage.

Sofware measure License: MIT (opens in new tab)

#1020. Perhaps an inconsistent use of NO ACTION and RESTRICT in the foreign key declarations

system catalog base tables only

Find as to whether in case of foreign key constraints both the compensating actions RESTRICT and NO ACTION are used within the same database. If the same thing has to do in different places, then try to do it in the same way.

Problem detection License: MIT (opens in new tab)
# 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
1001 Not inherited CHECK constraints Find CHECK constraints that have been defined in a supertable (parent table) but not in its subtables. An entity that belongs to a subtype should also belong to its supertype. If a subtype entity satisfies some constraint, then logically it must also satisfy the constraints of the supertype as well. If CHECK constraints are not inherited, then this is not guaranteed. If you implement subtyping not merely reuse implementation in the subtables, then the subtables must have at least the same CHECK constraints as the supertable. CHECK(false) on a supertable is an appropriate CHECK constraint if one wants to prevent registering data directly to the supertable, i.e., data can only be added to the subtables. General system catalog base tables only MIT (opens in new tab) View
1002 Not inherited CHECK constraints that are recreated in the immediate subtable Find base table CHECK constraints that have been defined as NOT INHERITED but the constraint with the same Boolean expression has been defined in the immediate subtable of the table. Problem detection system catalog base tables only MIT (opens in new tab) View
1003 Not inherited CHECK constraints that cover at least one column Find CHECK constraints that cover at least one column and that have been defined in a supertable (parent table) but not in its subtables. An entity that belongs to a subtype should also belong to its supertype. If a subtype entity satisfies some constraint, then logically it must also satisfy the constraints of the supertype as well. If CHECK constraints are not inherited, then this is not guaranteed. If you implement subtyping not merely reuse implementation in the subtables, then the subtables must have at least the same CHECK constraints as the supertable. Problem detection system catalog base tables only MIT (opens in new tab) View
1004 NOT VALID foreign key constraints Find not valid foreign key constraints. These constraints have been created so that the existing data has not been checked against the constraint. It could be deliberate in case of legacy systems that have data quality problems. However, ideally all the data in the table conforms to the constraint. Problem detection system catalog base tables only MIT (opens in new tab) View
1005 Number of rows in base tables Find the number of rows in base tables. General system catalog base tables only MIT (opens in new tab) View
1006 Number of system-generated and user-defined constraint names by constraint type (constraints that involve more than one column) Find the number of system-generated constraint names by constraint type. Names should follow the same style. If there is a mix of system-generated and user-defined names, then the style is most probably different. Sofware measure system catalog base tables only MIT (opens in new tab) View
1007 Number of system-generated and user-defined constraint names by constraint type (constraints that involve one column) Find the number of system-generated constraint names by constraint type. Names should follow the same style. If there is a mix of system-generated and user-defined names, then the style is most probably different. Sofware measure system catalog base tables only MIT (opens in new tab) View
1008 ON DELETE CASCADE is probably missing (based on the multiplicity of the relationship) This query identifies foreign key constraints that likely require an ON DELETE CASCADE action. It targets a specific pattern: where the foreign key constraint's columns are identical to a candidate key (Primary Key or Unique constraint) of the same table. This structure implements a one-to-one identifying relationship, where the child entity is existentially dependent on the parent (a weak entity depending on a strong entity). The absence of ON DELETE CASCADE in this scenario is a design flaw, as it prevents the parent row from being deleted and breaks the conceptual model. Problem detection system catalog base tables only MIT (opens in new tab) View
1009 ON DELETE CASCADE is probably not needed (based on the relationship type) This query identifies foreign key constraints that use ON DELETE CASCADE in a non-identifying relationship. A relationship is considered non-identifying if the foreign key columns in the child table are not part of the child table's candidate key. In such cases, the child entity has its own independent identity, and using ON DELETE CASCADE is often a design flaw that can lead to unexpected and catastrophic data loss. Problem detection system catalog base tables only MIT (opens in new tab) View
1010 ON DELETE SET NULL is probably missing Find implementations of the adjacency list design pattern, where the corresponding foreign key columns are optional but the foreign key constraint does not have ON DELETE SET NULL compensating action. Implement adjacency list correctly. Problem detection system catalog base tables only MIT (opens in new tab) View
1011 One-to-one relationships Find one-to-one relationships between base tables. In this case the foreign key columns must have primary key or unique constraint. These tables could implement inheritance hierarchy that has been specified in the conceptual data model. General system catalog base tables only MIT (opens in new tab) View
1012 One true lookup table This query identifies central classifier (reference) tables that store all or most of the system's reference values, along with the dependent tables that reference them. Problem detection system catalog base tables only MIT (opens in new tab) View
1013 ON UPDATE CASCADE is perhaps missing (based on the compensating actions of other foreign key constraints) This query detects inconsistencies in the application of ON UPDATE CASCADE for foreign keys referencing the same candidate key. It identifies sets of foreign key constraints where a proper, non-empty subset is configured with ON UPDATE CASCADE. Such a mixed configuration is a functional flaw, as any attempt to update the parent key will be blocked by the non-cascading constraints, rendering the CASCADE action ineffective and preventing the intended data modification. The principle of atomicity requires that for any given key, either all referencing foreign keys have ON UPDATE CASCADE, or none do. Problem detection system catalog base tables only MIT (opens in new tab) View
1014 ON UPDATE CASCADE is probably missing (based on column names) This query identifies foreign key constraints that are likely missing an ON UPDATE CASCADE action. It operates on the heuristic that foreign keys referencing a natural key should permit cascading updates. The query uses a naming convention to identify probable natural keys, specifically flagging foreign key columns having the suffix or prefix "code" on the assumption that such values are user-defined and may require modification. The absence of ON UPDATE CASCADE on these keys can lead to referential integrity violations when the parent key is updated. Problem detection system catalog base tables only MIT (opens in new tab) View
1015 ON UPDATE CASCADE is probably not needed (based on column names) This query identifies foreign key constraints with a superfluous ON UPDATE CASCADE action. It operates on the heuristic that foreign keys referencing surrogate keys should not permit cascading updates, as their values are immutable by definition. The query uses a naming convention to identify probable surrogate keys, specifically flagging foreign key columns with the prefix or suffix "id". The presence of ON UPDATE CASCADE on such keys is not only unnecessary but also misrepresents the nature of the relationship to a schema observer. Problem detection system catalog base tables only MIT (opens in new tab) View
1016 Optional composite foreign keys that do not have MATCH FULL specified Find optional composite foreign keys that do not have MATCH FULL specified. Without MATCH FULL the system will permit partial foreign key values Problem detection system catalog base tables only MIT (opens in new tab) View
1017 Overlapping non-function based indexes that have the same leading column but with different operator class Find non-function based indexes (both unique and non-unique) that have identical first column but the operator class that is used in case of the first column is different. Include unique indexes that support a constraint (primary key, unique, exclude), i.e., these indexes have been automatically created due to the constraint declaration. General system catalog base tables only MIT (opens in new tab) View
1018 Patterns of the names of columns of simple primary keys Find the patterns of the names of columns of simple primary keys. Make sure that the naming is consistent. Ideally, the names should indicate as to whether the column is a surrogate or a natural key column. PostgreSQL 14 added primary keys, unique constraints, and foreign keys to system catalogs. Thus the query was modified to exclude the results from the system catalog. General system catalog base tables only MIT (opens in new tab) View
1019 Percentage of the total index storage size from the total database storage size (system catalog included) Get overview of disk usage. Sofware measure system catalog base tables only MIT (opens in new tab) View
1020 Perhaps an inconsistent use of NO ACTION and RESTRICT in the foreign key declarations Find as to whether in case of foreign key constraints both the compensating actions RESTRICT and NO ACTION are used within the same database. If the same thing has to do in different places, then try to do it in the same way. Problem detection system catalog base tables only MIT (opens in new tab) View