As a new feature added to version 2, you can now export a database diagram metadata in a standard graph format, from either Model Xtractor or Data Xtractor. While on a model diagram, access the Objects – Export – Diagram as Graph menu command and select one of the supported graph formats. By default, diagrams are saved in a graphs submenu in your Xtractor user folder.

Export Graph Formats

As recommended by one of our users (thanks, Jan!), we looked at many graph formats, and just a few actually can contain data and styles for database diagrams with shapes and shape items. From the free diagram editors, we stopped only at yEd and Graphviz. Other apps like Gephi, Cytoscape, GUESS, Pajek, have been evaluated, but discarded. We also tried to avoid strict proprietary formats, but we adopted yEd’s extensions for lack of other proper standard options. Formats like GXL, GEXF, XGMML, GDF have been considered, but abandoned, because of their lack of important required options (most of them are just for network diagrams).

At the end, we added support for the following standard or adapted graph formats:

  1. Graphviz DOT – DOT is both the language and the main layout engine of the old Graphviz legacy application. DOT files can use the .gv and .dot extensions (we’ll rather use .gv, as .dot may conflict with Microsoft Word). They can be rendered with the command line Graphviz app, or by a copy and paste on the great related online app Viz-js.com.
  2. GraphML (Graph Markup Language) – XML-based standard language, with yEd/yWorks specific extensions. So this can be properly visualized only in the free yEd diagram app. Supported extensions are .graphml and .graphmlz, the second being used for zip-compressed files, also generated by our apps.
  3. GML (Graph Modeling Language) – JSON-based standard language, with yEd/yWorks specific extensions. So this can be also properly visualized only in the free yEd diagram app. Supported extensions are .gml and .xgml, the second being used for an equivalent XML-based content, also generated by our apps.
  4. TGF (Trivial Graph Format) – very simple text-only, but human readable format. A .tgf file has only a simple list of nodes, separated by # from another simple list of links between these nodes. The file can also be imported and visualized in yEd.

Exported Graph Elements

None of these formats support all Model Xtractor features, and many diagram details could be lost in the export process:

  • Exported data will contain just a static snapshot of most visible Xtractor diagram elements. Elements hidden by our dynamic features – like collapsed items – will not be exported. Graphs further imported by another diagramming applications are usually static. Model Xtractor is the only app with collapsible shapes, minified shapes and collapsible item categories. Many other apps with automatic layouts also do not allow interactively moving or resizing the shapes.
  • Main reason we export diagrams in a standard format is other diagram applications may offer better diagramming layout features. So the exact position of shapes and connector points are usually recalculated by the importing app. The shape size can be also slightly different and/or recalculated by the importing app. Graphviz will always render the diagram with its own automatic but static layout. And yEd has plenty of different layout and further configuration options you can choose from.
  • Elements like comments and shape stereotypes are not exported. Also, some styles and colors may be lost in the process. Shape title highlights and item highlights are not exported. Gradient colors, when exported and supported by the importing app, may be rendered in a different manner. Graphviz does not support all our connector head types, especially for the Crow’s Foot notation.
  • All files are exported in UTF-8 encoding, which will hopefully support most of the character codes. The diagram background color may be exported or not, it depends on the format. We never export the dot or math grid – these are app-specific features.
  • What we do export are most of our specific theme styles (colors, text rendering options, other theme switches), and the three different notations for the connector head styles: (a) the default MX notation, (b) the standard Crow’s Foot notation, (c) and ERwin’s standard IDEF1X notation.

Export in Graphviz DOT Format

We’ll now use one simple database diagram, with slightly different options for each graph export. The data model displays most tables from the Chinook sample database, installed already for SQLite and SQL CE by any of our applications.

graph-Default

Use Objects – Export – Diagram as Graph menu command and export it into a .gv Graphviz DOT file. Open the file into a text editor like Notepad, copy all the text and then paste it over the data from Viz-js.com. I see an online diagram rendered this way:

graph-Default-DOT-2

Following portion of pseudo-code, in the DOT language, is to render just two shapes and the link between (the label attributes should be filled-in with actual HTML content):

digraph G {
  graph [ rankdir="LR" bgcolor="#ffffff" ]
  node [ style="filled" shape="Mrecord" gradientangle=180 ]
  edge [ arrowhead="none" arrowtail="none" dir="both" ]

  n61 [ fillcolor="#d3dcef:#f5f5f5" color="#716f64" penwidth="1" label=... ]
  n72 [ fillcolor="#ddd6ef:#f5f5f5" color="#716f64" penwidth="1" label=... ]
  n61 -> n72 [ penwidth=1 color="#696969" arrowtail="crow" ]
}

