Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Object Relational Mapping Pattern - using Sql Object

3,811 views

Published on

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.

Published in: Technology
  • Login to see the comments

  • Be the first to like this

Object Relational Mapping Pattern - using Sql Object

  1. 1. SQLObject Object-Relational Mapper (ORM) for Python Presented by Andy Bulka [email_address] n et. a u
  2. 2. Impedance Mismatch <ul><li>Relational databases and OO memory models use different paradigms. </li></ul><ul><li>Management likes databases. </li></ul><ul><li>Programmers like OO models. </li></ul><ul><li>Mapping between one and the other is fiddly work. </li></ul>
  3. 3. The Basic ORM Solution <ul><li>A class is a table. </li></ul><ul><li>An attribute on a class is a column in a table. </li></ul><ul><li>Automatic mapping code in your classes so that setting attributes on objects has side effects (it changes the database). </li></ul>
  4. 4. SQLObject <ul><li>Provides a strong database abstraction, allowing cross-database compatibility e.g. SQLLite, MySQL, firebird, maxdb, postgres, sybase. </li></ul><ul><li>Possibly use sqlserver via mxODBC. </li></ul><ul><li>SQLRelay http:// sqlrelay . sourceforge .net/ . </li></ul>
  5. 5. SQLObject Joins <ul><li>One-to-one </li></ul><ul><li>One-to-many </li></ul><ul><li>Many-to-many </li></ul><ul><li>(Something which many ORMs do not have.) The join system is also intended to be extensible </li></ul>
  6. 6. Inheritance <ul><li>SQLObject supports inheritance </li></ul><ul><li>The inherited table does not have to repeat the attributes of the table it inherits from – just adds new attributes. </li></ul><ul><li>SQLObject will look after the mappings and for each OO memory instance, creates an entry in both tables. </li></ul>
  7. 7. An Example <ul><li>Object Model </li></ul>

×