| Goal | Find CHECK constraints that have been defined in a supertable (parent table) but not in its subtables. An entity that belongs to a subtype should also belong to its supertype. If a subtype entity satisfies some constraint, then logically it must also satisfy the constraints of the supertype as well. If CHECK constraints are not inherited, then this is not guaranteed. If you implement subtyping not merely reuse implementation in the subtables, then the subtables must have at least the same CHECK constraints as the supertable. CHECK(false) on a supertable is an appropriate CHECK constraint if one wants to prevent registering data directly to the supertable, i.e., data can only be added to the subtables. |
|---|---|
| Notes | The query finds also check constraints where the cardinality is zero, i.e., it does not involve any columns (for instance: CHECK(false)). |
| Type | General (Overview of some aspect of the database.) |
| License | MIT (opens in new tab) |
| Fixing Suggestion | Define the supertable CHECK constraint as inherited. |
| Data Source | system catalog only |
| SQL Query |
|
Collections
This query belongs to the following collections:
Find problems by overview
Queries that results point to different aspects of database that might have problems. A human reviewer has to decide based on the results as to whether there are problems or not .
| Name | Description |
|---|---|
| Find problems by overview | Queries that results point to different aspects of database that might have problems. A human reviewer has to decide based on the results as to whether there are problems or not . |
Categories
This query is classified under the following categories:
CHECK constraints
Queries of this category provide information about CHECK constraints.
Table inheritance
Queries of this category provide information about the inheritance between base tables.
| Name | Description |
|---|---|
| CHECK constraints | Queries of this category provide information about CHECK constraints. |
| Table inheritance | Queries of this category provide information about the inheritance between base tables. |
Further reading and related materials: