Look Maa! No Tables Only Objects!

Databases are one topic that I have never had a chance to get deeper insights.

I started JDBC’ing when later I was surprised to know that one could connect to the database using ‘C’.

I had not worked enough to feel the pain of iterating over ResultSet and writing insert/update scripts that virtually went outside the screen when I saw the onset of “Hibernate-Relational Persistence for Idiomatic Java”. I never liked the writing/seeing/understanding XML, but I had no choice but to Well Hmmm!

And with most of the time spent in Hibernate, I never felt its features were intuitive to that of Java(in no specific order).

  • First and foremost in Java, Enum are first class citizens, in Hibernate, working with an Enum is not at all trivial.
  • Using composite keys asks you to maintain a seperate object for it.
  • Already there were two worlds of entities in Application(objects) and entities in DB(records), now to understand the two, one needed to know how Hibernate understands the two worlds.

For simple applications, Hibernate is way to work with, but with very large applications, I did not like the complexity that it brought in atleast two occasions, requiring extra time to keep the DB and the hbm files in sync.
It could be the incorrect way of not completely relying on hbm for schema generation, but because these applications had predefined schema’s, this was the only possible safe-path.

Issues with RDBMS:

  • Application<---->Mapping<---->DB
  • Cost of mapping conversion(second level cache’s are not enough!)
  • Transactions duplicates Locking- In general.

Tired of looking at xml, and with the option to write an application for fun, I have the option to evaluate the usage of Object Oriented Database.
I had found atleast a dozen implementation of such software, at the end it came down to db4o and Perst. And here is the summary of them:

db4o

  • Most commonly used OODBMS.
  • Easy to learn.
  • Supports intuitive Refactoring of persistent classes.
  • Support for Projections is not available(could not find).
  • Lazy initialization supported with default level of depth.

Perst

  • Has GIS Dataset
  • Fastest amongst all OODBMS.
  • Cryptic creation of indices for faster search.
  • Concept of Links for references pollutes domain.
  • No fixed DTD for import/export feature for refactoring.

Both the products have the following in common:

  • Support for Transactions.
  • Zero mismatch between object and saved data.
  • Confusing Licence!

At the end, I have to give in to db4o for simplicity and refactoring features.
And that’s where I would start looking at injecting it into the application.

Concerns about OODBMS:

  • Not Yet widely used – I wonder why?
  • Clustering – I do not need it.
  • Backup – RDBMS or File?
  • Optimization – Exotic feature than a requirement.

So I would look forward to working on the application on db4o and will update on the findings!

~rohit.

Decoding the SSO

I found this a year ago but i am sharing it now!
When i was developing multiple RoR apps about a year ago, there was one basic requirement, that of a SSO solution.

Err…. i hope you guys know what SSO is?
Well for those of you who are clueless, SSO stands for Single Sign-On.

Yes, SSO is one of the most important requirements of modern web apps. SSO enables a user to use multiple apps with a single username/password and the user needs to authenticate only once to use all the connected apps.

Take the example of Google! Have you ever wondered how you can directly access (without requiring to re-enter your credentials) your orkut/picassa account, when a moment back you were using gmail. Yes Google uses SSO!

Now for the decoding part, this is how Google does it:

Have you ever observed closely, what happens whenever you try to access any of the Google services for the first time?
The first request is always redirect to google’s main domain (i.e google.com) along with a set of parameters:
1. service -> which tells the service being requested
2. continue -> which tells the web location where the request should be forwarded after it is authenticated on the main domain

There are a few more parameters, but the above two are the most important.

Once you authenticate yourself on any google service, a cookie is created on the main domain. This cookie is checked whenever you try to access some other google service for the first time.
Once your identification is established on the main domain, another cookie with similar info is set on the service/webapp you are accessing (e.g. mail.google.com / orkut.com / blogger.com)
So, the subsequent requests to the same webapp, need not be redirected to the main domain for authentication!

The reverse happens, when you logout of a google service. The cookie on the current app is removed and then the request is forwarded to main domain to remove the cookie over there as well.
This makes sure that you logout of all the google services at one go!

For more info, on how you can implement SSO in your webapps, refer to these links:

http://www.jasig.org/cas
http://code.google.com/p/rubycas-server/
http://code.google.com/p/rubycas-client/

My triumph over MYSQL..!

My fight with MySQL has finally come to an end. It has been troubling me past few weeks.
I was facing troubles on installing it on my office PC. Finally I got it right..!!!! hurrayyy..I won over it..!

The error which was troubling was ” Error No:1045- Access denied for user ‘root@localhost’ (using password:YES)”.

the resolution is:
MySQL configuration wizard doesn’t set or reset the root password. It simply leaves the password as blank. Otherwise the installation is complete.

The crack is: On getting this error, go to MySQL Command Line. Press ENTER when it asks for password(because it has been left blank by the Server Configuration Wizard).
On the command prompt, type SET PASSWORD FOR ‘root@localhost’ = PASSWORD(‘newpwd’);

Now its running….