| Goal | This query identifies foreign key constraints that link tables with inconsistent naming conventions—specifically, where one table name is singular and the other is plural. Using Estonian language heuristics to distinguish grammatical number, the query detects mixed naming styles across directly related tables. While adopting either singular or plural table names is a matter of architectural preference, mixing both within the same schema degrades predictability, confuses developers, and complicates automated ORM code generation. |
|---|---|
| Notes | The query works somewhat correctly only if the names are in Estoniand. The query is based on a simplified assumption that in case of many words in Estonian (of course, not all) the plural form is indicated by the letter "d" at the end of the word. If the name or its subcomponent ends with de_ or te_, then it is considered plural. Names that for example end with id, oid, kood, or uuid are considered singular. Thus, "auto" is considered singular whereas "autod" and "autode_aruanne" are considered plural. |
| 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) |
| Data Source | INFORMATION_SCHEMA+system catalog |
| SQL Query |
|
Fixing Suggestion
Align the flagged tables with your project's singular or plural naming standard using ALTER TABLE ... RENAME TO, after confirming that the Estonian morphological check did not trigger a false positive.
Categories
This query is classified under the following categories:
Inconsistencies
Queries of this catergory provide information about inconsistencies of solving the same problem in different places.
Naming
Queries of this category provide information about the style of naming.
| Name | Description |
|---|---|
| Inconsistencies | Queries of this catergory provide information about inconsistencies of solving the same problem in different places. |
| Naming | Queries of this category provide information about the style of naming. |