| Goal | Find 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. |
|---|---|
| Notes | The query finds all the base tables that have at least one Boolean column where the name of the column refers to an event that may be caused by a state transition. The query shows all the Boolean columns of the tables. The query takes into account columns with the type Boolean as well as columns that do not have the Boolean type although the name of the column indicates that the column contains truth values. It returns the name of table and its schema as well as names and types of columns. In case of the string_agg function, the line break (br) tag is used as a part of the separator for the better readability in case the query result is displayed in a web browser. The query may return false positive results if the columns are not used for the registration of data about the state. The query takes into account both column names in Estonian and in English. |
| Type | Problem detection (Each row in the result could represent a flaw in the design) |
| Reliability | Medium (Medium number of false-positive results) |
| License | MIT (opens in new tab) |
| Fixing Suggestion | Create a state classifier table and associated it with the table in question by using a foreign key (see Level 2 Status Pattern, Current Status from L. Silverston ja P. Agnew, „The Data Model Resource Book, Volume 3: Universal Patterns for Data Modeling,“ Chichester, John Wiley & Sons Ltd, 2009.) or use a temporal type instead of the type Boolean. |
| Data Source | INFORMATION_SCHEMA+system catalog |
| SQL Query |
|
Collections
This query belongs to the following collections:
Find problems about base tables
A selection of queries that return information about the data types, field sizes, default values as well as general structure of base tables. Contains all the types of queries - problem detection, software measure, and general overview
| Name | Description |
|---|---|
| Find problems about base tables | A selection of queries that return information about the data types, field sizes, default values as well as general structure of base tables. Contains all the types of queries - problem detection, software measure, and general overview |
Categories
This query is classified under the following categories:
Boolean data
Queries of this category provide information about truth-values data that is kept in the database.
Comfortability of database evolution
Queries of this category provide information about the means that influence database evolution.
Comfortability of data management
Queries of this category provide information about the means that have been used to make the use or management of database more comfortable and thus, more efficient.
Result quality depends on names
Queries of this category use names (for instance, column names) to try to guess the meaning of a database object. Thus, the goodness of names determines the number of false positive and false negative results.
State machine
Queries of this category provide information about registration of states of entities in a database.
| Name | Description |
|---|---|
| Boolean data | Queries of this category provide information about truth-values data that is kept in the database. |
| Comfortability of database evolution | Queries of this category provide information about the means that influence database evolution. |
| Comfortability of data management | Queries of this category provide information about the means that have been used to make the use or management of database more comfortable and thus, more efficient. |
| Result quality depends on names | Queries of this category use names (for instance, column names) to try to guess the meaning of a database object. Thus, the goodness of names determines the number of false positive and false negative results. |
| State machine | Queries of this category provide information about registration of states of entities in a database. |
Further reading and related materials:
| Reference |
|---|
| https://medium.com/@jpotts18/3-reasons-i-hate-booleans-in-databases-646d99696580 |
| https://softwareengineering.stackexchange.com/questions/214940/how-to-handle-status-columns-in-designing-tables |
| L. Silverston ja P. Agnew, „The Data Model Resource Book, Volume 3: Universal Patterns for Data Modeling,“ Chichester, John Wiley & Sons Ltd, 2009. Level 1 Status Pattern |
| Representing the Status of the Main Entities of an Information System in SQL Databases Master Thesis, in Estonian. |