I am handing over a Redshift database with plenty of views. I want to visualize their dependencies.
I made the select below, receiving ~500 rows with first two columns showing names of two related entities.
SELECT
dependent_view.relname as dependent_entity_name
, source_table.relname as entity_name
, source_table.relkind as entity_type
, count(distinct pg_attribute.attname) as joined_column_count
FROM pg_depend
JOIN pg_rewrite ON pg_depend.objid = pg_rewrite.oid
JOIN pg_class as dependent_view ON pg_rewrite.ev_class = dependent_view.oid
JOIN pg_class as source_table ON pg_depend.refobjid = source_table.oid
JOIN pg_attribute ON pg_depend.refobjid = pg_attribute.attrelid
AND pg_depend.refobjsubid = pg_attribute.attnum
JOIN pg_namespace dependent_ns ON dependent_ns.oid = dependent_view.relnamespace
JOIN pg_namespace source_ns ON source_ns.oid = source_table.relnamespace
WHERE
source_ns.nspname = 'public'
AND pg_attribute.attnum > 0
GROUP BY 1,2,3
ORDER BY 1,2;
I want
- Diagram with
- 1 node per unique entity name
- 1 line connecting two related nodes per row.
- To work with the result in Draw.io or similar
I don't want
- Draw it manually
I tried
- Using Smartdraw - Draws entities without connections
- Using VisualParadigm - Crashes
- ModelXtractor - permission denied to pg_class_info
Is there any way to achieve this? An existing software tool or a script?