Tuesday, November 25, 2008

Running SchemaSpy for database tables in SQL Server 2005

I was looking for a tool to generate the schema diagram from my SQL Server 2005 development database.  After some research I found the open source tool SchemaSpy which meet my needs, it also had decent reviews in few blogs.  But I had problem running the tool to generate the Html documents for my schema.

After playing around with the option parameters, I was finally able to get it to generate the documentation needed.  Couple of things to ensure before running schemaspy to generate documentation for SQL Server 2005 schema.

Make sure the Graphviz installation is added to your system PATH variable.  Run the following command

java -jar schemaSpy.jar -t mssql05 -db <name of the database> -host <Ip address/hostname> -s dbo -port 1433 -u <username of the database> -p <Password for the userId> -o library

Saturday, November 01, 2008

Difference between Static and Singleton Pattern

I wanted to blog about this for a while, b'cos I found many folks not being able to answer this question during the interview process.  Few differences worth mentioning are

  • Singletons can implement interfaces and inherit from other classes (while static classes cannot).
  • Singletons can be extended (used as a subclass) while static classes cannot.
  • There is only one instance in case of Singletons but there is none in case of Static classes.
  • Singletons can be passed around as a parameter to function calls but you can't do that with a Static class.