1 / 18

Svetoslav Kapralov

Svetoslav Kapralov. Contents. DB4O Overview OODBMS vs. RDBMS What is DB4O DB4O Basics Object Container CRUD Activation Transactions. DB4O Overview. O О DBMS ( db4o ) vs. RDBMS. Object-oriented programming (OOP) and relational databases (RDBMS) do not match up

genica
Download Presentation

Svetoslav Kapralov

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Svetoslav Kapralov

  2. Contents • DB4O Overview • OODBMS vs. RDBMS • What is DB4O • DB4O Basics • Object Container • CRUD • Activation • Transactions

  3. DB4O Overview

  4. OОDBMS (db4o) vs. RDBMS • Object-oriented programming (OOP) and relational databases (RDBMS) do not match up • An object database (ODBMS) stores objects directly

  5. What is db4o? • Open source object database • Designed for embedded • 1,000,000 downloads, • 20,000 registered community members • 200 customers • Dual license model (GPL / commercial) • db4o is up to 55x fasterthan Hibernate + RDBMS!

  6. What is db4o? • No Database Administrator required • No conversion or mapping needed since objects are stored as they are • Only one line of code to store objects of any complexity natively • Installation by adding a single library file

  7. DB4O Basics

  8. Object Container • Represents db4o databases • Supports local file mode or client connections to db4o server • All operations are executed transactional • Maintains references to stored and instantiated objects

  9. Storing Objects • Objects stored using method setof ObjectContainer • Stores objects of arbitrary complexity ObjectContainer database = Db4o.openFile("test.db"); // create a publication Book book =new Book(“db4o"); // create authors Author lambo = new Author(“Lambo"); Author gruiu = new Author(“Gruiu"); // assign authors to book book.addAuthor(lambo); book.addAuthor(gruiu); //store complex object database.set(book);

  10. Retrieving Objects • db4o supports three query languages • QBE • Native query • SODA

  11. Query by Example • simple method based on prototype objects ObjectContainer database = Db4o.openFile("test.db"); // get author “Lambo" Author proto = new Author(“Lambo"); ObjectSet<Author> authors = database.get(proto); for (Author author: authors) { System.out.println(author.getName()); } // get all books ObjectSet<Book> books = database.get(Book.class); for (Book book: books) { System.out.println(book.getTitle()); }

  12. Native Queries • type safe • transformed to SODA and optimized ObjectContainer database = Db4o.openFile("test.db"); // find all books after 1995 ObjectSet<Book> books = database.query( new Predicate<Book>() { publicboolean match(Book book) { return book.getYear() > 1995; } } ); for (Book book: books) { System.out.println(book.getTitle()); }

  13. Update / Delete Objects • Update procedure for persistent object • retrieve desired object from the database • perform the required changes and modification • store object back to the database by calling the setmethod • Delete procedure for persistent object • retrieve desired object from the database • method deleteof ObjectContainerremoves objects

  14. CRUD Summary • Storing of new objects using the setmethod • object graph is traversed and all referenced objects are stored • Updating of existing objects using the setmethod • by default update depth is set to one • only primitive and string values are updated • object graph is not traversed for reasons of performance

  15. CRUD Summary • Deleting existing objects using the deletemethod • by default delete operations are not cascaded • referenced objects have to be deleted manually • cascading delete can be configured for individual classes

  16. Activation • Activation controls instantiation of object fields • object field values are loaded into memory only to a certain depth when a query retrieves objects • activation depth denotes the length of the reference chain from an object to another • fields beyond the activation depth are set to null for object references or to default values for primitive types

  17. Activation • Activation depth trade-off • set to maximum • set to minimum • Controlling activation • default activation depth is 5 • methods activateand deactivateof ObjectContainer • per class configuration

  18. Transactions • ACID transaction model • Data transaction journaling • zero data loss in case of system failure • automatic data recovery after system failure • db4o core is thread-safe for simultaneous operations • db4o uses the read committed isolation level

More Related