mercoledì 17 settembre 2008

Relational to document based: what to do?

I'm trying to figure out how to "convert" a relational database to a document based one. Specifically, an existent (legacy) relational database.

As an example, think about a DB where the record can be represented by the following Java class:

public class Person {
String name;
String surname;
Date registration_date;

If I want to write an instance of Person to a document based DB, as CoachDB, I can use the following approaches.

The simplest one that may come to mind is making Person implement the Serializable interface, serialize the instance of the class, and then write the obtained bit-code to a Document. However, this would make the DB completely useless: in the DB I would have only bit-codes, and I wouldn't be able to retrieve data without the Java serializer/deserializer. I would use the DB as a file system, so this approach is definitely bad.

Another idea could be: for each field, write it to the document in a form like

{ field.key , field.value.toString() }

However this would work without problems only for the first two fields. In fact, when we write to the document the registration_date.toString(), we would have some problems reconstructing it back from the document.

I'm currently searching for a solution about this topic. Stay in touch!

Nessun commento:

Posta un commento