Object-oriented database db4o: initial knowledge db4o

Source: Internet
Author: User



> The industry's quest for persistent storage has never stopped, and many new technologies have sprung up in the open source and business sectors to make it easier and easier to use objects to express our thinking. In the past year, the industry is also rethinking, in the end, the ORM is to bring us a convenience or trouble. Pointing to the well-known Hibernate, has been discussing its performance issues, we seem to reach the consensus: "In the business logic complex place with SP, and the general CRUD or Hibernate", even the world-renowned BearingPoint also have similar views. The following simple example illustrates the drawbacks of traditional ORM tools. Let's consider a simple Student object such as   Listing 1 :

Listing 1. Student class

public class Student {private string name, private int age, public string GetName () {return name,} public int getage () { return age; } }

Consider this scenario: find "all students younger than 20 years old"?

Use the ORL implementation as shown in Listing 2:

Listing 2. ORL implementation

String OQL = "SELECT * from student in allstudents where Student.age <20"; Oqlquery query = new Oqlquery (OQL); Object students = Query.execute ();

Use the JDOQL implementation as shown in Listing 3:

Listing 3. JDOQL implementation

Query query = persistencemanager.newquery (Student.class, "Age <20"); Collection students = (Collection) query.execute ();

There are some common problems with the methods above:

    • The modern integrated development environment does not check for semantic and grammatical errors in inline strings. In all of the above query statements, both the age field and the value 20 are considered numeric types, but none of the Ides or compilers can check their actual correctness. If the developer confuses the query code-― for example, changing the name or type of the age field will cause-all of the above query statements are wrong at the time of the run times, and not prompt at compile.

    • Modern agile development techniques encourage continuous refactoring to maintain a clear and up-to-date class model that accurately reproduces evolving domain models. If the query code is difficult to maintain, it delays determining the time to refactor and inevitably introduces low-quality code.

    • All of the listed queries are directly using the Student class's private member, age, rather than using its public interface Student.getage (), so they all break object-oriented encapsulation rules, violate interfaces, and implement object-oriented laws that should be separated.

    • All queries are not native to 100%.

Since there are so many problems, why not just use a purely object-oriented database? Some developers may say: "It lacks the support of mathematical models and is not mature enough". It is true that the RDBMS has evolved over the decades to achieve today, and it has been perfected. and technological innovation is endless, complacent forever can not keep up with the pace of change.

