Creating database diagrams with G2

No surprise here I guess, this is a variation on my ealier posting but now on the basis of database information rather than assembly (reflected) data.

DB diagrams with G2

Althoug it might look like a piece of cake to display this kind of information and it seems like a simple shift from the class shape discussed earlier, it was quite a challenge to dot it. Not so much the diagramming part but the data grid inside the shape was somewhat difficult. While there is a datagrid for WPF it would be a heavy load on the diagramming surface to include it in the shape containers. So, the only option was to create a home-made lightweight datagrid. In addition, it had to have an inline editing capability in the form of comboboxes, textboxes, checkboxes and more. Finally, I also wanted the whole shape to have different view states; totally collapsed, names only and the full datagrid view.

In the picture you can see a sample diagram with the various features;

  • the User & Countries tables are ‘full’, the Credential table is in a collapsed state and the Address table shows only the names of the fields. The upper-right icon allows you to cycle through the different views. This is not mendatory, however, as the icon simply launches a routed command which can be captured anywhere and you can call the ShowCollapsed(), ShowNamesOnly and ShowFull() methods on the original source to changes the view as you like.
  • the lines in bold in the grid show either the active record or the primary key(s)
  • double clicking allows one to edit the fields
  • the labels can contain in general the info you like and it’s a generic feature of G2 rather than part of the database related shape info.

Although I did not fully develop things, one can go the full nine yards and turn this sample into either a database visualizer or a database editor (or both) much like in SQL Server’s management studio. Using the integrated analysis service of G2 one could also traverse the diagram and create scripts or XML on top of it. Well, you got the point I guess.

4 Responses to Creating database diagrams with G2

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

top