Goal Find names of domains that contain the name of the table that column the domain specifies. Domains are reusable artifacts that one should be able to use in case of different base tables. Thus, it is inappropriate to use the name of a particular table in the name of the domain.
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 Rename the domain and make the name more general.
Data Source INFORMATION_SCHEMA only
SQL Query
SELECT c.table_schema, c.table_name, c.column_name,  c.data_type, c.domain_schema, c.domain_name
FROM information_schema.columns AS c 
WHERE (c.table_schema, c.table_name) IN (SELECT table_schema, table_name
FROM INFORMATION_SCHEMA.tables WHERE table_type='BASE TABLE') 
AND c.table_schema NOT IN (SELECT schema_name
FROM INFORMATION_SCHEMA.schemata
WHERE schema_name<>'public' AND
schema_owner='postgres' AND schema_name IS NOT NULL) 
AND c.table_name ILIKE '%' || c.domain_name || '%'
ORDER BY c.table_schema, c.table_name, c.ordinal_position;

Collections

This query belongs to the following collections:

NameDescription
Find problems automaticallyQueries, 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:

NameDescription
DomainsQueries of this category provide information about reusable specifications of column properties.
NamingQueries of this category provide information about the style of naming.

Further reading and related materials:

Reference
The corresponding code smell in case of cleaning code is "N2: Choose Names at the Appropriate Level of Abstraction". (Robert C. Martin, Clean Code)