Show related/linked Tables

Let’s say I have Table A, which has relationships to several other tables (X, Y, and Z) through foreign keys.

Is there a feature in the diagram that allows me to add Table A and then automatically display all related tables (X, Y, and Z) with a single click?

Hi @zonny,

I understand your use case like this:

  • When you click Table A on the diagram, its relationships to X, Y, and Z are highlighted.

Please see my attached video for more information.

If that’s not the case, can you explain the details clearer?

Thanks!

1 Like

I got your point: the line in the SQL diagram, when you click “Add Related Tables,” and based on the key relation, it loads all tables in the diagram.
As I know, it is not available here. But I think it would require extra coding to use this feature, and as I used ERwin, Lucid, etc., no one has these types of features. As far as SQL Server Diagram, that is not an ER model; it is physically relationship among tables that is converted into a diagram to display.
Let us know your comments on this.
Thanks,

2 Likes

@huyleminh This is what I meant.

Thank you @Ashish_Bajpai for explaining it better than me

1 Like

Thanks, @zonny and @Ashish_Bajpai, for the SQL Server example.

Let me check if I’ve got the use case right: you have a large set of tables, and you want to focus on one table and everything it’s related to.

In dbdiagram, that could work with the diagram view feature like this:

  1. Click a table on the diagram.
  2. Choose “Add to new view with all relations.”
  3. A new diagram view is created with that table and all the tables linked to it.

Would that cover what you need?

@huyleminh,

To put it simply, @zonny wants the code to be uncommented automatically when a table is clicked. For example, suppose the Order table is connected to Order_Detail and Customers, Order_Detail is connected to Products, and Products is connected to Categories, with all the code currently commented out.

Because of this, nothing is displayed on the “DBML Preview” canvas. If you uncomment one table—let’s say Categories—and right-click on the canvas to “Add Related Tables,” the code for the Products table should automatically be uncommented (assuming @zonny only wants level-1 relations). Similarly, if you do this for the Order table, the Order_Detail and Customers tables should be uncommented since they are directly connected to it.

If @zonny is looking for more than level 1, that means almost all tables would end up being uncommented.

The reason I mentioned that this might be unnecessary extra code is because DBML is text-based, not canvas-based. We write text to render tables, so adding logic just to comment and uncomment code might not be ideal. Just my thoughts!

@zonny, could you shed a bit more light on this?


And we have " DiagramView" on the Pro feature (sorry, as a free user never used, how will it work, but seeing in help file) that simply rectifies this issue.

This is what I am after.

When I create a new Diagram View and display a Table in the Diagram View, I need an option on the Table to add all related Tables without choosing them one by one.

So in the example above, I create a Diagram View and display Order table in the Diagram View. Then I click on the Order table and choose “Add Related Tables”, it will display Order_Detail and Customers tables. Just the level-1 relations for that Order table.

2 Likes

@huyleminh might be able to answer this better, but adding this feature could make the tool lose its lightweight nature.

1 Like

@zonny , @huyleminh
On second thought, I was thinking that importing DBML files could work here. We could create level-1 relationships in file 1, import that into a level-2 relationship file for reuse, and so on. Then, in the final file, we could create views based on the relationship levels (or file levels).

I think this approach might resolve the issue. @huyleminh will it work?

Thanks for pushing on this, @zonny and @Ashish_Bajpai. You described the feature well, and it is on our roadmap.

The direction we are building: a filter that selects a table plus its related tables, available in both the UI and DBML.

Proposal syntax

  • order_items : just that table
  • +order_items : the table and everything upstream
  • order_items+ : the table and everything downstream
  • +order_items+ : the table and everything related, both directions, all levels
  • 1+order_items+1 : one level each way
  • 3+order_items+1 : 3 levels upstream, 1 level downstream

@zonny’s case (add Order, get Order_Detail and Customers) is 1+orders+1.

Below is a mockup of our idea:
filter-related-tables

The filter syntax is what you save into a diagram view as code, so a view stays reproducible instead of hand-curated.

No ship date to share yet. I will post here when it is in beta.

2 Likes
* `order_items` : just that table
* `+order_items` : the table and everything upstream
* `order_items+` : the table and everything downstream
* `+order_items+` : the table and everything related, both directions, all levels
* `1+order_items+1` : one level each way
* `3+order_items+1` : 3 levels upstream, 1 level downstream

This will be a good idea. Wow. Totally agree.
:+1:

Yes, thank you so much @Ashish_Bajpai @huyleminh @Thi_Nguyen