Helma logo
helma.org » Home > docs > tutorial > Object-Relational Mapping

Object-Relational Mapping

The goal is now, to "wire" the relational tables in the MySQL database to the object-oriented structure of Helma. While MySQL (and any other relational database system) structures data in tabular form, each row representing a data set, in Helma each table row becomes a HopObject using the columns as named subnodes, also called properties.

To achieve this, you will now create a prototype such HopObjects can be adapted from. While this sounds complex in theory, in practice you do this simply by adding a new directory to your application (e.g. by issueing mkdir apps/addressbook/Person).

+----+-----------+-----------+---------------------+
| id | firstname | lastname  | email               | 
+====+===========+===========+=====================+
|  1 | Hannes    | Wallnoefer | hannes@helma.org    |
+----+-----------+-----------+---------------------+
|  2 | Robert    | Gaggl     | robert.gaggl@orf.at |
+----+-----------+-----------+---------------------+
|  3 | Tobi      | Schaefer  | tobi@helma.org      |
+----+-----------+-----------+---------------------+
fig.1 A relational database table.

+-------------+
| HopObject 1 |
+===========+=+----------------+
| FIRSTNAME | Hannes           |
+-----------+------------------+
| LASTNAME  | Wallnoefer        |
+-----------+------------------+
| EMAIL     | hannes@helma.org |
+-----------+------------------+

+-------------+
| HopObject 2 |
+===========+=+-------------------+
| FIRSTNAME | Robert              |
+-----------+---------------------+
| LASTNAME  | Gaggl               |
+-----------+---------------------+
| EMAIL     | robert.gaggl@orf.at |
+-----------+---------------------+

+-------------+
| HopObject 3 |
+===========+=+--------------+
| FIRSTNAME | Tobi           |
+-----------+----------------+
| LASTNAME  | Schaefer        |
+-----------+----------------+
| EMAIL     | tobi@helma.org |
+-----------+----------------+
fig.2 Three HopObjects representing the three
rows of the table.
These so-called type mappings are set-up in the file type.properties for each HopObject. We create such a file in the next step.


Up: Tutorial
Previous: Database Connection Next: "Wiring" The Prototype


Page last modified on 2005-10-17 20:44 by czv