June 26, 2008

Enabling Apache User Directories

Filed under: Development,Linux — mifan @ 10:25 am

In Apache, you have the choice of allowing users to have their own web URIs from within their home folders. Say for instance that my username is nazgul, on a domain, then I can have a web-enabled folder within my home directory, which is accessible by http://somewhereonmiddleearth/~nazgul. To do this on Linux, do the following:
Create a folder named public_html
mkdir public_html
Go to your Apache folder (/etc/apache2/ on my system), and copy over the userdir modules from the mods-available folder to the mods-enabled folder:
cd /etc/apache2/
sudo cp -r mods-available/userdir.* mods-enabled/

Restart Apache2
sudo /etc/init.d/apache2 restart
And hey presto, your files under public_html would be accessible via a browser: thus if you are on your local machine, then you can access them via http://localhost/~nazgul . This is quite useful if you create web applications using Eclipse – where having your workspace inside public_html means they areautomatically web-accessible.

June 9, 2008

Creating ER diagrams from SQL

Filed under: Uncategorized — mifan @ 10:34 am

SQLt/SQL::Translator/SQLFairy is a great tool to create ER diagrams from SQL:

SQL::Translator is a group of Perl modules that manipulate structured data definitions (mostly database schemas) in interesting ways, such as converting among different dialects of CREATE syntax (e.g., MySQL-to-Oracle), visualizations of schemas (pseudo-ER diagrams: GraphViz or GD), automatic code generation (using Class::DBI), converting non-RDBMS files to SQL schemas (xSV text files, Excel spreadsheets), serializing parsed schemas (via Storable, YAML and XML), creating documentation (HTML and POD), and more.

In Ubuntu Linux and Debian Linux, this can be obtained by installing SQLFairy:
apt-get install sqlfairy
This is quite useful if you follow a bottom-up approach: create the SQL first, and then create ER diagrams – although this might not be a common development method, it does have its uses, and some of us like it 🙂
So for instance, say you have a MySQL schema named sample.sql. To create a ER diagram with color, named sample_schema.png, run the following in the command line:
sqlt-diagram -d=MySQL -o=sample_schema.png sample.sql --color
where -d=MySQL specified the MySQL driver. Other available drivers can be obtained by:
sqlt -l
Additionally, sqlt can also be used to convert between various database schemas as well.

SQLFairy ER Diagram

Blog at