Catalog of PostgreSQL queries for finding information about a PostgreSQL database and its design problems

AND
AND
AND
ANDFrom where does the query gets its information?
AND
AND

There are 961 queries.

Seq nrNameGoalTypeData sourceLast updateLicense...
541Numeric literals between apostrophesPlacing numeric literals between apostrophes will cause unnecessary type conversions. It could also be that the literal should indeed be textual but the problem is in choosing the values. For instance, table Occupation has column occupation_code with the type VARCHAR(3). However, all the values in the column consist of digits (for instance, 1, 2, 3). Thus, it would have been better to a) use SMALLINT as the column type or b) use different occupation codes that contain additional symbols to digits.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-04 13:20MIT License
542ON DELETE CASCADE is not needed (based on classifier tables)Find foreign key constraints with ON DELETE CASCADE compensating action that refer to classifier (reference data) tables.Problem detectionINFORMATION_SCHEMA+system catalog base tables2023-12-08 14:52MIT License
543ON DELETE CASCADE is probably missing (based on the multiplicity of the relationship)Find foreign key constraints that completely overlap with a candidate key constraint (primary key or unique constraint) but the foreign key constraint does not have the ON DELETE CASCADE compensating action. In this case there is a foreign key that implements a relationship type between a strong entity type and a weak entity type (1-1 relationship type). Therefore, in this case ON DELETE CASCADE is an appropriate compensating action.Problem detectionsystem catalog base tables only2021-02-25 17:29MIT License
544ON DELETE CASCADE is probably not needed (based on the relationship type)Find foreign key constraints that implement a non-identifying relationship type and have ON DELETE CASCADE compensating action. If the identity of the parent table is not a part of the identity of the child table, then there is a non-identifying relationship type and most probably the foreign key should not have ON DELETE CASCADE.Problem detectionsystem catalog base tables only2023-10-28 18:38MIT License
545ON DELETE SET NULL is probably missingFind 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 detectionsystem catalog base tables only2021-02-25 17:29MIT License
546One-to-one relationshipsFind 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.Generalsystem catalog base tables only2023-01-06 13:39MIT License
547One true lookup tableFind tables that contain all (or most) of the classifier values and tables that refer to these.Problem detectionsystem catalog base tables only2021-02-25 17:29MIT License
548Only ID primary keyFind base base tables have the simple primary key that contains a 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. In addition the base table must not have any unique constraint.Problem detectionINFORMATION_SCHEMA+system catalog base tables2022-11-09 15:15MIT License
549Only one value permitted in a base table or a foreign table column (based on check constraints)Find columns of base tablesor foreign tables in case of which a check constraint on the column permits only one value in the column. The constraint may be correct if it is applied to a column of a subtable that is inherited from the supertable or is used to enfore the rule that the table can have at most one row.GeneralINFORMATION_SCHEMA+system catalog base tables2020-12-25 17:57MIT License
550Only one value permitted in a base table or a foreign table column (based on enumeration types)Find columns of base tables or foreign tables in case of which the type of the column permits only one value in the column. The type is an enumeration type that specifies only one value.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-02-25 17:30MIT License
551Only one value permitted in a non-inherited base table or a foreign table column (based on check constraints)Find columns of base tables or foreign tables in case of which a check constraint on the column permits only one value in the column. Exclude columns that are inherited from a supertable because the constraint may be correct if it is applied to a column of a subtable that is inherited from the supertable.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-02-25 17:29MIT License
552ON UPDATE CASCADE is not needed (based on surrogate keys)Find foreign key constraints that reference to a candidate key that is a surrogate key, i.e., its values are generated by the system by using sequence generators. Do not use ON UPDATE CASCADE in case of foreign keys that reference to surrogate keys.Problem detectionINFORMATION_SCHEMA+system catalog base tables2022-04-30 18:39MIT License
553ON UPDATE CASCADE is perhaps missing (based on the compensating actions of other foreign key constraints)Find inconsistencies of using ON UPDATE CASCADE in case of foreign key constraints. An example of inconsistency is that there are two foreign key constraints in different tables that refer to the same table and its candidate key. One of the constraints has ON UPDATE CASCADE compensating action one does not. ON UPDATE CASCADE usage should be consistent, otherwise it does not allow us to change key values in the primary table. More generally, there is a set of foreign key constraints F that refer to a candidate key of table T. It cannot be the case that a proper non-empty subset of these foreign keys have ON UPDATE CASCADE compensatory action. Either all the constraints in F should have it or none of it should have it (depending on circumstances).Problem detectionsystem catalog base tables only2022-04-30 18:39MIT License
554ON UPDATE CASCADE is probably missing (based on column names)Find foreign key constraints that do not feature ON UPDATE CASCADE compensating action although people have a reason to change the key value in the primary table by assuming that the names of foreign key columns correctly point towards the use of natural keys in the table.Problem detectionsystem catalog base tables only2023-11-16 11:59MIT License
555ON UPDATE CASCADE is probably missing (based on data types)Find foreign key constraints where the foreign key column does not have an integer type or uuid type and the foreign key constraint does not have ON UPDATE CASCADE compensating action. In this case the foreign key probably refferes to a natural key (i.e., a key that values have meaning outside the computer system) and ON UPDATE CASCADE would be suitable because the key values could be changed over time.Problem detectionINFORMATION_SCHEMA+system catalog base tables2023-10-06 14:19MIT License
556ON UPDATE CASCADE is probably missing (based on the properties of the referenced column)Find the foreign key constraints that do not have ON UPDATE CASCADE and that referenced key is a simple key that has an integer type, is not covered by another foreign key, and does not have an associated sequence generator, i.e., the foreign key references a simple natural key.Problem detectionINFORMATION_SCHEMA+system catalog base tables2022-04-30 18:39MIT License
557Optional base table columnsFind optional base table columns, i.e., columns that permit NULLs. Are you sure you want to allow NULLs in these columns?GeneralINFORMATION_SCHEMA only2020-11-21 03:02MIT License
558Optional base table columns that have a default value that is not the empty stringFind optiona base table columns that have a default value that is not the empty string. Such columns should be mandatory.Problem detectionINFORMATION_SCHEMA only2021-02-25 17:29MIT License
559Optional base table columns that participate in a UNIQUE constraint or indexFind optional base table columns that participate in a UNIQUE constraint or index. Each base table has one or more candidate keys. One of these is usually selected to be the primary key, other are called alternate keys. To enforce an alternate key one should define a UNIQUE constraint and determine that all the key columns are mandatory (NOT NULL) just like the primary key columns are mandatory. Make sure that the NOT NULL constraint is not missing on these columns.Problem detectionINFORMATION_SCHEMA+system catalog base tables2022-10-21 15:57MIT License
560Optional columns before mandatory columnsFind cases where optional columns are before a mandatory column. Place mandatory columns before optional columns to improve comprehensibility of the table.Problem detectionINFORMATION_SCHEMA only2021-02-25 17:29MIT License