A Universal Database Definition


NoSQL::PL2SQL is an interface to a generic RDB standardized on the SQL interface.  So what makes this package NoSQL?
NoSQL::PL2SQL encapsulates the SQL and replaces it with... well, nothing.
In this case, NoSQL describes the interface... the part that really matters.  The ideal interface for a NoSQL solution is whatever the user is most comfortable with.  That is, for Object Oriented (OO) programmers, whatever methods are defined for accessing the properties and elements of an object.
Java, for example, is standardized around method names such as getName(), setName(), getProperty(), setProperty(), etc.  For Java developers, these methods represent the ideal way to interface to a set of database data that can be aggregated as a defined object.
Personally, I am partial to the Perl approach:
$obj = new MyClass() ;
$obj->{UserID} = '23kla12' ;
## obj.setUserID('23kla12')
in Java
$myID = $obj->{UserID} ;
## myID = obj.getUserID()
in Java
In Perl, these statements would compile and execute even if the line 1 statement, which declares and defines $obj, was removed.  By default, Perl creates a hash table of property names and values.  On this basis, the functions of the other two statements will be obvious wherever they occur in a block of code.
Perl includes the ability to overload the assignment operator.  In line 2, the default operation is sufficient to set a property named 'UserID' to reflect the value '23kla12'. Same with line 3. But in order to perform a side effect, say to notify that user that his/her record is being accessed, an overload can be defined.  Since these side effects are supposed to be encapsulated in the class definition, I find this approach makes it easy to write and manage objects in Perl.
The genius of Perl is to use overloaded assignments to access internal data.  Naturally, I took the same approach for the NoSQL interface.  Since the assignment operator is the most obvious and intuitive for users, I don't feel the need for excessive API documentation.
The internal structure of PL2SQL includes a set of SQL statements that are generated as part of the overloaded assignment operators.  When the object is destroyed, these SQL statements are transmitted to the RDB server.  Any changes in the object data remain persistent until that data is again initialized as an object.
As a result, the PL2SQL API essentially consists of a single method, SQLObject(), required to initialize an object.
Comments Leave a comment
  • Re: new module pl2sql
    Sep 20 2012
    Corion (PerlMonks)
    3 Replies