7
SQLObject Object-Relational Mapper (ORM) for Python Presented by Andy Bulka [email protected]

Object Relational Mapping Pattern - using Sql Object

  • Upload
    tcab22

  • View
    2.533

  • Download
    5

Embed Size (px)

DESCRIPTION

Relational databases and OO memory models use different paradigms. Mapping between one and the other is fiddly work so an auto-mapping tool like Sql Object (python framework) can help enormously.

Citation preview

Page 1: Object Relational Mapping Pattern - using Sql Object

SQLObject

Object-Relational Mapper (ORM)for Python

Presented by Andy Bulka

[email protected]

Page 2: Object Relational Mapping Pattern - using Sql Object

Impedance Mismatch

• Relational databases and OO memory models use different paradigms.

• Management likes databases.

• Programmers like OO models.

• Mapping between one and the other is fiddly work.

Page 3: Object Relational Mapping Pattern - using Sql Object

The Basic ORM Solution

• A class is a table.

• An attribute on a class is a column in a table.

• Automatic mapping code in your classes so that setting attributes on objects has side effects (it changes the database).

Page 4: Object Relational Mapping Pattern - using Sql Object

SQLObject

• Provides a strong database abstraction, allowing cross-database compatibility e.g. SQLLite, MySQL, firebird, maxdb, postgres, sybase.

• Possibly use sqlserver via mxODBC.

• SQLRelay http://sqlrelay.sourceforge.net/.

Page 5: Object Relational Mapping Pattern - using Sql Object

SQLObject Joins

• One-to-one

• One-to-many

• Many-to-many

• (Something which many ORMs do not have.) The join system is also intended to be extensible

Page 6: Object Relational Mapping Pattern - using Sql Object

Inheritance

• SQLObject supports inheritance

• The inherited table does not have to repeat the attributes of the table it inherits from – just adds new attributes.

• SQLObject will look after the mappings and for each OO memory instance, creates an entry in both tables.

Page 7: Object Relational Mapping Pattern - using Sql Object

An Example

• Object Model