Filter Queries

Found 1056 queries.

  • All the queries about database objects contain a subcondition to exclude from the result information about the system catalog.
  • Although the statements use SQL constructs (common table expressions; NOT in subqueries) that could cause performance problems in case of large datasets, it shouldn't be a problem in case of the relatively small amount of data in the system catalog of a database.

#341. Derived table names have prefix or suffix

system catalog base tables only

This query identifies views and materialized views that include a prefix or suffix in their names (such as v_ or _mv). In a well-designed database, derived tables should follow the exact same naming conventions as base tables, because they function identically from the application's perspective. Therefore, if base tables do not use type-based prefixes or suffixes, derived tables should not use them either.

Problem detection License: MIT (opens in new tab)

#342. Derived table on top of another derived table

INFORMATION_SCHEMA+system catalog base tables

Do not build multiple levels of derived tables (views and materialized views) because it will hamper evolvability and understandability of the tables.

Problem detection License: MIT (opens in new tab)

#343. Derived table presents the same data in the same way as a single base table

INFORMATION_SCHEMA+system catalog base tables

Find derived tables (views and materialized views) that present data from one base table without adding columns, renaming columns, changing the order of columns, removing columns, or restricting rows. Perhaps something is missing from the subquery of the derived table.

Problem detection License: MIT (opens in new tab)

#344. Derived tables with embedded row locking

INFORMATION_SCHEMA+system catalog base tables

This query identifies derived tables (views and materialized views) whose defining subqueries utilize explicit row locking clauses (e.g., FOR UPDATE, FOR SHARE). Embedding locking semantics within a view definition is considered an architectural anti-pattern. It couples data projection with transaction control, causing simple read operations against the view to unexpectedly acquire locks. This behavior degrades concurrency by blocking other readers and violates the principle that reading a data element should not implicitly block simultaneous access.

Problem detection License: MIT (opens in new tab)

#345. Derived table uses a function to get data from another table

INFORMATION_SCHEMA+system catalog base tables

Find views that use a function to get data from another table.

Problem detection License: MIT (opens in new tab)

#346. Deterministic (immutable) functions that do not have input parameters

INFORMATION_SCHEMA+system catalog base tables

Find deterministic functions that do not have any input parameters. Make sure that it is correct because in general a deterministic function must calculate a value based on input.

Problem detection License: MIT (opens in new tab)

#347. Deterministic (immutable) functions that do not return a value

INFORMATION_SCHEMA+system catalog base tables

Find deterministic (immutable) functions that do not return a value. This goes against the idea of deterministic functions.

Problem detection License: MIT (opens in new tab)

#348. Different foreign key column names in case of referencing the same candidate key

system catalog base tables only

Find the cases when the names of columns in different foreign keys that reference to the same candidate key are different. If different names reflect different roles, then it is legitimate. However, there could also be accidental differences that makes it more difficult to use the database.

Problem detection License: MIT (opens in new tab)

#349. Different prefixes of a candidate key column and a referencing foreign key column

system catalog base tables only

The naming must be consistent. Find foreign key constraints where the candidate key column and foreign key column names have different prefixes. Thus, for instance, one cannot use USING syntax for joining the tables.

Problem detection License: MIT (opens in new tab)

#350. Different suffixes of a candidate key column and a referencing foreign key column

system catalog base tables only

This query identifies naming inconsistencies in foreign key relationships by comparing the suffixes of foreign key columns against their referenced candidate key columns. It flags pairs where the suffixes diverge (e.g., referencing user_id via a column named user_code or user_ref). Such discrepancies prevent the use of the simplified ANSI SQL USING syntax for joins, forcing the use of explicit ON clauses. The goal is to enforce a standardized suffix convention (typically _id) across the schema to improve maintainability and query readability.

Problem detection License: MIT (opens in new tab)

#351. Different ways how to find default timestamp values

INFORMATION_SCHEMA only

Find all the default values of base table, view, and foreign table columns that are expressions invoking a function that returns a timestamp. Do it only if there are different expressions, i.e., there could be possible inconsistencies.

Problem detection License: MIT (opens in new tab)

