Monday, May 08, 2006

Corel Linux Upgrade Woes

Over the weekend I tried to upgrade my Corel Linux system for PHP 4.0. Unfortunately I was unable to accomplish this because Corel Linux is so obsolete. All I managed to do was upgrade Apache from 1.3.3 to 1.3.35 and PHP from 3.0.5 to 3.0.16. I did document my Apache HTTP server configuration file, httpd.conf, in my notes and gained some experience but it was extremely frustrating. I ought to scrap my Corel Linux system but everything works and it took me a long time to get it that way. I have the Linux version of WordPerfect Office 2000 Deluxe installed on that system. It includes WordPerfect and Paradox 9.

My other Linux system is Mandrake 8.2 which is much better. Unfortunately it is installed on a removable hard drive for my best PC which means I have to swap out my Windows 2000 Professional hard drive for that one. So it requires a lot of hard drive swapping to work on Mandrake 8.2. If I had more disk space I could run Mandrake 8.2 as a virtual server.

Sunday, May 07, 2006

X Bitmap Format

The XBM image format is a simple image file format that can only be used for black and white line art. But the cool thing about XBM files is that you can create them through JavaScript. This means you can add an image to a web page without using an image file. Instead the image is text within the HTML source code. Although black and white line art isn't very fancy it does have the advantage of not allowing the user to right click on the image to save it.

The following sample code will create a little trash can icon but it does not work in Internet Explorer. Try to view this in Firefox instead. I was unable to get an example to work properly in this blog entry. You will need to create your own web page.


<HTML>
<HEAD>
<TITLE>XBM Image Format</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">

<script type="text/javascript">
var strXBM = "#define trash_width 16\n"
strXBM = strXBM + "#define trash_height 16\n"
strXBM = strXBM + "static char trash_bits[] = {"
strXBM = strXBM + "0x00, 0x01, 0xe0, 0x0f, 0x10, 0x10, 0xf8, 0x3f, 0x10, 0x10, 0x50, 0x15,"
strXBM = strXBM + "0x50, 0x15, 0x50, 0x15, 0x50, 0x15, 0x50, 0x15, 0x50, 0x15, 0x50, 0x15,"
strXBM = strXBM + "0x50, 0x15, 0x10, 0x10, 0xe0, 0x0f, 0x00, 0x00};"
</SCRIPT>

<H1>XBM Image Format</H1>
<IMG SRC="javascript:strXBM">
</BODY>
</HTML>

Saturday, May 06, 2006

Information Schema

Yesterday I blogged about how to document a MySQL database by a rather involved process of importing the database into SQL Server and then Microsoft Access. Actually you could simply use phpMyAdmin 2.5.0 to display the same information by clicking the Structure and then the Data Dictionary links. However importing a MySQL database into SQL Server and Microsoft Access is still a useful task.

phpMyAdmin 2.5.0 probably queries the information_schema table to obtain its information about the database design. The information_schema is a special database table that contains data about all the other databases and tables on the database server. Querying the information_schema table can be very useful for dynamically generating code. You could construct tedious INSERT and UPDATE SQL statements or stored procedures based on this information. I have found the correct syntax for running information_schema queries on SQL Server and MySQL:

SQL Server Queries


SELECT table_name FROM information_schema.tables WHERE table_catalog = 'dbName'
tables in a database

SELECT column_name, data_type, numeric_precision, character_maximum_length,is_nullable, column_default
FROM information_schema.columns
WHERE table_name = 'tableName'
columns in a database

MySQL Queries


select table_name, create_time from information_schema.tables where table_schema = 'books'
tables in a database

select column_name, data_type, numeric_precision, character_maximum_length,is_nullable, column_default from information_schema.columns where table_name = 'reading'
columns in a database

Friday, May 05, 2006

How To Document A MySQL Database Design

My blog software is WordPress which is using a MySQL database. My task is to document the database design. Let us see how I accomplish this goal.

My first step is to back up the database because I need a local copy to work with. I log into phpMyAdmin 2.5.0 and export the database as a SQL text file. There is no need to describe this step because it is well documented on the Internet. This gives me a phpMyAdmin MySQL-Dump file which reveals the database design but not in a format I find very readable.

Next I want to import the database backup into my local MySQL Database Server. First I need to create the database "wordpress", then I use the MySQL Administrator's Restore option to restore the database using the SQL file, making sure the target schema is my new database and the checkbox "Create database(s) if they don't exist" is checked.

Then I download and install the ODBC driver for MySQL. You can get it here: http://dev.mysql.com/downloads/connector/odbc/3.51.html I want to create a SQL Server database version of the WordPress MySQL database so I create a new SQL Server database and start the DTS Import / Export Wizard.

Because I installed the ODBC driver for MySQL I now find a new option in the data source drop down list:

MySQL-DTS-Import-Export

When I select that option I discover that I need to create a Data Source Name for the MySQL database I want to import:

MySQL Data Source Name

I click the Test button and find I can connect to the database:

Success; connection was made!

When I attempt to import all the tables, I get 11 tables copied but 2 show errors:

DTS Import Status

There was an error importing the wp_links table Error at Destination for Row number 1. Errors encountered so far in this task: 1. Insert error, column 11 ('link_updated', DBTYPE_DBTIMESTAMP), status 10: Integrity violation; attempt to insert NULL data or data which violates constraints. Unspecified error

wp_links error

And an error importing the wp_users table Error at Destination for Row number 1. Errors encountered so far in this task: 1. Insert error, column 13 ('dateYMDhour', DBTYPE_DBTIMESTAMP), status 10: Integrity violation; attempt to insert NULL data or data which violates constraints. Unspecified error

wp_users error

To solve these errors I just edit the SQL Server database design for these tables and allow these fields to accept NULL values:

wp_links NULL

wp_users NULL

Then I attempt to import just these two tables again and this time it works:

Executing Package

Since that went pretty well I attempt the same thing with Microsoft Access. I try to import the MySQL database using ODBC Databases as the file type and select my data source name which already exists now. Unfortunately Microsoft Office Access has a problem and needs to close:

Microsoft Office Access has encountered a problem and needs to close.

Since that does not work I just export my SQL Server database to my Access database which succeeds with no errors:

Sucessfully copied 13 table(s) from Microsoft SQL Server to Microsoft Access.

Now that I have all my tables and data in Access I can document the database design using its documentation wizard. Select Tools from the menu and then select Analyze and then Documenter. Click the Select All button and then the OK button.

Access Documenter

Now I can export the table design reports as web pages so you can view them online. Select File from the menu and then Export. Select HTML as the "save as type". The table design reports will be exported as web pages complete with navigation links. You can view the talbe design of the MySQL database used by the WordPress blog here:

http://www.williamsportwebdeveloper.com/design/wordpress_db.html