开发者

Optimal dot / GraphViz layout for graph DB schema

I'm using dot + GraphViz for the first time to help with planning out a graph DB schema.

As I add more nodes, the output is looking less than ideal. In particular, the languages and countries are looking rather confusing.

I've tried some basic rankings, but been unable to influence it much.

How I can get a clearer output?

The code:

digraph ReferenceGraph {
  nodesep = 2;
  edge [color=gray50, fontname=Calibri, fontsize=11]
  node [shape=record, fontname=Calibri, fontsize=11]

  root [label="Reference Node", color=darkgreen, fontcolor=darkgreen, fontname=Calibri, fontsize=11]

  sue [label="{{User}|{GivenName=Sue}|{FamilyName=Williams}|{Username=swilliams}|{EmailAddress=Sue.Williams@foo.com}|{BusinessPhone=02 1234 5678}|{MobilePhone=0414 123 456}|{PasswordSalt=fcd376dc}|{PasswordHash=a8635cfd2930ebc0cc78}|{PreviousPasswordSalt=gggf6dc}|{PreviousPasswordHash=wer435cfd2930ebc0cc78}|{RequirePasswordChangeOnNextLogin=true}|FailedLoginAttempts=0|LastLoginAttemptUtc=21 Jun 2011 16:43:01 UTC|{DateCreatedUtc=20 Jun 2011 15:43:07 UTC}}", color=blue, fontcolor=blue]
  sue -> root [label="ADMINISTERS"]

  clint [label="{{Client}|{UniqueId=100}|{GivenName=Clint}|{MiddleNames=ian bill}|{FamilyName=Wood}|{PreferredName=Woods}|{Gender=Male Female Unknown}|{PlaceOfBirthTown}|{PlaceOfBirthState}|{PlaceOfBirthCountry}|{Email=clint.wood@foo.com}|{LanguageComments}|{InterpreterRequired=true false}|{InterpreterComments}|{Religion=Buddhist}|{LegalOrders=order1}|{DateOfBirth=21 June 1979}|{DateOfBirthCertainty=Confirmed Unconfirmed Estimated}}", color=blue, fontcolor=blue]
  clint -> acme [label="CLIENT_BELONGS_TO"]
  clint -> english [label ="SPEAKS"]

  cat [label="Cat (Client)"]
  cat -> acme [label="CLIENT_BELONGS_TO"]
  cat -> english [label ="SPEAKS"]
  cat -> mandarin [label ="SPEAKS"]

  acme [label="{{Agency}|{UniqueId=100}|{Key=acme}|{Name=Acme Australia}}", color=blue, fontcolor=blue]
  root -> acme [label="HOSTS"]

  john [label="John (User)"]
  john -> acme [label="USER_BELONGS_TO"]

  jack [label="Jack (User)"]
  jack -> acme [label="USER_BELONGS_TO"]

  centreA [label="{{Centre}|{Name=CentreA}|{BusinessPhone=02 1234 5678}|{Fax=0414 123 456}|{Email=xyz@bcb.com}|{Status=Active}}", color=blue, fontcolor=blue]
  centreA -> acme [label="CENTRE_BELONGS_TO"]

  centreAStreetAddress [label="{{PhysicalAddress}|{Line 1=Level 1}|{Line 2=11 Sydney Road}|{TownSuburb=Sydney}|{State=NSW}|{Postcode=2000}|{Country=Australia}}", color=blue, fontcolor=blue]
  centreA -> centreAStreetAddress [label="HAS_STREET_ADDRESS"]

  centreAPostalAddress [label="PO Box 123 (PhysicalAddress)"]
  centreA -> centreAPostalAddress [label="HAS_POSTAL_ADDRESS"]

  clintCurrentAddress [label="{{CurrentAddress}|{Line 1=Level 1}|{Line 2=11 Sydney Road}|{TownSuburb=Sydney}|{State=NSW}|{Postcode=2000}|{Country=Australia}}", color=blue, fontcolor=blue]
  clint -> clintCurrentAddress [label="开发者_如何学JAVAHAS_STREET_ADDRESS"]

  referenceData [label="Reference Data"]
  root -> referenceData [label="HAS_REFERENCE_DATA"]

  languagesReferenceData [label="Languages"]
  referenceData -> languagesReferenceData [label="HAS_LANGUAGES"]

  english [label="{{Language}|{Name=English}}", color=blue, fontcolor=blue]
  languagesReferenceData -> english [label="HAS_LANGUAGE"]

  mandarin [label="Mandarin (Language)"]
  languagesReferenceData -> mandarin [label="HAS_LANGUAGE"]

  japanese [label="Japanese (Language)"]
  languagesReferenceData -> japanese [label="HAS_LANGUAGE"]

  countriesReferenceData [label="Countries"]
  referenceData -> countriesReferenceData [label="HAS_COUNTRIES"]

  australia [label="{{Country}|{Name=Australia}}", color=blue, fontcolor=blue]
  countriesReferenceData -> australia [label="HAS_COUNTRY"]

  china [label="China (Country)"]
  countriesReferenceData -> china[label="HAS_COUNTRY"]
}


You may try to add

splines=true;
overlap=prism;

instead of nodesep=2; and render the graph with neato instead of dot. This will result in a more compact layout Labels do overlap with some nodes though, and the record-based nodes are awfully close to each other.

Be aware though that you may never obtain a perfect db schema by using graphviz - there will almost always be some crossing edges which could be layed out in a better way. A manually layed out db schema will beat the graphviz output.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