QuickDB ORM
Encyclopedia
QuickDB is an object-relational mapping
Object-relational mapping
Object-relational mapping in computer software is a programming technique for converting data between incompatible type systems in object-oriented programming languages. This creates, in effect, a "virtual object database" that can be used from within the programming language...

 framework
Software framework
In computer programming, a software framework is an abstraction in which software providing generic functionality can be selectively changed by user code, thus providing application specific software...

  for the Java software platform. It was developed by Diego Sarmentero along with others and is licensed under the LGPL License. Versions for .NET
.NET Framework
The .NET Framework is a software framework that runs primarily on Microsoft Windows. It includes a large library and supports several programming languages which allows language interoperability...

, Python
Python (programming language)
Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...

 and PHP
PHP
PHP is a general-purpose server-side scripting language originally designed for web development to produce dynamic web pages. For this purpose, PHP code is embedded into the HTML source document and interpreted by a web server with a PHP processor module, which generates the web page document...

are also being developed.

Concepts

QuickDB allows a developer to focus on the definition of the entities that represent the tables of the database and perform operations that allow the interaction between these entities and the database without having to perform tedious configurations, leaving to the library the task to infer the object structure and make the mapping of the object to the Database.

The software aims not only to simplify the task of mapping the attributes between a traditional relational database and the objects from the data model, but in turn, make the use of the library intuitive for the developer, leaving aside configuration tasks. Where each operation involves only the task (save, modify, ...) and the subject where it should apply to (the object).

QuickDB, like other tools for object-relational mapping, seeks to resolve the differences between the two co-existing data models: Object-Oriented Model and the Relational Model. To address this problem, it takes a fully object-oriented approach, where structures like "Objects composed of other objects", "Inheritance", "Collections" (one-to-many and many-to-many) are recognized by default as common entities, and also other features such as automatic table creation and modification of tables dynamically if the structure of the object change over time (addition of new attributes) are included. QuickDB not require the implementation of any interface, or the use of inheritance by the data model to be persistent, it is based simply on certain naming conventions for attributes to infer relevant information about the Object. However, it is possible to use annotations to set certain characteristics of the object, which gives the assurance that everything that QuickDB recognize by default, can be also managed completely by the developer. For queries, QuickDB pretends to maintain this approach where the developer works with the data model in a fully object-oriented way, and therefore the SQL statements (although they are permitted) are not necessary, and can be used by default a Query system where the condition to be evaluated is specified with a simple reference to the attributes in the objects from the data model.

Capabilities

This capabilities can be combined with Inheritance, Compound Objects, Collections (Many to Many Relation, One to Many Relation) and Automatic Table Creation.

Using QuickDB

Example Classes::

//Create AdminBase instance for MySQL
AdminBase admin = new AdminBase(AdminBase.DATABASE.MYSQL, "localhost",
"3306", "exampleQuickDB", "root", "");

//Create Address Object
Address a = new Address;
a.setNumber(123);
a.setStreet("unnamed street");

//Create a Collection of Phone Objects
Phone p1 = new Phone;
p1.setAreaCode("351");
p1.setNumber("123456");
Phone p2 = new Phone;
p2.setAreaCode("351");
p2.setNumber("4567890");
ArrayList phones = new ArrayList;
phones.add(p1);
phones.add(p2);

//Create Employee Object
Employee e = new Employee;
e.setCode(555);
e.setRolDescription("play ping pong");
e.setName("Diego Sarmentero");
e.setBirth(new java.sql.Date(100, 4, 20));
e.setAddress(a);
e.setPhone(phones);

Operation: save


//Create the Table automatically if not exists
admin.save(e); //Salvar Employee

Result: save

Tables are automatically created and the Employee object is saved with all the objects related to it.

Address
idstreetnumber
1 unnamed street 123


Phone
idareaCodenumber
1 351 123456
2 351 4567890


Person
idnamebirthaddress
1 Diego Sarmentero 2000-05-20 1


PersonPhone
idbaserelated
1 1 1
2 1 2


Employee
idcoderolDescriptionparent_id
1 555 play ping pong 1

Operation: obtain

The Employee object which inherited attribute address has the value "unnamed street" in street is retrieved.


admin.obtain(e, "address.street = 'unnamed street'");



admin.obtain(e).where("street", Address.class).equal("unnamed street").find;

Operation: modify

Change the name from the Employee object and add a new Phone to the collection (the obtain operation must be performed previously to retrieve the object).


e.setName("Leonardo");
Phone p = new Phone;
p.setAreaCode("123");
p.setNumber("98765");
e.getPhone.add(p);

admin.modify(e);

Operation: delete

Delete an specific Employee object (after retrieve the object with obtain operation).


admin.delete(e);

Inheritance: AdminBinding

QuickDB also provides the possibility of allowing the developer to create the data model extending the AdminBinding Class (but this is not required, this is another available resource to simplify some processes), which serves as a "link" between the entities and AdminBase to allow the operations that interact with the database to be executed from the object itself and not use AdminBase intermediary as directly.

AdminBinding not cover all the functionality that AdminBase provides, as it only handles those operations that are specific to the object that contains them, leaving out those that refer to collections, etc.

More Features

QuickDB includes many features that can be consulted on the Project Page. An important detail to take into account is that with every new feature that is added, the simplicity of QuickDB is maintained without sacrifice functionality.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK