<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>code-diesel &#187; sql</title>
	<atom:link href="http://www.codediesel.com/tag/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codediesel.com</link>
	<description>/* PHP &#38; MySQL Journal */</description>
	<lastBuildDate>Thu, 02 Feb 2012 13:19:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Creating SQL schemas with Doctrine DBAL</title>
		<link>http://www.codediesel.com/mysql/creating-sql-schemas-with-doctrine-dbal/</link>
		<comments>http://www.codediesel.com/mysql/creating-sql-schemas-with-doctrine-dbal/#comments</comments>
		<pubDate>Mon, 20 Dec 2010 07:34:33 +0000</pubDate>
		<dc:creator>sameer</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[schemas]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.codediesel.com/?p=2773</guid>
		<description><![CDATA[A tedious task during web development is that of database schema creation. A schema containing a few tables comprising of a small set of rows is quick, while that containing dozens of tables and large numbers of columns is a tedious process. I usually resort to a small php script with some regular expression tossed [...]]]></description>
			<content:encoded><![CDATA[<p>A tedious task during web development is that of database schema creation. A schema containing a few tables comprising of a small set of rows is quick, while that containing dozens of tables and large numbers of columns is a tedious process. I usually resort to a small php script with some regular expression tossed in to automatically create a schema from a text file definition. But that is a little buggy as I&#8217;ve to manually add the indexes and other small things. Now that Doctrine has released a DBAL library, this will provide a nice ability to automatically create sql schemas.<br />
<span id="more-2773"></span></p>
<h4>Doctrine DBAL</h4>
<p><a target="_blank" href="http://www.doctrine-project.org/projects">Doctrine DBAL</a> (available as RC4 as of this writing) provides a wonderful abstraction layer to process all the needed database actions. DBAL is a lightweight layer built around a PDO-like API which offers features like database schema introspection, schema migration, database access and manipulation through an OO API. Note that DBAL API can be used independently of the Doctrine ORM API. So you can use the DBAL library even if you are unfamiliar with the ORM API.</p>
<h4>Creating a MySQL schema from DBAL </h4>
<p>In this post I&#8217;ve created a small example script using the DBAL API to generate a MySQL schema for a couple of tables. Note that the DBAL API uses <a target="_blank" href="http://php.net/manual/en/language.namespaces.php">php namespaces</a>, so you will need to be familiar with them to understand the code, which also means that you must be at least using PHP 5.3.0</p>

<div class="wp_codebox"><table><tr id="p27735"><td class="code" id="p2773code5"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> Doctrine\Common\ClassLoader<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/* Doctrine uses a class loader to autoload the required classes */</span>
<span style="color: #000000; font-weight: bold;">require</span> <span style="color: #0000ff;">'Doctrine/doctrine-dbal/Doctrine/Common/ClassLoader.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/* Lets first load the Doctrine DBAL lbrary */</span>
<span style="color: #000088;">$classLoader</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ClassLoader<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Doctrine'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'./Doctrine/doctrine-dbal/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$classLoader</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">register</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/* Provide DBAL with some initial database infor */</span>
<span style="color: #000088;">$config</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> \Doctrine\DBAL\Configuration<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$connectionParams</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'dbname'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'test'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'user'</span>      <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'root'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'password'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'host'</span>      <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'localhost'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'driver'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'pdo_mysql'</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/* Connect to the database */</span>
<span style="color: #000088;">$conn</span> <span style="color: #339933;">=</span> \Doctrine\DBAL\DriverManager<span style="color: #339933;">::</span><span style="color: #004000;">getConnection</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$connectionParams</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/* We will now generate a table definition, 
   but first lets get a Schema object .
*/</span>
<span style="color: #000088;">$schema</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> \Doctrine\DBAL\Schema\Schema<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/* Now use the Schema object to create a 'users' table */</span>
<span style="color: #000088;">$usersTable</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$schema</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createTable</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;users&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/* Add some columns to the table */</span>
<span style="color: #000088;">$usersTable</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addColumn</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;id&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;integer&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;unsigned&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$usersTable</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addColumn</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;first_name&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;string&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;length&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">64</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$usersTable</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addColumn</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;last_name&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;string&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;length&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">64</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$usersTable</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addColumn</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;email&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;string&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;length&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">256</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$usersTable</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addColumn</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;website&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;string&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;length&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">256</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/* Add a primary key */</span>
<span style="color: #000088;">$usersTable</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setPrimaryKey</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;id&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #009933; font-style: italic;">/* Create another table called 'login' and add some columns */</span>
<span style="color: #000088;">$loginTable</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$schema</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createTable</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;login&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$loginTable</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addColumn</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;id&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;integer&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;unsigned&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$loginTable</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addColumn</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;username&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;string&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;length&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">64</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$loginTable</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addColumn</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;password&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;string&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;length&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">64</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$loginTable</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addUniqueIndex</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;username&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$loginTable</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setPrimaryKey</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;id&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/* Assign a foreign key constraint to the table */</span>
<span style="color: #000088;">$loginTable</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addForeignKeyConstraint</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$usersTable</span><span style="color: #339933;">,</span> 
                        <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;id&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> 
                        <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;id&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> 
                        <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;onDelete&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;CASCADE&quot;</span><span style="color: #009900;">&#41;</span>
                        <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/* Set the Schema output platform, as we are using MySQL
   a Mysql schema will be generated. */</span>
<span style="color: #000088;">$platform</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$conn</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getDatabasePlatform</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/* The 'queries' variable will now hold the 
   an array of sql statements.
*/</span>
<span style="color: #000088;">$queries</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$schema</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">toSql</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$platform</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>This will generate the following MySQL statements.</p>

<div class="wp_codebox"><table><tr id="p27736"><td class="code" id="p2773code6"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> users
  <span style="color: #66cc66;">&#40;</span>
     id         INT <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
     first_name VARCHAR<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">64</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
     last_name  VARCHAR<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">64</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
     email      VARCHAR<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
     website    VARCHAR<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
     <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span><span style="color: #66cc66;">&#40;</span>id<span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#41;</span>
ENGINE <span style="color: #66cc66;">=</span> INNODB 
&nbsp;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> login
  <span style="color: #66cc66;">&#40;</span>
     id       INT <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
     username VARCHAR<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">64</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
     PASSWORD VARCHAR<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">64</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
     <span style="color: #993333; font-weight: bold;">UNIQUE</span> <span style="color: #993333; font-weight: bold;">INDEX</span> login_username_uniq <span style="color: #66cc66;">&#40;</span>username<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
     <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span><span style="color: #66cc66;">&#40;</span>id<span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#41;</span>
ENGINE <span style="color: #66cc66;">=</span> INNODB 
&nbsp;
<span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">TABLE</span> login <span style="color: #993333; font-weight: bold;">ADD</span> CONSTRAINT 
login_id_fk <span style="color: #993333; font-weight: bold;">FOREIGN</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">&#40;</span>id<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">REFERENCES</span> users<span style="color: #66cc66;">&#40;</span>
id<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #993333; font-weight: bold;">DELETE</span> CASCADE</pre></td></tr></table></div>

<h4>Migrating schemas to another platform</h4>
<p>Now that you have generated the script to create sql schemas, you can easily migrate the generated schemas to another platform using a couple of statements. For example we can migrate the above MySQL statements to Oracle using the following code.</p>

<div class="wp_codebox"><table><tr id="p27737"><td class="code" id="p2773code7"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">.</span>
<span style="color: #339933;">.</span>
<span style="color: #000088;">$myPlatform</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> \Doctrine\DBAL\Platforms\OraclePlatform<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$queries</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$schema</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">toSql</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$myPlatform</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">.</span></pre></td></tr></table></div>

<h4>Basic column types</h4>
<p>Below are the basic types that you can use in the &#8216;addColumn&#8217; method when creating tables.</p>

<div class="wp_codebox"><table><tr id="p27738"><td class="code" id="p2773code8"><pre class="text" style="font-family:monospace;">'bigint', 'boolean', 
'datetime', 'date', 'time', 
'decimal', 'integer', 'smallint',
'object', 'string', 'text'.</pre></td></tr></table></div>

<p>In the next few posts we will explore some more features of Doctrine DBAL.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codediesel.com/mysql/creating-sql-schemas-with-doctrine-dbal/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Browser based SQL schema designer</title>
		<link>http://www.codediesel.com/mysql/browser-based-sql-schema-designer/</link>
		<comments>http://www.codediesel.com/mysql/browser-based-sql-schema-designer/#comments</comments>
		<pubDate>Tue, 03 Feb 2009 11:11:29 +0000</pubDate>
		<dc:creator>sameer</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.codediesel.com/?p=253</guid>
		<description><![CDATA[WWW SQL Designer is a free database designer. It allows developers to create database schemas using a graphical interface. The designs can be further saved/loaded and exported to SQL scripts. The software supports a number of databases and languages. This tool allows you to draw and create E-R diagrams in your browser using Javascript without [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://code.google.com/p/wwwsqldesigner/">WWW SQL Designer</a> is a free database designer. It allows developers to create database schemas using a graphical interface. The designs can be further saved/loaded and exported to SQL scripts. The software supports a number of databases and languages.<br />
<span id="more-253"></span><br />
<a href="http://www.codediesel.com/wp-content/uploads/2009/02/image11.gif" target="_self"><img class="aligncenter size-full wp-image-267" style="border: 1px solid #c0c0c0;" title="image11" src="http://www.codediesel.com/wp-content/uploads/2009/02/image11.gif" alt="image11" width="973" height="533" /></a></p>
<p>This tool allows you to draw and create E-R diagrams in your browser using Javascript without the need for any external plugins like Flash, Java or Flex.</p>
<p>Many database features are supported, such as keys, foreign key constraints, comments and indexes. You can either save your design , print it or export as SQL script. It is possible to import schema from existing database. The application supports MySQL, Sqlite, PostgreSQL ,MSSql.</p>
<p>The application allows you to:<br />
1. Draw E-R designs<br />
2. Edit tables and rows<br />
3. Manage keys<br />
4. Create relations (FK constraints)<br />
5. Save &amp; Load designs<br />
6. Import DB schemas</p>
<p>The importing of MySQL databases can take some time, so make sure you set PHP timeout to more than 60 seconds to avoid errors. A sample WordPress 2.7 schema imported is shown below.</p>
<p><a href="http://www.codediesel.com/wp-content/uploads/2009/02/image21.gif" target="_self"><img class="aligncenter size-full wp-image-264" style="border: 1px solid #c0c0c0;" title="image21" src="http://www.codediesel.com/wp-content/uploads/2009/02/image21.gif" alt="image21" width="884" height="457" /></a></p>
<p><strong>Installation:</strong><br />
Installation is simple. Just download the code from <a href="http://code.google.com/p/wwwsqldesigner/downloads/list">here</a>, change your database settings in the &#8216;sqldesigner\backend\php-mysql\index.php&#8217; (if you are using PHP &amp; MySQL) file and you are ready.</p>
<p>A live demo of the application can be found <a href="http://ondras.zarovi.cz/sql/demo/?keyword=default">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codediesel.com/mysql/browser-based-sql-schema-designer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

