<?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>Mokka mit Schlag &#187; Databases</title>
	<atom:link href="http://www.elharo.com/blog/category/software-development/databases/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.elharo.com/blog</link>
	<description>Ranting and Raving</description>
	<lastBuildDate>Wed, 01 Feb 2012 13:01:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Seeking an Agile Database Definition Language</title>
		<link>http://www.elharo.com/blog/software-development/databases/2007/06/14/seeking-an-agile-database-definition-language/</link>
		<comments>http://www.elharo.com/blog/software-development/databases/2007/06/14/seeking-an-agile-database-definition-language/#comments</comments>
		<pubDate>Thu, 14 Jun 2007 10:03:29 +0000</pubDate>
		<dc:creator>Elliotte Rusty Harold</dc:creator>
				<category><![CDATA[Databases]]></category>

		<guid isPermaLink="false">http://www.elharo.com/blog/software-development/2007/06/14/seeking-an-agile-database-definition-language/</guid>
		<description><![CDATA[The database schemas for my current project are getting hashed out, mostly in Visio. This is pretty but not very automatable. I&#8217;d like to see if we can follow a more agile, iterative approach to database development. In particular, I&#8217;d like to be able to check the database definition into source code control and build [...]]]></description>
			<content:encoded><![CDATA[<p>The database schemas for my current project are getting hashed out, mostly in Visio. This is pretty but not very automatable. I&#8217;d like to see if we can follow a more agile, iterative approach to database development. In particular, I&#8217;d like to be able to check the database definition into source code control and build the whole thing, including database tables and sample databases for testing out of Ant. Requirements include:</p>
<ol>
<li>Supports (at a minimum) MySQL and Derby</li>
<li>Can be read by Java and Python</li>
<li>Allows for inserting of data for unit testing; i.e. not just table definitions</li>
</ol>
<p>It also wouldn&#8217;t hurt if it could reverse engineer existing SQL databases.</p>
<p>I&#8217;m tempted to write my own, probably using XML, but surely someone has already done this? I haven&#8217;t found a lot though. What I&#8217;ve got so far are these, none of which really meet the requirements:<br />
<span id="more-1000687"></span></p>
<h2>Andromeda</h2>
<p><a href="http://www.andromeda-project.com/">Andromeda</a> uses YAML for the database definition language. The downside is that only a PHP parser is currently available. I&#8217;d have to write one for Java and/or Python. </p>
<h2>Python</h2>
<p>We have some database generation code written in Python. Maybe I should just use Jython to call this from Java? It still feels like a hack though. </p>
<h2>Raw SQL</h2>
<p>We could just write a big SQL script to set up the tables and load in the data. However JDBC can&#8217;t execute SQL scripts, only individual statements. (Perhaps this is fixed somewhere in some project?)</p>
<p>Surely this is an obvious enough idea that someone has already done it? Probably in XML? Any ideas? </p>
]]></content:encoded>
			<wfw:commentRss>http://www.elharo.com/blog/software-development/databases/2007/06/14/seeking-an-agile-database-definition-language/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Fundamentally Safe Database APIs</title>
		<link>http://www.elharo.com/blog/software-development/databases/2007/04/06/fundamentally-safe-database-apis/</link>
		<comments>http://www.elharo.com/blog/software-development/databases/2007/04/06/fundamentally-safe-database-apis/#comments</comments>
		<pubDate>Fri, 06 Apr 2007 15:13:28 +0000</pubDate>
		<dc:creator>Elliotte Rusty Harold</dc:creator>
				<category><![CDATA[Databases]]></category>

		<guid isPermaLink="false">http://www.elharo.com/blog/software-development/databases/2007/04/06/fundamentally-safe-database-apis/</guid>
		<description><![CDATA[Is anyone aware of work on fundamentally safe database APIs for server side programs that completely avoid the possibility of SQL injection? What I envision is a somewhat limited API that does not execute raw SQL statements or provide any facility to do so. Instead you&#8217;d set up something like this: Statement s = database.getSelectStatement(); [...]]]></description>
			<content:encoded><![CDATA[<p>Is anyone aware of work on fundamentally safe database APIs for server side programs that completely avoid the possibility of SQL injection? What I envision is a somewhat limited API that does not execute raw SQL statements or provide any facility to do so. Instead you&#8217;d set up something like this:</p>
<pre><code>Statement s = database.getSelectStatement();
s.setTable("customers");
s.addField("email");
s.addField("telephone");
s.addCondition(
  new EqualsCondition("id", "p17")
);
ResultSet r = s.execute();
</code></pre>
<p>The library would turn this into the usual SQL statement</p>
<p><code>SELECT email, telephone FROM customers WHERE id = "p17"</code></p>
<p>The library could verify the individual parts of the query before submitting it to the database. If you passed a string like <code>"id = \"p17\" OR true; DELETE * FROM customers; SELECT * FROM customers WHERE "</code> to <code>EqualsCondition()</code> it would throw an exception.<br />
<span id="more-1000529"></span></p>
<p>This API doesn&#8217;t have to be in Java or any particular language. Nor does it have to have the full power of SQL. Basic SELECTs would be sufficient. Safety is valued over power here.</p>
<p>Surely I&#8217;m not the first person to think of this? Are there any APIs of this nature? in any environment or language?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.elharo.com/blog/software-development/databases/2007/04/06/fundamentally-safe-database-apis/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Converting a Mini to a Server, Part 3: MySQL and PHP</title>
		<link>http://www.elharo.com/blog/software-development/databases/2006/03/07/converting-a-mini-to-a-server-part-3-mysql-and-php/</link>
		<comments>http://www.elharo.com/blog/software-development/databases/2006/03/07/converting-a-mini-to-a-server-part-3-mysql-and-php/#comments</comments>
		<pubDate>Tue, 07 Mar 2006 19:18:54 +0000</pubDate>
		<dc:creator>Elliotte Rusty Harold</dc:creator>
				<category><![CDATA[Databases]]></category>

		<guid isPermaLink="false">http://blog.elharo.com/blog/?p=170</guid>
		<description><![CDATA[To summarize what has gone before, I now have headless, network access to a Mac X86 Mini, and have successfully installed Apache 2.0.55. The next step is to install MySQL, PHP, and WordPress; then copy The Cafes and elharo.com from the old server to the Mini. First up, MySQL. This almost couldn&#8217;t be easier. MySQL [...]]]></description>
			<content:encoded><![CDATA[<p>To summarize what has gone before, I now have <a href="http://www.elharo.com/blog/mac/2006/03/07/converting-the-mini-to-a-server-preliminaries/">headless, network access to a Mac X86 Mini</a>, and have <a href="http://www.elharo.com/blog/software-development/web-development/2006/03/07/converting-a-mini-to-a-server-part-2-installing-apache/">successfully installed Apache 2.0.55</a>. The next step is to install MySQL, PHP, and WordPress; then copy The Cafes and elharo.com from the old server to the Mini.<br />
<span id="more-170"></span></p>
<p>First up, MySQL. This almost couldn&#8217;t be easier. MySQL AB publishes a precompiled binary for X86 Macs, and it&#8217;s installed using the usual Mac installer. This is about the easiest server side install I&#8217;ve ever had to do. The only thing that could be better would be to not include a separate install for the autolauncher. Oh, and it should probably ask you for a database root password while installing rather than letting it be set later. Let&#8217;s do that before I forget:</p>
<p><samp>mini:/usr/local/mysql elharo$ ./bin/mysqladmin -u root password mynewpassword<br />
mini:/usr/local/mysql elharo$ ./bin/mysql -u root -pmynewpassword<br />
Welcome to the MySQL monitor.  Commands end with ; or \g.<br />
Your MySQL connection id is 5 to server version: 5.0.18-standard</p>
<p>Type &#8216;help;&#8217; or &#8216;\h&#8217; for help. Type &#8216;\c&#8217; to clear the buffer.</p>
<p>mysql> DELETE FROM mysql.user WHERE User = &#8221;;<br />
Query OK, 2 rows affected (0.00 sec)</p>
<p>mysql> FLUSH PRIVILEGES;<br />
Query OK, 0 rows affected (0.00 sec)<br />
</samp></p>
<p>But honestly these are nickel-and-dime issues compared to what you have to go through with most server side software.</p>
<p>Next up is PHP. I&#8217;ll need to build this one from source. </p>
<p><samp>mini:~/Desktop/php-5.1.2 elharo$ ./configure &#8211;with-apxs2=/usr/httpd/bin/apxs &#8211;with-mysql=/usr/local/mysql &#8211;prefix=/opt/php5 &#8211;with-libxslt &#8211;with-tidy<br />
creating cache ./config.cache<br />
checking for Cygwin environment&#8230; no<br />
checking for mingw32 environment&#8230; no<br />
&#8230;<br />
creating main/internal_functions_cli.c<br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br />
| License:                                                           |<br />
| This software is subject to the PHP License, available in this     |<br />
| distribution in the file LICENSE.  By continuing this installation |<br />
| process, you are bound by the terms of this license agreement.     |<br />
| If you do not agree with the terms of this license, you must abort |<br />
| the installation process at this point.                            |<br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+</samp></p>
<p><samp>Thank you for using PHP.</samp></p>
<p>Now onto make:</p>
<p><samp>mini:~/Desktop/php-5.1.2 elharo$ make<br />
/bin/sh /Users/elharo/Desktop/php-5.1.2/libtool &#8211;silent &#8211;preserve-dup-deps &#8211;mode=compile gcc  -Iext/libxml/ -I/Users/elharo/Desktop/php-5.1.2/ext/libxml/ -DPHP_ATOM_INC -I/Users/elharo/Desktop/php-5.1.2/include -I/Users/elharo/Desktop/php-5.1.2/main -I/Users/elharo/Desktop/php-5.1.2 -I/usr/include/libxml2 -I/Users/elharo/Desktop/php-5.1.2/ext/date/lib -I/usr/local/mysql/include -I/usr/include/tidy -I/Users/elharo/Desktop/php-5.1.2/TSRM -I/Users/elharo/Desktop/php-5.1.2/Zend  -no-cpp-precomp  -I/usr/include -g -O2  -c /Users/elharo/Desktop/php-5.1.2/ext/libxml/libxml.c -o ext/libxml/libxml.lo<br />
/Users/elharo/Desktop/php-5.1.2/ext/libxml/libxml.c: In function &#8216;php_libxml_streams_IO_open_wrapper&#8217;:<br />
/Users/elharo/Desktop/php-5.1.2/ext/libxml/libxml.c:264: warning: pointer targets in passing argument 1 of &#8216;xmlParseURI&#8217; differ in signedness<br />
/Users/elharo/Desktop/php-5.1.2/ext/libxml/libxml.c:265: warning: pointer targets in passing argument 1 of &#8216;xmlStrncmp&#8217; differ in signedness<br />
/Users/elharo/Desktop/php-5.1.2/ext/libxml/libxml.c:265: warning: pointer targets in passing argument 2 of &#8216;xmlStrncmp&#8217; differ in signedness<br />
/Users/elharo/Desktop/php-5.1.2/ext/libxml/libxml.c: In function &#8216;_php_list_set_error_structure&#8217;:<br />
/Users/elharo/Desktop/php-5.1.2/ext/libxml/libxml.c:433: warning: pointer targets in passing argument 1 of &#8216;xmlStrdup&#8217; differ in signedness<br />
/Users/elharo/Desktop/php-5.1.2/ext/libxml/libxml.c:433: warning: pointer targets in assignment differ in signedness<br />
&#8230;<br />
/Users/elharo/Desktop/php-5.1.2/ext/tidy/tidy.c:1084: warning: pointer targets in initialization differ in signedness<br />
/Users/elharo/Desktop/php-5.1.2/ext/tidy/tidy.c: In function &#8216;zif_tidy_get_output&#8217;:<br />
/Users/elharo/Desktop/php-5.1.2/ext/tidy/tidy.c:1100: warning: pointer targets in initialization differ in signedness<br />
make: *** [ext/tidy/tidy.lo] Error 1<br />
</samp></p>
<p>Hmm, those libxml warnings are troublesome. I wonder if Tidy and/or libxsl assuming something they shouldn&#8217;t be about the signedness of a Mac? I don&#8217;t think I have to have libxsl or libtidy right now so let&#8217;s reconfigure and try again without them.</p>
<p><samp>mini:~/Desktop/php-5.1.2 elharo$ make clean<br />
find . -name \*.lo -o -name \*.o | xargs rm -f<br />
find . -name \*.la -o -name \*.a | xargs rm -f<br />
find . -name \*.so | xargs rm -f<br />
find . -name .libs -a -type d|xargs rm -rf<br />
rm -f libphp5.la sapi/cli/php libs/libphp5.bundle modules/* libs/*<br />
mini:~/Desktop/php-5.1.2 elharo$ ./configure &#8211;with-apxs2=/usr/httpd/bin/apxs &#8211;with-mysql=/usr/local/mysql &#8211;prefix=/opt/php5<br />
loading cache ./config.cache<br />
checking for Cygwin environment&#8230; (cached) no<br />
checking for mingw32 environment&#8230; (cached) no<br />
checking for egrep&#8230; (cached) grep -E<br />
checking for a sed that does not truncate output&#8230; (cached) /usr/bin/sed<br />
checking host system type&#8230; i686-apple-darwin8.5.3<br />
checking target system type&#8230; i686-apple-darwin8.5.3<br />
checking for gcc&#8230; (cached) gcc<br />
&#8230;<br />
Build complete.<br />
(It is safe to ignore warnings about tempnam and tmpnam).<br />
</samp></p>
<p>OK. That worked. I&#8217;ll have to remember that I don&#8217;t have libtidy or libxslt installed in this. Finally install:</p>
<p><samp>mini:~/Desktop/php-5.1.2 elharo$ sudo make install<br />
Password:<br />
Installing PHP SAPI module:       apache2handler<br />
/usr/httpd/build/instdso.sh SH_LIBTOOL=&#8217;/usr/httpd/build/libtool&#8217; libs/libphp5.so /usr/httpd/modules<br />
/usr/httpd/build/libtool &#8211;mode=install cp libs/libphp5.so /usr/httpd/modules/<br />
cp libs/libphp5.so /usr/httpd/modules/libphp5.so<br />
<em>Warning!  dlname not found in /usr/httpd/modules/libphp5.so.</em><br />
Assuming installing a .so rather than a libtool archive.<br />
&#8230;<br />
Wrote PEAR system config file at: /opt/php5/etc/pear.conf<br />
You may want to add: /opt/php5/lib/php to your php.ini include_path<br />
Installing PDO headers:          /opt/php5/include/php/ext/pdo/<br />
</samp></p>
<p>OK. Let&#8217;s load up a simple PHP page and see if PHP is working or if I need to restart Apache or some such. Nope. Doesn&#8217;t work. It&#8217;s just displaying the PHP file, not interpreting it. Let&#8217;s restart the server. OK. Now something&#8217;s changed. It isn&#8217;t showing anything at all instead of showing the PHP source code. At least that means it understands there&#8217;s something didfferent about a .phtml file. Let&#8217;s look in the error log and see what we see. <samp>[Tue Mar 07 13:46:33 2006] [notice] child pid 18205 exit signal Bus error (10)<br />
[Tue Mar 07 13:46:37 2006] [notice] child pid 18206 exit signal Bus error (10)<br />
[Tue Mar 07 13:46:51 2006] [notice] child pid 18207 exit signal Bus error (10)</samp></p>
<p>Could that be the problem? Let&#8217;s reload the <tt>.php</tt> page one more time and see if that adds an error. Yep, that&#8217;s it all right. Now the question becomes, why is that happening? Googling on the error message is sometimes productive. This <a href="http://lists.freebsd.org/pipermail/freebsd-ports/2005-February/021142.html">thread</a> may be relevant, but doesn&#8217;t seem to have a definite answer.  </p>
<p>OK. Figured it out. I hadn&#8217;t installed a <tt>php.ini</tt> in <tt>/usr/ocal/lib</tt>. You&#8217;d think that would have been installed by default but I guess not. But now it&#8217;s back to showing the PHP source code? Why?</p>
<p>OK. Figured that out. I had not yet added the line </p>
<p><code>AddType application/x-httpd-php .php .phtml</code></p>
<p>to <tt>httpd.conf</tt>. Again the installer should have done this, but it didn&#8217;t. Believe it or not, it took me longer than it should have to figure out the problem because of yet another variation of the <a href="http://cafe.elharo.com/java/the-nastiest-bug/">nastiest bug</a>. This time, I had <tt>httpd.conf</tt> files from two different web servers open in several different terminal windows, and I checked for the AddType line in what I thought was the new server but was in fact the old server.</p>
<p>In any case, I now seem to have a functioning Apache 2/MySQL 5/PHP 5 system compiled natively for the Mac Mini. The next step is to set up the virtual hosts, install WordPress in each one, and load the old data. This seems like as a good a time as any to update to the latest version of WordPress, and since I have it on good authority that 2.0.2 is coming out <em>very</em> soon, I think I&#8217;ll wait for that before moving ahead. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.elharo.com/blog/software-development/databases/2006/03/07/converting-a-mini-to-a-server-part-3-mysql-and-php/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>SQL Date Types and Ranges in No Year</title>
		<link>http://www.elharo.com/blog/software-development/databases/2005/11/21/sql-date-types-and-ranges-in-no-year/</link>
		<comments>http://www.elharo.com/blog/software-development/databases/2005/11/21/sql-date-types-and-ranges-in-no-year/#comments</comments>
		<pubDate>Tue, 22 Nov 2005 01:11:57 +0000</pubDate>
		<dc:creator>Elliotte Rusty Harold</dc:creator>
				<category><![CDATA[Databases]]></category>

		<guid isPermaLink="false">http://blog.elharo.com/blog/software-development/2005/11/21/sql-date-types-and-ranges-in-no-year/</guid>
		<description><![CDATA[in XML Schema there is a gMonthDay type which represents dates such as October 31; that is, Halloween but not in any particular year. How is this typically handled in SQL? The date type requires a year? Do I just have to define separate INT fields for month and day? A related question: how are [...]]]></description>
			<content:encoded><![CDATA[<p>in XML Schema there is a gMonthDay type which represents dates such as October 31; that is, Halloween but not in any particular year. How is this typically handled in SQL? The date type requires a year? Do I just have to define separate INT fields for month and day?</p>
<p>A related question: how are date ranges handled? e.g. the range from Halloween to Christmas (10-31 to 12-25)? Two columns for the start and two for the end? Or a start date followed by a number of days? Leap years make this tricky though.</p>
<p>And still a third question: ranges may extend for the entire year or a part thereof. Furthermore they may extend across the New Year&#8217;s boundary. e.g. their could be a range that goes from 11-3 to 3-15. How is that handled?</p>
<p>And finally, to really complicate matters the range may be discontiguous. That is, it could cover March 15 to May 15 and September 15 to October 15, but not the intervening dates. However, the potential discontiguity is limited. In my application, there are never more than two contiguous ranges within a year.  </p>
<p>I can hack this together, but surely I&#8217;m not the first person to need something like this. Has anyone seriously worked through a problem like this and published a detailed analysis of the different approaches for modelling this in SQL tables, and the advantages and disadvantages of each? References appreciated.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.elharo.com/blog/software-development/databases/2005/11/21/sql-date-types-and-ranges-in-no-year/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Union Types in SQL</title>
		<link>http://www.elharo.com/blog/software-development/databases/2005/11/21/union-types-in-sql/</link>
		<comments>http://www.elharo.com/blog/software-development/databases/2005/11/21/union-types-in-sql/#comments</comments>
		<pubDate>Tue, 22 Nov 2005 01:00:24 +0000</pubDate>
		<dc:creator>Elliotte Rusty Harold</dc:creator>
				<category><![CDATA[Databases]]></category>

		<guid isPermaLink="false">http://blog.elharo.com/blog/software-development/2005/11/21/union-types-in-sql/</guid>
		<description><![CDATA[XML schemas support a union type. For instance, you can say that an element must be an int or one of the strings &#8220;large&#8221;, &#8220;small&#8221;, or &#8220;huge&#8221;. Does SQL have any equivalent? That is, is it possible to type a field as containing either an int or one of an enumerated list of strings? Or [...]]]></description>
			<content:encoded><![CDATA[<p>XML schemas support a union type. For instance, you can say that an element must be an int or one of the strings &#8220;large&#8221;, &#8220;small&#8221;, or &#8220;huge&#8221;. Does SQL have any equivalent? That is, is it possible to type a field as containing either an int or one of an enumerated list of strings? Or do I just have to create two fields, one of which is null? How is this customarily handled in SQL?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.elharo.com/blog/software-development/databases/2005/11/21/union-types-in-sql/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

