Article Preview
Buy Now
| Print: | |
| PDF: |
Databases for Real
Simple Object Relational Mapping
Working with relational databases.
Issue: 2.4 (March/April 2004)
Author: Paul Lefebvre
Author Bio: Paul Lefebvre is President and Chief Software Architect of LogicalVue Software, producers of SQLVue, Schema and other products.
Article Description: No description available.
Article Length (in bytes): 4,086
Starting Page Number: 37
RBD Number: 2418
Resource File(s):
2418.sit Updated: Monday, March 15, 2004 at 1:00 AM
Related Link(s): None
Known Limitations: None
Excerpt of article text...
Sometimes it can be annoying to deal with the database in a relational format; it continually requires you to write SQL. SQL is powerful, but it is not object-oriented and is sometimes difficult for people to grasp. An alternative way to access the database is to map the data to classes and then interact with the classes. The classes contain (and hide) any SQL that is used.
Two benefits for using a design such as this are:
1. We only need to connect to the database when needed.
2. The SQL is isolated in the mapping classes making your main code more readable and minimizing the changes needed should the database change.
Softball Again
Let's go back to the softball example we used in past columns. We will map each of the tables to a class. The softball example has three tables: team, game, and location. We'll start off by mapping team. Start by creating a new REALbasic project.
Team Mapping
The first step is to create a class which we'll call team. Each instance of this class will contain one row of data. The individual columns will be contained in properties of the class, so we'll need to create public properties for each column in team:
...End of Excerpt. Please purchase the magazine to read the full article.
Article copyrighted by REALbasic Developer magazine. All rights reserved.
|










