Symbolic Logic:Programming:Object Relational Mapping

Relational Databases may be used to persist and retrieve objects. The SQL language provides a powerful language for describing data retrieval. It is also similar in nature to a Logic Programming Language, and is inherently compatible with it.

However SQL has a dark side. It is not really suited for retrieving objects. Also it is not integrated into the language and forces the user to code conditions on objects in SQL and in there chosen Object Oriented language.

ORM goals
An ORM aims to integrate all aspects of database use into one language.
 * Creating a table should be done automatically by declaring a class for the table.
 * Creating a column on a database should be as easy as declaring it in a class.
 * Creating a where condition should be as easy as creating a boolean condition on the attributes of the class.
 * Handle inheritence and allow the construction of polymorphic lists.
 * Developer never directly writes SQL.

Principles of ORM Design
An object to relational mapping system may seem like a complex system. But in fact it turns out to be simple if we us the principle of Localisation of Functionality. This principle says that each component part of the system should implement as much of its own functionality as possible.

So instead of asking, we ask the one simple question,
 * "how do we map databases and relations and onto classes with inheritance"
 * "How do we implement an attribute"

An attribute is a single column of a table. An attribute should be implemented by a single generic Attribute class. Almost all the functionality required for the implementation of an ORM can be put into this single class.

A Design for an ORM

 * ORM Persistence
 * ORM Attributes
 * ORM Entity Relationship

Links

 * Symbolic Logic:Programming:Framework
 * Symbolic Logic:Programming
 * Intelligence and Reasoning