> Let's take a brief look at the history of the object database (data from the Wiki Encyclopedia): The term "Object-oriented database system" first appeared in 1985. Notable research projects include: Encore-ob/server (Brown University), EXODUS (Wisconsin University), IRIS (Hewlett-Packard), ODE (Bell Lab), ORION (MCC), Vodak (GMD-IPSI) and Zeit Geist (Texas Instruments). The number of papers published in the ORION project is the largest. MCC's Won Kim compiles the most valuable parts of these papers into a book and is published by MIT Press. The object database management system adds a lasting concept to the object-oriented programming language. The earliest commercialization of Odbms appeared in 1986 and was launched by Servio Corporation (now Gemstone) and Ontos Corporation. Later (the 90 's), Versant, objectivity, O2 technology, poet, Ibex, Unisql, and ADB MATISSE joined the pioneering ranks.

Today, Db4objects, an open source object-oriented database company from Silicon Valley, California, has brought us db4o, a pure object-oriented database with excellent performance, and a leading role in this and subsequent articles.

What db4o brings to us is an object-oriented approach to querying:

    • the native query language of 100% should be fully expressed in the implementation language (Java or C #) and fully follow the semantics of the implementation language.

    • the 100% object-oriented query language should be run in its own implementation language, allowing generic collections to be performed without optimizations without custom preprocessing.

    • The 100% type-safe query language should be able to fully capture the features of modern Ides such as syntax detection, type detection, refactoring, and so on.

What is db4o

"Using tables to store objects is like driving a car home, then splitting it into parts and putting it in the garage, and then assembling the car in the morning." But one wonders whether this is the most effective way to park a car. "–esther Dyson

Db4o is an open-source, pure object-oriented database engine that is easy to use for both Java and. NET developers. At the same time, DB4O has been validated by third parties as an object-oriented database with excellent performance, and the following benchmark diagram compares db4o with some traditional durable scenarios. Db4o ranked second in this comparison, just behind JDBC. With the benchmark results from Figure 1, it is worthwhile to savor the significant difference in performance between the HIBERNATE/HSQLDB scheme and the JDBC/HSQLDB scheme, which confirms the industry's concern for Hibernate. And Db4o's excellent performance, let us believe: more OO does not necessarily sacrifice performance.

Figure 1. HSQLDB Benchmark Test

At the same time, db4o is characterized by the need for DBA management, small footprint, which is ideal for embedded applications and Cache applications, so since Db4o was released, it has quickly attracted a large number of users to use db4o for a wide variety of embedded systems, including mobile software, medical devices, and real-time control systems.

Db4o is developed and is responsible for business operations and support by Db4objects, an open source database company from Silicon Valley, California. Db4o is based on the GPL protocol. Db4objects was formed in 2004 under the leadership of CEO Christof Wittig, including Mark Leslie, CEO of Veritas software company, Vinod Khosla (one of Sun's founders), Sun Senior investment in Silicon Valley, the CEO of the company. There is no doubt that today Db4objects is one of Silicon Valley's hottest innovators in technology.

db4o Characteristics

Db4o's goal is to provide a powerful, fit-embedded database engine that can work on devices, mobile products, desktops, and servers in a variety of platforms. The main features are as follows:

    • Open Source mode. Unlike other Odbms, db4o is open source software that drives the development of db4o products through the power of the open source community.

    • native database. db4o is a 100% native object-oriented database that uses programming languages to manipulate databases directly. Programmers do not have to do OR map to store objects, which greatly saves the programmer's development time in storing data.

    • High performance. Figure 2 shows the official benchmark data for db4o, db4o is 44 times times faster than the Hibernate/mysql solution on some test lines! and easy to install, only about 400Kb. jar or. dll library files. In the next series of articles, we will focus only on the application in the Java platform, but in fact db4o will undoubtedly work well on the. NET platform.

Figure 2. DB4O official benchmark test data

    • is easy to embed. The uses db4o only need to introduce more than 400 K jar files or DLL files, memory consumption is very small.

    • 0 management. The uses db4o to achieve 0 management without DBAs.

    • supports multiple platforms. The db4o supports from Java 1.1 to Java 5.0, and also supports. NET platforms such as. NET, compactframework, Mono, etc., and can also run in CDC, Personalprofile, Symbia N, SavaJe, and Zaurus, a J2ME dialect environment that supports reflection, can also be run in CLDC, MIDP, Rim/blackberry, Palm OS, which do not support reflection-enabled J2ME environments.

Perhaps the developer would ask, what if the existing application environment already has a relational database? It doesn't matter, db4o DRS (db4o Replication System) enables two-way synchronization (replication) of db4o and relational databases, 3. DRS is based on Hibernate development, the current version is 1.0, and runs on Java 1.2 or later platforms, based on DRS for Db4o to Hibernate/rdbms, db4o to db4o, and Hibernate/rdbms Two-way replication to Hibernate/rdbms. The DRS model is shown in Figure 3.

Figure 3. DRS model


Db4o has received the Java Pro 2006 Reader's Choice Award for its open source concept and innovative implementation. Whether from the success story or db4o itself, this pure object-oriented database is worth our attention, from the official forum feedback, there are quite a user ready to migrate the relational database to db4o. And the latest release of the 5.5 version, but also to improve performance again a lot. In the following article, I will continue to share with you the db4o brought us this object-oriented database storm.



    • DB4O official website.

    • Object-oriented database db4o Tour series : View a complete list of articles in this series.

    • ODMG Official website: Learn about ODMG technology.

    • DeveloperWorks Java Technology Zone: Hundreds of articles on various aspects of Java programming.

Access to products and technologies

    • Download the db4o free version.

Object-oriented database db4o: initial knowledge db4o

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

Tags Index: