| Goal | "Names in software are 90 percent of what make software readable. You need to take the time to choose them wisely and keep them relevant. Names are too important to treat carelessly. Names should not cause confusion." (Robert C. Martin, Clean Code) Names should not cause confusion. Find the distinct names (identifiers) of user-defined objects that are SQL keywords that are completely unreserved in PostgreSQL. In PostgreSQL "there are several different classes of tokens ranging from those that can never be used as an identifier to those that have absolutely no special status in the parser as compared to an ordinary identifier. " (PostgreSQL manual) Although the names are unreserved keywords in PostgreSQL these could be reserved keywords in other systems, which would complicate database migration. Moreover, such identifiers are often too general, i.e., do not provide enough information about the named object. |
|---|---|
| Notes | The query uses pg_get_keywords() system catalog information function to find all the keywords that are unreserved in PostgreSQL. In case of each suspected identifier it also presents the status of the keyword in PostgreSQL and information about its usage as column label. The query does not consider objects that are a part of an extension. |
| 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) |
| Data Source | INFORMATION_SCHEMA+system catalog |
| SQL Query |
|
Collections
This query belongs to the following collections:
Find problems about names
A selection of queries that return information about the names of database objects. Contains all the types of queries - problem detection, software measure, and general overview.
| Name | Description |
|---|---|
| Find problems about names | A selection of queries that return information about the names of database objects. Contains all the types of queries - problem detection, software measure, and general overview. |
Categories
This query is classified under the following categories:
Comfortability of database evolution
Queries of this category provide information about the means that influence database evolution.
Naming
Queries of this category provide information about the style of naming.
| Name | Description |
|---|---|
| Comfortability of database evolution | Queries of this category provide information about the means that influence database evolution. |
| Naming | Queries of this category provide information about the style of naming. |
Further reading and related materials:
Perhaps the names are too general. For instance, table name "Table" or column name "column" are at the wrong level of abstraction. The corresponding code smells in case of cleaning code are "N1: Choose Descriptive Names", "N2: Choose Names at the Appropriate Level of Abstraction", "N4: Unambiguous Names", "N7: Names Should Describe Side-Effects". (Robert C. Martin, Clean Code)
Smell "Meaningless name": Sharma, T., Fragkoulis, M., Rizou, S., Bruntink, M. and Spinellis, D.: Smelly relations: measuring and understanding database schema quality. In: Proceedings of the 40th International Conference on Software Engineering: Software Engineering in Practice, pp. 55-64. ACM, (2018).
| Reference |
|---|
| https://www.postgresql.org/docs/current/sql-keywords-appendix.html |
| Perhaps the names are too general. For instance, table name "Table" or column name "column" are at the wrong level of abstraction. The corresponding code smells in case of cleaning code are "N1: Choose Descriptive Names", "N2: Choose Names at the Appropriate Level of Abstraction", "N4: Unambiguous Names", "N7: Names Should Describe Side-Effects". (Robert C. Martin, Clean Code) |
| Smell "Meaningless name": Sharma, T., Fragkoulis, M., Rizou, S., Bruntink, M. and Spinellis, D.: Smelly relations: measuring and understanding database schema quality. In: Proceedings of the 40th International Conference on Software Engineering: Software Engineering in Practice, pp. 55-64. ACM, (2018). |
| https://www.sqlstyle.guide/ |