| Goal | Find foreign key columns that have a default value that is not present in the parent table. Identify default values that cause violations of the referential constraints. |
|---|---|
| Notes | The test creates a user-defined function that should be dropped in the end (see the garbage collection). In case of a test database that does not have test data the query returns false positive results. |
| Type | Problem detection (Each row in the result could represent a flaw in the design) |
| Reliability | High (Few or no false-positive results) |
| License | MIT (opens in new tab) |
| Fixing Suggestion | Add a row where the key is the default value in question to the parent table. |
| Data Source | INFORMATION_SCHEMA+system catalog |
| SQL Query |
|
Collections
This query belongs to the following collections:
Find problems automatically
Queries, that results point to problems in the database. Each query in the collection produces an initial assessment. However, a human reviewer has the final say as to whether there is a problem or not .
| Name | Description |
|---|---|
| Find problems automatically | Queries, that results point to problems in the database. Each query in the collection produces an initial assessment. However, a human reviewer has the final say as to whether there is a problem or not . |
Categories
This query is classified under the following categories:
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.
Data at the database logical level
Queries of this category provide information about data in base tables.
Default value
Queries of this catergory provide information about the use of default values.
Read user data
Queries of this category have to read data from user tables.
Relationships between tables
Queries of this category provide information about how database tables are connected to each other and whether such connections have been explicitly defined and whether it has been done correctly.
| Name | Description |
|---|---|
| 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. |
| Data at the database logical level | Queries of this category provide information about data in base tables. |
| Default value | Queries of this catergory provide information about the use of default values. |
| Read user data | Queries of this category have to read data from user tables. |
| Relationships between tables | Queries of this category provide information about how database tables are connected to each other and whether such connections have been explicitly defined and whether it has been done correctly. |