Okay, here is the Mermaid graph syntax representing the dependency tree provided by your sp_helpview output.
graph TD
%% Define the root node (Level 0)
A0(vew_pbc_nsrd_sma_offering)
%% Define Level -1 dependencies
subgraph Level_Minus_1
A0 --> B1_func(fn_get_esg_scrns<br/><i>SQL Function</i>);
A0 --> B1_v1(eg_vew_bfal<br/><i>View</i>);
A0 --> B1_v2(eg_vew_bfcr<br/><i>View</i>);
A0 --> B1_v3(eg_vew_bfpt<br/><i>View</i>);
A0 --> B1_v4(eg_vew_bfun<br/><i>View</i>);
A0 --> B1_v5(eg_vew_btcd<br/><i>View</i>);
A0 --> B1_v6(eg_vew_prtf<br/><i>View</i>);
A0 --> B1_v7(vew_fund_detail<br/><i>View</i>);
A0 --> B1_v8(vew_fund_esg_attributes<br/><i>View</i>);
A0 --> B1_v9(vew_fund_esg_screens<br/><i>View</i>);
A0 --> B1_v10(vew_fund_isg_attributes<br/><i>View</i>);
A0 --> B1_v11(vew_esg_exp_data_src_scrn<br/><i>View</i>);
end
%% Define Level -2 dependencies
subgraph Level_Minus_2
%% Dependencies of fn_get_esg_scrns
B1_func --> C2_v1(vew_fund_esg_screens<br/><i>View</i>);
B1_func --> C2_v2(vew_esg_exp_data_src_scrn<br/><i>View</i>);
%% Dependencies of other Level -1 Views (linking directly to their base tables)
B1_v1 --> C2_t1(fund_alias<br/><i>Table</i>);
B1_v2 --> C2_t2(fund_curncy<br/><i>Table</i>);
B1_v3 --> C2_t3(fund_port_type<br/><i>Table</i>);
B1_v4 --> C2_t4(fund<br/><i>Table</i>);
B1_v5 --> C2_t5(trad_comm_dates<br/><i>Table</i>);
B1_v6 --> C2_t6(preq_toplevel_fund<br/><i>Table</i>);
B1_v7 --> C2_t7(fund_detail<br/><i>Table</i>);
B1_v8 --> C2_t8(fund_esg_attributes<br/><i>Table</i>);
B1_v10 --> C2_t9(fund_isg_attributes<br/><i>Table</i>);
end
%% Define Level -3 dependencies
subgraph Level_Minus_3
%% Dependencies of Level -2 Views
C2_v1 --> D3_t1(fund_esg_screens<br/><i>Table</i>);
C2_v2 --> D3_t2(esg_exp_data_src_scrn<br/><i>Table</i>);
end
%% Styling (Optional)
style A0 fill:#f9f,stroke:#333,stroke-width:2px
classDef view fill:#ccf,stroke:#333,stroke-width:1px;
classDef table fill:#cfc,stroke:#333,stroke-width:1px;
classDef func fill:#fcc,stroke:#333,stroke-width:1px;
class B1_v1,B1_v2,B1_v3,B1_v4,B1_v5,B1_v6,B1_v7,B1_v8,B1_v9,B1_v10,B1_v11,C2_v1,C2_v2 view;
class C2_t1,C2_t2,C2_t3,C2_t4,C2_t5,C2_t6,C2_t7,C2_t8,C2_t9,D3_t1,D3_t2 table;
class B1_func func;
Explanation of the Mermaid Code:
graph TD: This declares a graph that orients from Top Down.
A0(vew_pbc_nsrd_sma_offering): Defines the starting node (Level 0) with its name. The parentheses () create a standard rectangular node.
subgraph ... end: These blocks help visually group nodes by their dependency level, although Mermaid doesn't strictly enforce hierarchy within subgraphs in the same way the text output does. The links define the actual structure.
A0 --> B1_func(...): This is the core syntax. It creates a directional link (an arrow) from the parent node (A0) to the child node (B1_func).
- Node Labels
(Name<br/><i>Type</i>):
- We use the object name as the primary identifier for the node.
<br/><i>Type</i> adds the object type (Table, View, SQL Function) below the name, using HTML-like tags for formatting within the node label. This improves readability.
- IDs (
A0, B1_func, C2_v1, etc.): Unique identifiers are needed for each node to define the links. I've used a pattern like Level_Indicator_Type_Sequence (e.g., B1_func for Level -1 Function, C2_t1 for Level -2 Table).
- Styling (Optional):
style A0 fill:#f9f,stroke:#333,stroke-width:2px: Styles the root node specifically.
classDef ...: Defines reusable style classes for Views, Tables, and Functions.
class ... view;: Applies the 'view' style class to all nodes identified as views. Similarly for tables and functions. This helps visually distinguish the different object types in the graph.
You can paste this code into any Mermaid renderer (like the GitHub markdown preview, online Mermaid editors, or tools that support Mermaid) to see the visual graph.