P-dd is a PHP library for creating dynamic relational database documentation, in a number of forms, for an arbitrary database.

Friday, January 05, 2007

Simple ER Diagram Example

Being able to simply create an ER diagram is one of the main reasons I had for starting this project, and with that in mind I figure I should show just how simple it is to do so.

In order to run this you would need to have Graphviz's Neato installed on the web server... though once that's done, this is the sum total of the code you need to use the TestDatasource and produce a full ER diagram like that shown below:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<title>P-dd: A simple example outputting the default DOT generated diagram using the TestDatasource</title>

require_once( 'include_package.php' );

include_package( 'Datasources' );
include_package( 'DatabaseModel' );
include_package( 'Renderers', true );

$oFactory = new DatabaseFactory( new TestDatasource() );
$oDatabase = $oFactory->ConstructDatabase();

$oImageGenerator = new DotImageGenerator( DotDatabaseRenderer::Render( new DotRendererConfiguration(), $oDatabase ) );
$oImageGenerator->GenerateImageFile( 'Gif', 'ExampleImage.gif' );

echo( HtmlTag::Image( 'ExampleImage.gif', 'Dot generated diagram (using NEATO)') );



Technorati Tags: , , , , , , , , , , , , ,



  • At 6:31 PM, Blogger schoolmap said…


    A tool called LatticeFramework Studio can generate the ER diagram from Oracle, MySQL and SQL Server using GraphViz. It will generate the GraphViz dot file connected to your database, adn then generate the ER diagram using GraphViz dot.exe. LatticeFramework Studio also has a dot file editor to make it easier to edit the generated dot file.

    Here is sample ER diagram generated from Oracle HR schema:


    Here is the screencast how to use it:

  • At 4:38 AM, Blogger Macy Dalby said…

    Thanks this info was really helpful! I used a website called Lucidchart to find er diagram examples and it was really easy to understand. If you use diagrams often you should check it out!

  • At 7:13 AM, Blogger Karren Barlow said…

    Thanks! I have also found some great ER Diagram Examples using Lucidchart and their site is very helpful and easy to use! Give it a try!


Post a Comment

Links to this post:

Create a Link

<< Home