Goal Referential degree of a schema is defined as the number of foreign keys in the database schema.
Notes The query returns information about all the non-system schemas, even those that do not have foreign key constraints. In the latter case the number would be 0.
Type Sofware measure (Numeric values (software measures) about the database)
License MIT License
Data Source INFORMATION_SCHEMA only
SQL Query
SELECT s.schema_name AS schema, COUNT(tc.table_schema) AS number_of_foreign_keys 
FROM information_schema.schemata AS s LEFT JOIN 
(SELECT table_schema
FROM information_schema.table_constraints 
WHERE constraint_type = 'FOREIGN KEY') AS tc ON s.schema_name=tc.table_schema
WHERE schema_name NOT IN (SELECT schema_name
FROM INFORMATION_SCHEMA.schemata
WHERE schema_name<>'public' AND
schema_owner='postgres' AND schema_name IS NOT NULL)
GROUP BY s.schema_name
ORDER BY COUNT(tc.table_schema) DESC, s.schema_name;

Collections

This query belongs to the following collections:

NameDescription
Find problems about integrity constraintsA selection of queries that return information about the state of integrity constraints in the datadabase. Contains all the types of queries - problem detection, software measure, and general overview
Find problems by overviewQueries 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 .
Find quick numeric overview of the databaseQueries that return numeric values showing mostly the number of different types of database objects in the database
Categories

This query is classified under the following categories:

NameDescription
Relationships between tablesQueries of this category provide information about how database tables are connected to each other and whether such connections have been explicitly defined and whether it has been done correctly.

Further reading and related materials:

Reference
Piattini, M., Calero, C., Sahraoui, H. A., & Lounis, H. (2001). Object-relational database metrics. L'Objet, 7(4), 477-496.