[英]Entity Relationship Diagram from Name Pairs, Redshft
I am handing over a Redshift database with plenty of views.我正在移交具有大量视图的 Redshift 数据库。 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,接收到 ~500 行,前两列显示两个相关实体的名称。
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我想
I don't want我不想
I tried我试过
Is there any way to achieve this?有什么办法可以做到这一点? An existing software tool or a script?
现有的软件工具或脚本?
There are certainly ways to generate that.当然有办法产生它。 However, the huge number of elements in the graph might make it unreadable and unusable.
但是,图表中的大量元素可能会使其不可读且无法使用。
My first try would be plantuml .我的第一个尝试是plantuml 。 The format is straightforward, and if it would fail, you'd fail fast.
格式很简单,如果它失败了,你很快就会失败。
In a more general way this is a classical graph vizualization problem, with nodes and edges.在更一般的方式中,这是一个经典的图形可视化问题,具有节点和边缘。 So you could as well use a more specialized graph visualisation algorithm for example using force-directed layout , which self-organizes the nodes, and quickly identifies the "hubs" that are at the center of many related groups.
因此,您也可以使用更专业的图形可视化算法,例如使用力导向布局,它可以自组织节点,并快速识别位于许多相关组中心的“中心”。 The advantage is that these algorithms are designed to present much more complex graphs than a couple of hundreds relations.
优点是这些算法旨在呈现比几百个关系复杂得多的图形。
If you do not want to dig into the complexity of a Fruchterman-Reingold algorithm or similar alternatives, you could go for some libraries (you now have some search terms) or even open-source tools such as Gephi .如果您不想深入研究 Fruchterman-Reingold 算法或类似替代方案的复杂性,您可以 go 一些库(您现在有一些搜索词)或什至Gephi等开源工具。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.