| Goal | This query identifies base table columns that, based on their name, are presumed to store personal names but lack an explicit maximum length constraint. It operates on a heuristic, flagging columns with names like first_name, surname, etc., that are defined with unbounded textual types (e.g., text, varchar) and have no corresponding CHECK constraint to limit their length (e.g., char_length(col) <= n). The absence of such a limit is a design flaw that can introduce usability issues in front-end applications and create potential security vulnerabilities related to excessive data submission. |
| Notes | The query finds columns with type text or varchar that do not restrict the maximum length with a CHECK constraint. |
| 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 License |
| Fixing Suggestion | Add a check constraint to restrict the maximum character length. |
| Data Source | INFORMATION_SCHEMA+system catalog |
| SQL Query |
|
This query belongs to the following collections:
| 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 . |
This query is classified under the following categories:
| Name | Description |
|---|---|
| CHECK constraints | Queries of this category provide information about CHECK constraints. |
| Field size | Queries of this category provide information about the maximum size of values that can be recorded in column fields |
| 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. |
| Validity and completeness | Queries of this category provide information about whether database design represents the world (domain) correctly (validity) and whether database design captures all the information about the world (domain) that is correct and relevant (completeness). |
Further reading and related materials: