zodb, the zope object database (may 2003)

18
An introduction to the open source object database, by Kiran Jonnalagadda <[email protected]> http://jace.seacrow.com/ ZODB The Zope Object Database

Upload: kiran-jonnalagadda

Post on 30-Jun-2015

295 views

Category:

Technology


2 download

DESCRIPTION

A presentation on the Zope Obect Database, made to the Bangalore LUG in May 2003. ZODB was an early entrant to what is called NoSQL these days.

TRANSCRIPT

Page 1: ZODB, the Zope Object Database (May 2003)

An introduction to the open source object database, by

Kiran Jonnalagadda <[email protected]>http://jace.seacrow.com/

ZODBThe Zope Object Database

Page 2: ZODB, the Zope Object Database (May 2003)

Where relational databases are unwieldy

The object database methodology

A brief introduction to Python

Mechanics of ZODB

Limitations

Resources

Agenda

Page 3: ZODB, the Zope Object Database (May 2003)

Relational Database Records

Field Record 1 Record 2 ...

First Name Atul Kiran ...

Last Name Chitnis Jonnalagadda ...

Age 41 24 ...

Phone No. 344 0397 658 2921 ...

Exte

nsib

le

Individual Record Is Not Extensible

Page 4: ZODB, the Zope Object Database (May 2003)

Issues with Relational DBs

Can’t store multiple values in a single field

Can’t add extra fields to individual records

Solved by adding extra relational tables

With complex data, this gets unmanageable

Developer time is wasted writing a database interaction layer

Page 5: ZODB, the Zope Object Database (May 2003)

Object Hierarchy

Address BookDatabase

KiranJonnalagadda

Atul Chitnis

...

...

First Name

Last Name

Age

Phone Number

...

...

Page 6: ZODB, the Zope Object Database (May 2003)

An object oriented database stores objects instead of database records

Objects contain variables (data) and methods to act on these variables; may be inherited

Objects are usually organised hierarchically

Most object databases are bound to a specific language because each language implements OOP differently

Object Concepts

Page 7: ZODB, the Zope Object Database (May 2003)

High performance

Transparent Operation and Caching

Transactional: Unlimited Undo

Multi-threaded

Storage plugins

Needs Python

Introducing ZODB

Page 8: ZODB, the Zope Object Database (May 2003)

Python is a dynamic typed and a strong typed language

Python is dynamic: everything can be modified at run-time. Class members, base classes, whatever

Why Python?

Page 9: ZODB, the Zope Object Database (May 2003)

What Dynamic Means

Variables Are: Dynamic Typed Static Typed

Strong Typed Python C, C++, Java

Weak Typed Perl, PHP, JS,Shell Script *

Page 10: ZODB, the Zope Object Database (May 2003)

Not a relational database

No SQL support

No security model

No query interface:

Objects must be accessed via container

A separate search engine is available

What ZODB is Not

Page 11: ZODB, the Zope Object Database (May 2003)

ZODB: The Mechanics

Page 12: ZODB, the Zope Object Database (May 2003)

All classes must be derived from the “Persistent” base class provided by ZODB

At the start of your program, open a ZODB connection

Commit the transaction periodically

That is all!

Code need not be ZODB aware

Really Simple Usage

Page 13: ZODB, the Zope Object Database (May 2003)

Example Code

# Necessary importsfrom ZODB import FileStorage, DBfrom Persistence import Persistent

# Connect to a databasestorage = FileStorage.FileStorage('/tmp/test-filestorage.fs')db = DB(storage)conn = db.open()

# Get the root of the databasedbroot = conn.root()

# Defining user classesclass UserDataClass(Persistent): pass

# Commit or abort after making a changeget_transaction().commit()get_transaction().abort()

Page 14: ZODB, the Zope Object Database (May 2003)

ZEO is Zope Enterprise Objects

One ZEO serves multiple ZODB clients

Databases can be mounted on each other, just like file systems

No replicated storage yet

Remote Storage: ZEO

Page 15: ZODB, the Zope Object Database (May 2003)

FileStorage (standard)The entire database is stored in a single file

DirectoryStorageEach object is stored as a separate file

BerkeleyDB StorageThe database is stored in BerkeleyDB

ClientStorageDatabase is stored in a remote ZEO database

Available ZODB Storages

Page 16: ZODB, the Zope Object Database (May 2003)

Only available via Python

Transparency is sometimes undesirable

Cannot detect changes in objects not derived from the Persistent base class, like a list or dictionary

Programmer has to flag such objects as dirty

ZEO is optimised for heavy reads, not writes

Limitations

Page 17: ZODB, the Zope Object Database (May 2003)

ZODB Product Page:http://zope.org/Products/StandaloneZODB

ZEO Product Page:http://zope.org/Products/ZEO/

An introduction to ZODB and ZEO:http://www.amk.ca/zodb/zodb-zeo.html

The Indian Zope and Python User Group:http://groups.yahoo.com/group/izpug

Resources

Page 18: ZODB, the Zope Object Database (May 2003)

This presentation is available online at:http://jace.seacrow.com/tech/zope/blug-zodb

Thank You!