Export in GraphML Format

Duplicate the previous Model Xtractor diagram and change the Default theme to All Teal. This is kind of a rich and heavy theme, with uniform shape gradients in green. Switch also the data model notation, from the default MX notation to IDEF1X:

graph-IDEF1X

Use Objects – Export – Diagram as Graph menu command and export it into a .graphml Graph Markup Language file. As an alternative, saving as .graphmlz is also possible and it will compress the content in ZIP format. Load the .graphml or .graphmlz file in the free standalone diagramming app yEd. The default automatic layout is still acceptable, but you can further improve it. For instance, the diagram below is rendered after a call to Layout – Edge Routing – Orthogonal Channel after import:

graph-IDEF1X-GraphML-Layout

A small portion of the exported XML, in pseudo-code, for one shape and one link:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" ...>
  ...
  <graph edgedefault="directed" id="G">
    <node id="n51">
      <data key="node">
        <y:GenericNode configuration="com.yworks.entityRelationship.big_entity">
          <y:Geometry x="220" y="10" width="119" height="112"/>
          <y:Fill color="#008080" color2="#ffffff" transparent="false"/>
          <y:BorderStyle color="#716f64" type="line" width="1"/>
          <y:NodeLabel ...>InvoiceLine</y:NodeLabel>
          <y:NodeLabel ...>...</y:NodeLabel>
        </y:GenericNode>
      </data>
    </node>
    <edge id="e103" source="n57" target="n61">
      <data key="edge">
        <y:PolyLineEdge>
          <y:LineStyle color="#696969" type="dashed" width="1.0"/>
          <y:Arrows source="circle" target="circle"/>
          <y:BendStyle smoothed="false"/>
        </y:PolyLineEdge>
      </data>
    </edge>
  </graph>
</graphml>

Export in GML/XGML Format

Duplicate the first Model Xtractor diagram and show as Simplified, show items with Data Types, show Category items, show shape stereotypes (as Object Types), then hide all Icons and Colors. The new shapes will get larger, so manually arrange them a bit:

graph-Simplified

Use the same Objects – Export – Diagram as Graph menu command and export it into a .gml Graph Modeling Language file. As an alternative, saving as .xgml is also possible and will render the content in equivalent XML, instead of JSON. Load the .gml or .xgml file in yEd. The default automatic layout is just acceptable, but you can further improve it. You may get overlapping shapes. Use a specific layout, or manually select and move the shapes around a bit:

graph-Simplified-GML

A small portion of the exported JSON for GML (the XML syntax for XGML would be just equivalent), in pseudo-code, for one shape and one link:

graph
[
	hierarchic	1
	directed	1
	node
	[
		id	1
		label	"..."
		graphics
		[
			x	41
			y	51
			w	24
			h	24
			customconfiguration	"com.yworks.entityRelationship.big_entity"
			fill	"#f5f5f5"
			fill2	"#dfdfdf"
			outline	"#000000"
		]
		LabelGraphics
		[
			text	""
			fill	"#dfdfdf"
			fontStyle	"bold"
			color	"#000000"
			fontSize	12
			fontName	"Dialog"
			configuration	"com.yworks.entityRelationship.label.name"
			anchor	"t"
		]
	]
	edge
	[
		source	78
		target	85
		graphics
		[
			width	1
			style	"line"
			fill	"#696969"
		]
	]
]

Export in TGF Format

Duplicate first Model Xtractor diagram and change the Default theme to Cassandra Navy Headless. This is a light theme, with navy blue text and no background colors, just shape shadows. Shape titles appear here outside their item’s rectangles, but this will not be rendered in any exported graph format. Switch also the data model notation, from the default MX notation to Crow’s Foot:

graph-Crow

This could be exported in any of the previous rich graph formats, and then rendered by Graphviz or yEd. However, we’ll use here the last very simple graph format, that saves only shape names and unidirectional links.

Use Objects – Export – Diagram as Graph menu command and export it into a .tgf Trivial Graph Format file. Load the file in yEd and use two commands to properly display data: (a) call Layout – Hierarchical to spread the initially overlapped shapes, followed by (b) Tools – Fit Node to Labels, to fit text within the shapes.:

graph-Crow-TGF

The full content of the exported .tgf file is as it follows:

n1 
n5 Artist
n8 Customer
n22 Employee
n38 Genre
n41 Invoice
n51 InvoiceLine
n57 Playlist
n61 Track
n72 MediaType
#
n1 n5
n8 n22
n22 n22
n41 n8
n51 n41
n51 n61
n61 n1
n61 n38
n61 n72
n57 n61