Filter Queries

Found 1077 queries.

Page 18 of 54
  • 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 tables with multiple DISTINCT's

INFORMATION_SCHEMA+system catalog base tables

Find derived tables (views and materialized views) that contain more than one DISTINCT invocation. Make sure that the query is correctly written, including that it does not have unwanted formation of a Cartesian product.

General License: MIT (opens in new tab)

#342. Derived tables with ranking

INFORMATION_SCHEMA+system catalog base tables

Find views and materialized views that use rank and dense_rank window functions.

General License: MIT (opens in new tab)

#343. Derived tables with sorting

INFORMATION_SCHEMA+system catalog base tables

Find derived tables where the rows are ordered, i.e., there is ORDER BY clause at the end of the view. Different users may want to see the rows in different order. Thus, the DBMS may have to do extra and unnecessary work by firstly sorting based on one set of rows and after that based on other set of rows. Use sorting if you know that all the users want the rows in the same order and cannot/will not change the order in the application.

General License: MIT (opens in new tab)

#344. Derived tables with string_agg

INFORMATION_SCHEMA+system catalog base tables

Find views and materialized views that use string_agg aggregate function.

General 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 search paths of SECURITY DEFINER functions

INFORMATION_SCHEMA+system catalog base tables

Find the different search paths used in case of SECURITY DEFINER functions and the number of their occurrences. Make sure that these have been specified correctly and consistently and that they do not refer to any non-existent schemas.

General License: MIT (opens in new tab)

#349. Distinct functional tasks implemented by triggers

INFORMATION_SCHEMA+system catalog base tables

This query identifies and categorizes the distinct functional tasks implemented via triggers across the database schema. Rather than simply listing individual trigger instances, it aggregates triggers on the same or multiple tables that execute identical logic or share the same underlying routine (for example, maintaining audit timestamps or logging change history) into a single functional responsibility. This high-level inventory provides developers and database architects with a clear overview of the responsibilities delegated to the database tier, helping identify opportunities for code consolidation and standardization.

General License: MIT (opens in new tab)

#350. 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)

#351. Domain candidates

INFORMATION_SCHEMA+system catalog base tables

Find column descriptions that are candidates for describing a domain.

General License: MIT (opens in new tab)

#352. 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)

#353. 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)

#354. Do not assume you must use files (based on user data)

INFORMATION_SCHEMA+system catalog base tables

Find cases where you store images and other media as files outside the database and store in the database only paths to the files.

Problem detection License: MIT (opens in new tab)

#355. Do not create user-defined routines that have the same name as some installed extension routine

INFORMATION_SCHEMA+system catalog base tables

Avoid creating user-defined routines that have the same name as some extension routine because it may cause confusion.

Problem detection License: MIT (opens in new tab)

#356. Do not format comma-separated lists (based on user data)

INFORMATION_SCHEMA+system catalog base tables

Find, based on the data that users have recoreded in a database, cases where a multi-valued attribute in a conceptual data model is implemented as a textual column of a base table. Expected values in the column are strings that contain attribute values, separated by commas or other separation characters.

Problem detection License: MIT (opens in new tab)

#357. Do not leave out referential constraints (based on composite keys)

INFORMATION_SCHEMA+system catalog base tables

Try to find missing foreign key constraints. Find columns of base tables that are not covered by any foreign key constraint but belong to a composite key, do not have an associated sequence generator, and have a name that refers to the possibility that these are used to record some kind of codes or id's. Moreover, there must be at least one other base table that has a column with the same name. Such strategy would find missing constraints in tables that implement many-to-many relationship types but which that are not complete "islands" in terms of missing foreign key constraints.

Problem detection License: MIT (opens in new tab)

#358. Do not leave out the referential constraints (based on adjacency list design)

INFORMATION_SCHEMA+system catalog base tables

Try to find missing foreign key constraints. Find non-key and non-foreign key columns of base tables that do not have an associated sequence generator, and that name refers to the possibility that the column holds parent identifiers.

Problem detection License: MIT (opens in new tab)

#359. Do not leave out the referential constraints (based on classifiers)

INFORMATION_SCHEMA+system catalog base tables

This query identifies short text columns in base tables that are not part of any primary or foreign key, but whose names closely match an existing table in the database. This pattern suggests that the similarly named table might be a classifier (reference) table, and the flagged column should ideally have a foreign key constraint referencing it.