#352. Disabled rules

system catalog base tables only

Identify disabled rules. These should be enabled or dropped, otherwise these are dead code.

Problem detection License: MIT (opens in new tab)

#353. Disabled system triggers (i.e., disabled enforcement of constraints)

system catalog base tables only

These triggers should be enabled because otherwise some important functionality regarding constraints like enforcing referential integrity does not work.

Problem detection License: MIT (opens in new tab)

#354. Disabled user triggers

system catalog base tables only

Identify disabled triggers. These should be enabled or dropped, otherwise these are dead code.

Problem detection License: MIT (opens in new tab)

#355. Domain based on another domain

INFORMATION_SCHEMA+system catalog base tables

Find domains that have been defined based on another domain. Do not specify domains based on existing domains. This would unnecessarily increase dependencies and complexity.

Problem detection License: MIT (opens in new tab)

#356. Domain CHECK constraint name contains table name

INFORMATION_SCHEMA only

This query identifies violations of modular design principles within user-defined domains. It detects CHECK constraints belonging to a domain where the constraint's name incorporates the identifier of a specific base table that utilizes that domain. Since domains are intended as reusable, abstract data types applicable across multiple entities, embedding a specific implementation context (like a table name) into the constraint's identifier creates semantic coupling. This makes the domain confusing to reuse in other contexts. Constraint identifiers should reflect the inherent logic of the domain (e.g., check_email_format), not the object to which it is applied.

Problem detection License: MIT (opens in new tab)

#357. Domain CHECK constraints with the same name

INFORMATION_SCHEMA only

Find domain check constraint names that are used more than once (within the same schema or in different schemas). Different things should have different names. However, here different constraints have the same name. Also make sure that this is not a sign of duplication of domains.

Problem detection License: MIT (opens in new tab)

#358. Domain declares the same default value for multiple independent foreign keys

INFORMATION_SCHEMA+system catalog base tables

Find domains that declare a default value and that are used in case of multiple foreign key constraints that point to different tables. Domains should be used in a manner that does not cause unnecessary coupling of concerns. For instance, let us assume that columns client_state_type_code of table Client (that is used to implement the relationship with table Client_state_type) and worker_state_type_code of table Worker (that is used to implement the relationship with table Worker_state_type) have been defined based on the same domain. It the domain has a default value, then it determines the initial state of both clients and workers. However, it must be possible to determine the initial state independently in case of clients and workers.

Problem detection License: MIT (opens in new tab)

#359. Domain name and type name are the same

INFORMATION_SCHEMA+system catalog base tables

Use different names to avoid confusion.

Problem detection License: MIT (opens in new tab)

#360. Domain name contains base table name

INFORMATION_SCHEMA only

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.

Problem detection License: MIT (opens in new tab)
# Name(activate to sort ascending) Goal(activate to sort ascending) Type(sorted ascending, activate to sort descending) Data source(activate to sort ascending) Last update(activate to sort ascending) License Actions
341 Derived table names have prefix or suffix This query identifies views and materialized views that include a prefix or suffix in their names (such as v_ or _mv). In a well-designed database, derived tables should follow the exact same naming conventions as base tables, because they function identically from the application's perspective. Therefore, if base tables do not use type-based prefixes or suffixes, derived tables should not use them either. Problem detection system catalog base tables only MIT (opens in new tab) View (opens in new tab)
342 Derived table on top of another derived table Do not build multiple levels of derived tables (views and materialized views) because it will hamper evolvability and understandability of the tables. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
343 Derived table presents the same data in the same way as a single base table Find derived tables (views and materialized views) that present data from one base table without adding columns, renaming columns, changing the order of columns, removing columns, or restricting rows. Perhaps something is missing from the subquery of the derived table. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
344 Derived tables with embedded row locking This query identifies derived tables (views and materialized views) whose defining subqueries utilize explicit row locking clauses (e.g., FOR UPDATE, FOR SHARE). Embedding locking semantics within a view definition is considered an architectural anti-pattern. It couples data projection with transaction control, causing simple read operations against the view to unexpectedly acquire locks. This behavior degrades concurrency by blocking other readers and violates the principle that reading a data element should not implicitly block simultaneous access. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
345 Derived table uses a function to get data from another table Find views that use a function to get data from another table. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
346 Deterministic (immutable) functions that do not have input parameters Find deterministic functions that do not have any input parameters. Make sure that it is correct because in general a deterministic function must calculate a value based on input. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
347 Deterministic (immutable) functions that do not return a value Find deterministic (immutable) functions that do not return a value. This goes against the idea of deterministic functions. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
348 Different foreign key column names in case of referencing the same candidate key Find the cases when the names of columns in different foreign keys that reference to the same candidate key are different. If different names reflect different roles, then it is legitimate. However, there could also be accidental differences that makes it more difficult to use the database. Problem detection system catalog base tables only MIT (opens in new tab) View (opens in new tab)
349 Different prefixes of a candidate key column and a referencing foreign key column The naming must be consistent. Find foreign key constraints where the candidate key column and foreign key column names have different prefixes. Thus, for instance, one cannot use USING syntax for joining the tables. Problem detection system catalog base tables only MIT (opens in new tab) View (opens in new tab)
350 Different suffixes of a candidate key column and a referencing foreign key column This query identifies naming inconsistencies in foreign key relationships by comparing the suffixes of foreign key columns against their referenced candidate key columns. It flags pairs where the suffixes diverge (e.g., referencing user_id via a column named user_code or user_ref). Such discrepancies prevent the use of the simplified ANSI SQL USING syntax for joins, forcing the use of explicit ON clauses. The goal is to enforce a standardized suffix convention (typically _id) across the schema to improve maintainability and query readability. Problem detection system catalog base tables only MIT (opens in new tab) View (opens in new tab)
351 Different ways how to find default timestamp values Find all the default values of base table, view, and foreign table columns that are expressions invoking a function that returns a timestamp. Do it only if there are different expressions, i.e., there could be possible inconsistencies. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
352 Disabled rules Identify disabled rules. These should be enabled or dropped, otherwise these are dead code. Problem detection system catalog base tables only MIT (opens in new tab) View (opens in new tab)
353 Disabled system triggers (i.e., disabled enforcement of constraints) These triggers should be enabled because otherwise some important functionality regarding constraints like enforcing referential integrity does not work. Problem detection system catalog base tables only MIT (opens in new tab) View (opens in new tab)
354 Disabled user triggers Identify disabled triggers. These should be enabled or dropped, otherwise these are dead code. Problem detection system catalog base tables only MIT (opens in new tab) View (opens in new tab)
355 Domain based on another domain Find domains that have been defined based on another domain. Do not specify domains based on existing domains. This would unnecessarily increase dependencies and complexity. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
356 Domain CHECK constraint name contains table name This query identifies violations of modular design principles within user-defined domains. It detects CHECK constraints belonging to a domain where the constraint's name incorporates the identifier of a specific base table that utilizes that domain. Since domains are intended as reusable, abstract data types applicable across multiple entities, embedding a specific implementation context (like a table name) into the constraint's identifier creates semantic coupling. This makes the domain confusing to reuse in other contexts. Constraint identifiers should reflect the inherent logic of the domain (e.g., check_email_format), not the object to which it is applied. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
357 Domain CHECK constraints with the same name Find domain check constraint names that are used more than once (within the same schema or in different schemas). Different things should have different names. However, here different constraints have the same name. Also make sure that this is not a sign of duplication of domains. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
358 Domain declares the same default value for multiple independent foreign keys Find domains that declare a default value and that are used in case of multiple foreign key constraints that point to different tables. Domains should be used in a manner that does not cause unnecessary coupling of concerns. For instance, let us assume that columns client_state_type_code of table Client (that is used to implement the relationship with table Client_state_type) and worker_state_type_code of table Worker (that is used to implement the relationship with table Worker_state_type) have been defined based on the same domain. It the domain has a default value, then it determines the initial state of both clients and workers. However, it must be possible to determine the initial state independently in case of clients and workers. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
359 Domain name and type name are the same Use different names to avoid confusion. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
360 Domain name contains base table name 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. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)