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

AND
AND
ANDQueries of this category provide information about truth-values data that is kept in the database.
ANDFrom where does the query gets its information?
AND
AND

There are 24 queries.

Seq nrNameGoalTypeData sourceLast updateLicense...
1Base table columns with SMALLINT or BOOLEAN typeEach column should have the most appropriate data type. Developers sometimes forget to use SMALLINT type even if it is logically the best choice. Developers also sometimes forget to use BOOLEAN type and instead invent something.GeneralINFORMATION_SCHEMA only2020-11-06 14:51MIT License
2Base tables with multiple Boolean columnsFind base tables that have more than one column with Boolean type.GeneralINFORMATION_SCHEMA only2021-02-19 17:41MIT License
3BOOLEAN base table and foreign table columns with a CHECK constraint that involves olnly this columnFind base table and foreign table columns with the Boolean type that has a CHECK constraint that involves only this column. Avoid unnecessary CHECK constraints. The Boolean type contains only two values and there is nothing to check. By creating a check that determines that possible values in the column are TRUE and FALSE, one duplicates the attribute constraint (column has a type). This is a form of duplication.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-02-25 17:29MIT License
4BOOLEAN base table and foreign table columns with a PRIMARY KEY, UNIQUE, or FOREIGN KEY constraint that involves olnly this columnFind base table columns with the Boolean type that has a PRIMARY KEY, UNIQUE, or FOREIGN KEY constraint that involves only this column. Avoid unnecessary constraints. It is quite improbable that there must be such constraints. For instance, a table with PRIMARY KEY () or UNIQUE () constraint can have at most two rows.Problem detectionINFORMATION_SCHEMA+system catalog base tables2022-11-03 10:46MIT License
5CHECK constraints on columns with Boolean dataFind check constraints that involve columns with the type Boolean.GeneralINFORMATION_SCHEMA only2020-12-27 15:09MIT License
6Columns of base tables that hold truth values but do not have a default value (Boolean columns)Find columns of base tables that have type BOOLEAN but do not have a default value. There are only two truth values - TRUE and FALSE - in case of two-valued logic. Often it should be possible to select one of these as the default value of a column that has BOOLEAN type.Problem detectionINFORMATION_SCHEMA only2023-11-09 13:14MIT License
7Columns of base tables that hold truth values but do not have a default value (non-Boolean columns)Find non-foreign key columns of base tables that probably (based on the column name) contain values that represent truth values but do not have a default value. There are only two truth values - TRUE and FALSE - in case of two-valued logic. It could be possible to select one of these as the default value in case of the columns.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-03-20 14:08MIT License
8Columns of base tables that hold truth values but do not restrict the permitted values (non-Boolean columns)Find non-foreign key columns of base tables that probably (based on the column name) contain values that represent truth values but do not have a have a check constraint. The constraint should restrict the permitted values with values that represent truth values TRUE and FALSE.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-03-20 14:07MIT License
9Columns of base tables that hold truth values that do not have a default value although they could have it (Boolean columns)Find columns of base tables that have type BOOLEAN. Based on column names these implement a state machine or record agreements. At the same time the columns do not have a default value. There are only two truth values - TRUE and FALSE - in case of two-valued logic. It should be possible to select one of these as the default value of the column.Problem detectionINFORMATION_SCHEMA only2023-11-09 16:39MIT License
10Columns of base tables that hold truth values that do not have a default value although they could have it (non-Boolean columns)Find columns of base tables that do not have type BOOLEAN but are used to record Boolean values. Based on column names these implement a state machine or record agreements. At the same time the columns do not have a default value. There are only two truth values - TRUE and FALSE - in case of two-valued logic. It should be possible to select one of these as the default value of the column.Problem detectionINFORMATION_SCHEMA+system catalog base tables2023-11-09 16:40MIT License
11Columns with BOOLEAN type that do not have a good nameThe phrase "is_" or "has_" or "can_" (in English) or "on_" (in Estonian) should be used in the name - preferably in the beginning. Worse: agreed, kinnitatud. Better: contract_is_agreed, leping_on_kinnitatud. Perhaps the best: is_contract_agreed or is_agreement, on_leping_kinnitatud, on_kinnitatud.Problem detectionINFORMATION_SCHEMA+system catalog base tables2024-01-03 09:56MIT License
12Consistency of using NOT NULL constraints on Boolean base table columnsFind the number of mandatory and optional Boolean base table columns and the proportion of optional columns from all the Boolean columns. Use two-valued logic (TRUE, FALSE) instead of three-valued logic (TRUE, FALSE, UNKNOWN). Because NULL in a Boolean column means unknown make all the Boolean columns mandatory.Sofware measureINFORMATION_SCHEMA only2020-12-28 01:43MIT License
13Inconsistent naming of columns with BOOLEAN typeFind as to whether some columns with the type Boolean start with a prefix ("is", "has", "can", "on") and some do not.Problem detectionINFORMATION_SCHEMA+system catalog base tables2024-01-03 09:54MIT License
14Names of columns with the type BOOLEANThe naming of BOOLEAN columns must be consistent. For the better readability the names of such columns could have prefix "is_" (in English) or "on_" (in Estonian)GeneralINFORMATION_SCHEMA+system catalog base tables2024-01-03 09:41MIT License
15Perhaps a CHECK constraint about the combination of truth values is missingFind base tables that have at least two columns that have Boolean type and have at least one Boolean column that is not covered by a CHECK constraint involving more than one Boolean column. The Boolean columns possibly mean that we want to record data about states. Often the states depend on each other. For instance, if an order is archived it must be inactive.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-02-25 17:29MIT License
16Perhaps a state machine is implemented with Boolean columnsFind implementations of state machines that uses a set of one or more Boolean columns. These columns could have the type Boolean or could probably (based on the column name and non-participation in a foreign key) contain values that represent truth values.Problem detectionINFORMATION_SCHEMA+system catalog base tables2023-11-09 13:22MIT License
17Perhaps a too simplified state machineFind base table columns with Boolean type that name refers to the possibility that these are used to register as to whether an entity is currently in active state or not. Find the base tables that have exactly one Boolean column. During the system design one should find all the possible states of an entity type that influence the behavior of the information system. Data as to whether an entity is in one of these states should be in the database. Having only two states - active/inactive - is sometimes a too big simplification.Problem detectionINFORMATION_SCHEMA only2021-03-27 03:08MIT License
18Perhaps the type of a base table column/domain should be BOOLEAN (based on CHECK constraints)Find base table columns and domains that have a CHECK constraint that limits possible values in a manner that seems to indicate that the permitted values represent truth values, i.e., permitted values are 0/1 or true/false.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-02-25 17:29MIT License
19Perhaps the type of a base table column/domain should be BOOLEAN (based on types and default values)Find base table columns and domains that have a textual type and the default value that represents a truth-value. For instance, the type of a column could be VARCHAR and the column has the default value 'TRUE'.Problem detectionINFORMATION_SCHEMA only2021-02-25 17:30MIT License
20Perhaps the type of a base table column should be BOOLEAN (based on column names)Find base table columns that based on the name seem to hold truth values. Find columns that name starts with "is_" or "has_" or "can_" or "on_" and that do not have Boolean type.Problem detectionINFORMATION_SCHEMA+system catalog base tables2024-01-03 09:41MIT License