Query goal: | Find non-textual base table columns that name refers to the possibility that these are used to register national identification numbers (personal codes). The codes can contain additional symbols to numbers. |
Notes about the query: | The query considers both column names in English and Estonian. |
Query type: | Problem detection (Each row in the result could represent a flaw in the design) |
Query reliability: | Medium (Medium number of false-positive results) |
Query license: | MIT License |
Fixing suggestion: | Choose data types carefully. Be as precise as possible. The type of the column should be VARCHAR (or CHAR or TEXT - depending on circumstances). Change the data type of the column. |
Data source: | INFORMATION_SCHEMA only |
SQL query: | Click on query to copy it
SELECT c.table_schema, c.table_name, c.column_name, c.data_type 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.data_type NOT ILIKE '%char%' AND c.data_type<>'text' AND c.column_name~*'^(isik[u_ ]*kood|person[_ ]*code|personal[_ ]*code|(national|nat)[_ ]*identification[_ ]*(number|nr)|(national|nat)[_ ]*identity[_ ]*(number|nr)|(national|nat)[_ ]*insurance[_ ]*(number|nr))$' ORDER BY c.table_schema, c.table_name, c.column_name; |
Collection name | Collection description |
---|---|
Find problems automatically | Queries, 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 . |
Category name | Category description |
---|---|
Data types | Queries of this category provide information about the data types and their usage. |
Result quality depends on names | Queries of this category use names (for instance, column names) to try to guess the meaning of a database object. Thus, the goodness of names determines the number of false positive and false negative results. |
Validity and completeness | Queries of this category provide information about whether database design represents the world (domain) correctly (validity) and whether database design captures all the information about the world (domain) that is correct and relevant (completeness). |
Reference |
---|
https://en.wikipedia.org/wiki/National_identification_number |