Problem detection License: MIT (opens in new tab)

#360. Do not leave out the referential constraints (based on column names)

INFORMATION_SCHEMA+system catalog base tables

This query identifies potentially missing foreign key constraints by analyzing base table columns whose names suggest they store reference codes or identifiers (IDs). It specifically flags columns that do not participate in any primary key, unique constraint, unique index, or foreign key constraint, and are not associated with a sequence generator (which would typically indicate a local surrogate key). Detecting these unconstrained reference columns helps prevent orphaned records and ensures relational data integrity across the schema.

Problem detection License: MIT (opens in new tab)
# Name(activate to sort ascending) Goal(activate to sort ascending) Type(activate to sort ascending) Data source(sorted ascending, activate to sort descending) Last update(activate to sort ascending) License Actions
341 Derived tables with multiple DISTINCT's Find derived tables (views and materialized views) that contain more than one DISTINCT invocation. Make sure that the query is correctly written, including that it does not have unwanted formation of a Cartesian product. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
342 Derived tables with ranking Find views and materialized views that use rank and dense_rank window functions. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
343 Derived tables with sorting Find derived tables where the rows are ordered, i.e., there is ORDER BY clause at the end of the view. Different users may want to see the rows in different order. Thus, the DBMS may have to do extra and unnecessary work by firstly sorting based on one set of rows and after that based on other set of rows. Use sorting if you know that all the users want the rows in the same order and cannot/will not change the order in the application. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
344 Derived tables with string_agg Find views and materialized views that use string_agg aggregate function. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
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
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
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
348 Different search paths of SECURITY DEFINER functions Find the different search paths used in case of SECURITY DEFINER functions and the number of their occurrences. Make sure that these have been specified correctly and consistently and that they do not refer to any non-existent schemas. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
349 Distinct functional tasks implemented by triggers This query identifies and categorizes the distinct functional tasks implemented via triggers across the database schema. Rather than simply listing individual trigger instances, it aggregates triggers on the same or multiple tables that execute identical logic or share the same underlying routine (for example, maintaining audit timestamps or logging change history) into a single functional responsibility. This high-level inventory provides developers and database architects with a clear overview of the responsibilities delegated to the database tier, helping identify opportunities for code consolidation and standardization. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
350 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
351 Domain candidates Find column descriptions that are candidates for describing a domain. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
352 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
353 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
354 Do not assume you must use files (based on user data) Find cases where you store images and other media as files outside the database and store in the database only paths to the files. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
355 Do not create user-defined routines that have the same name as some installed extension routine Avoid creating user-defined routines that have the same name as some extension routine because it may cause confusion. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
356 Do not format comma-separated lists (based on user data) Find, based on the data that users have recoreded in a database, cases where a multi-valued attribute in a conceptual data model is implemented as a textual column of a base table. Expected values in the column are strings that contain attribute values, separated by commas or other separation characters. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
357 Do not leave out referential constraints (based on composite keys) Try to find missing foreign key constraints. Find columns of base tables that are not covered by any foreign key constraint but belong to a composite key, do not have an associated sequence generator, and have a name that refers to the possibility that these are used to record some kind of codes or id's. Moreover, there must be at least one other base table that has a column with the same name. Such strategy would find missing constraints in tables that implement many-to-many relationship types but which that are not complete "islands" in terms of missing foreign key constraints. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
358 Do not leave out the referential constraints (based on adjacency list design) Try to find missing foreign key constraints. Find non-key and non-foreign key columns of base tables that do not have an associated sequence generator, and that name refers to the possibility that the column holds parent identifiers. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
359 Do not leave out the referential constraints (based on classifiers) This query identifies short text columns in base tables that are not part of any primary or foreign key, but whose names closely match an existing table in the database. This pattern suggests that the similarly named table might be a classifier (reference) table, and the flagged column should ideally have a foreign key constraint referencing it. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View
360 Do not leave out the referential constraints (based on column names) This query identifies potentially missing foreign key constraints by analyzing base table columns whose names suggest they store reference codes or identifiers (IDs). It specifically flags columns that do not participate in any primary key, unique constraint, unique index, or foreign key constraint, and are not associated with a sequence generator (which would typically indicate a local surrogate key). Detecting these unconstrained reference columns helps prevent orphaned records and ensures relational data integrity across the schema. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View