The list of all the queries

Check as to wheteher the names of tables are in the plural or in the singular form (Estonian version)

Query goal: Check as to wheteher the names of tables are in the plural or in the singular form. Make sure that you are consistent in naming.
Notes about the query: 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.
Query type: General (Overview of some aspect of the database.)
Query license: MIT License
Fixing suggestion: In case of base table names prefer the singular form.
Data source: INFORMATION_SCHEMA+system catalog
SQL query: Click on query to copy it

SELECT nspname AS table_schema, relname AS table_name, 
CASE WHEN relkind='r' THEN 'BASE TABLE'
WHEN relkind='v' THEN 'VIEW'
WHEN relkind='m' THEN 'MATERIALIZED VIEW'
WHEN relkind='f' THEN 'FOREIGN TABLE'
WHEN relkind='p' THEN 'PARTITIONED TABLE'
END AS table_type,
CASE WHEN relname ~* '(d$|.+(d|[^t]t)e_.+)' AND  relname !~* '((^|_)id$|kood$|(^|_)oid$|(^|_)uuid$|hind$|seisund$|brand$|kavand$|kavand$|^d*d$|periood$|pind$|sisend$|laud$|kraad$)' THEN 'Perhaps plural' ELSE 'Perhaps singular' END AS comment_about_the_table_name
FROM pg_class INNER JOIN pg_namespace ON pg_class.relnamespace=pg_namespace.oid
WHERE relkind IN ('r','v','m','f','p')
AND nspname NOT IN (SELECT schema_name
FROM INFORMATION_SCHEMA.schemata
WHERE schema_name<>'public' AND
schema_owner='postgres' AND schema_name IS NOT NULL)
ORDER BY comment_about_the_table_name, table_type, table_schema, table_name;

Categories where the query belongs to

Category nameCategory description
InconsistenciesQueries of this catergory provide information about inconsistencies of solving the same problem in different places.
NamingQueries of this category provide information about the style of naming.

The list of all the queries