TweetFollow Us on Twitter

OpenBase

Volume Number: 14 (1998)
Issue Number: 4
Column Tag: Rhapsody

OpenBase

by Gene Backlin

A Solid Database Framework for Rhapsody

Introduction

OpenBase is a solid database framework which will address your data handling requirements for Rhapsody. Like Rhapsody, OpenBase's foundation is with NeXTSTEP. It has evolved through the years to provide a mature environment for stand alone users as well as over distributed networks. For the developer, OpenBase has a rich set of application APIs that incorporate the C and Objective-C languages. Regardless of developers programming background Mac OS or NeXTSTEP/OpenStep, the OpenBase API framework allows quick development of full scale database applications.

Overview

This article will illustrate:

  • Steps to build SimpleTool, an application that queries a "Movie" database, show just how simple is writing an OpenBase database application.
  • Help Desk, an application using OpenBaseAdvancedAPI to address multi-tiered database interaction over local area networks.
  • OpenBase Manager, OpenBase's data management and interactive tool.

SimpleTool

SimpleTool demonstrates interaction with a relational database interaction without using the tedious programming overhead common with databases. Using C or Objective-C is the simplest way to access OpenBase. SimpleTool will retrieve from the database the movies and the revenue from the producing studios. Listing 1 illustrates the OpenBase API framework. A discussion follows.

Listing 1: SimpleTool_main.m

#import <Foundation/Foundation.h>
#import <OpenBaseAPI/OpenBase.h>

int main (int argc, const char *argv[])
{
  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  int returnCode;
  OpenBase *connection = ob_newConnection();

  //variables to hold values
  char movieTitle[256];
  char studioName[256];
  long revenue;

  if (!ob_connectToDatabase
    (connection, "Movie", "*", "", "", &returnCode))
    {
    printf("%s\n", ob_connectErrorMessage(connection));
    return -1;
    }

  ob_makeCommand(connection,"select t0.TITLE, t0.REVENUE, 
    t1.NAME from MOVIE t0, STUDIO t1 where 
    t0.STUDIO_ID = t1.STUDIO_ID order by t0.REVENUE DESC");

  if (!ob_executeCommand(connection))
    {
    printf("ERROR - %s\n",ob_serverMessage(connection));
    ob_invalidate(connection);
    return -1;
    }

  ob_bindString(connection, movieTitle);
  ob_bindLong(connection, &revenue);
  ob_bindString(connection, studioName);

  while (ob_nextRow(connection)) 
    {
    printf("%s made $%ld for %s.\n",movieTitle, revenue, 
      studioName);
    }

  ob_invalidate(connection);
  [pool release];
  exit(0);
  return 0;
}

Main begins by establishing a connection to the database, if a connection was not made, print the offending message returned from the connection object and exit. Using the ob_connectToDatabase() function, establish a connection to the database with the database name, hostname, logon id and password. Note the argument "*". The database connection is made directly to the local machine on a standalone computer, but will poll all hosts on a local area network. This is an example of OpenBase's scaleability.

  int returnCode;
  OpenBase *connection = ob_newConnection();
  // ...
  if (!ob_connectToDatabase(connection, "Movie", "*", "", "", 
    &returnCode))
    {
    printf("%s\n", ob_connectErrorMessage(connection));
    return -1;
    }

After a successful connection has been established, the ob_makeCommand() function is used to send SQL statements. The TITLE and REVENUE data columns from the MOVIE table as well as the associated studio NAME from the STUDIO table are retrieved. The SQL statements are now buffered for later execution by the database server.

  ob_makeCommand(connection,"select t0.TITLE, t0.REVENUE,
  t1.NAME from MOVIE t0, STUDIO t1 where t0.STUDIO_ID =
  t1.STUDIO_ID order by t0.REVENUE DESC");

The ob_executeCommand() passes the buffered SQL statements to the database server and returns TRUE for successful and FALSE for failed execution.

  if (!ob_executeCommand(connection))
    {
    printf("ERROR - %s\n",ob_serverMessage(connection));
    ob_invalidate(connection);
    return -1;
    }

The ob_bindString() and ob_bindLong() functions, bind the resulting data columns from the database, to the receiving program variables. SimpleTool binds the variables movieTitle, revenue and studioName respective to the order of the initial SELECT statement.

  ob_bindString(connection, movieTitle);
  ob_bindLong(connection, &revenue);
  ob_bindString(connection, studioName);

ob_nextRow() increments through the result rows and retrieves the data. FALSE is returned when all data is processed.

  while (ob_nextRow(connection)) 
    {
    printf("%s made $%ld for %s.\n",movieTitle, revenue, 
      studioName);
    }

Main ends with a call to terminate the connection to the database server.

  ob_invalidate(connection);

Help Desk

Help Desk, addresses multi-tiered database requirements by directly connecting to the user interface through the OpenBaseAdvancedAPI as seen in Figure 1.

Figure 1. Help Desk Manager.

Designing the Interface

The Apple supplied tool Interface Builder is used to design the user interface. Information on Interface Builder is detailed at http://devworld.apple.com/techinfo/techdocs/rhapsody/apple.com. See Figure 2 for a screen shot of a connection being performed using Interface Builder.

Figure 2. Making the Interface Builder Object Connection.

Managing the Interface and Database Relationships

Two FormManagers and one ReadTableManager are created. The first FormManager lists customer questions and the other displays who asked the question. The ReadTableManager manages a picklist of information.

  tableManager = [[ReadTableManager alloc] init];
  formManager = [[FormManager alloc] init];
  contactsFormManager = [[FormManager alloc] init];

To set the key attribute and table, each object must be initialized.

  [tableManager setKeyAttribute:@"support._rowid"];
  [tableManager setTableName:@"support"];

  [formManager setKeyAttribute:@"support._rowid"];
  [formManager setTableName:@"support"];

  [contactsFormManager setKeyAttribute:@"contacts._rowid"];
  [contactsFormManager setTableName:@"contacts"];

Connect the interface objects; tableManager, formManager and contactsFormManager to the database.

  [tableManager setConnection:connection];
  [formManager setConnection:connection];
  [contactsFormManager setConnection:connection];

Set specific query ordering. In this example "ASC" is ascending.

  [tableManager setOrderBy:@" ORDER BY
    support.shortQuestion ASC"];

Bind the screen objects to the database columns.

#define FIELD(outlet) [OutletManager newForOutlet:outlet]
#define TEXT(outlet) [OutletTextManager newForOutlet:outlet]
#define POPUP(outlet) [OutletPopUpManager   \
                      newForOutlet:outlet]

[formManager addOutlet:FIELD(shortQuestion) 
      withColumnName:@"support.shortQuestion"];
[formManager addOutlet:FIELD(product) 
      withColumnName:@"support.product"];
[formManager addOutlet:TEXT(textQuestion) 
      withColumnName:@"support.question"];
[formManager addOutlet:TEXT(textAnswer) 
      withColumnName:@"support.answer"];
[formManager addOutlet:FIELD(dateCreated) 
      withColumnName:@"support.dateCreated"];
[formManager addOutlet:POPUP(answered) 
      withColumnName:@"support.answered"];

Set up the Contacts Form to be a target of the FormManager.

[contactsFormManager addOutlet:FIELD(firstname) 
      withColumnName:@"contacts.firstname"];
[contactsFormManager addOutlet:FIELD(lastname) 
      withColumnName:@"contacts.lastname"];
[contactsFormManager addOutlet:FIELD(email) 
      withColumnName:@"contacts.email"];

Add each column to initialize the table.

[tableManager addColumn:@"support.product" 
    title:@"Product"];
[tableManager addColumn:@"support.answered" 
    title:@"Answered"];
[tableManager addColumn:@"support.shortQuestion" 
    title:@"Summary"];

Initialize the windowTableView object, to display the query results.

[tableManager setTableView:windowTableView];

Establishing Database Relationships

The formManager will display related details when a selection is made in the tableManager. To accomplish this, a target relationship must be made between the tableManager and formManager.

[tableManager addTarget:formManager
    withValue:@"support._rowid"];

The contactsFormManager displays the contacts through the contacts_id key.

[formManager addOutlet:contactsFormManager
    withColumnName:@"support.contacts_id"];

The formManager sets the SQL "WHERE" constraints as well as subqueries.

[tableManager fetchData:[formManager whereConstraints]];

Insulation from Direct SQL

OpenBase's OpenBaseAdvancedAPI, completely insulates you from SQL commands like SEARCH, RESET, SAVE and DELETE, by the following methods.

- (void)findAction:sender
{
  [tableManager fetchData:[formManager whereConstraints]];
}

- (void)resetAction:sender
{
  [tableManager resetAction:self];
}

- (void)saveAction:sender
{
  [formManager saveChanges];
}

- (void)deleteAction:sender
{
  [tableManager deleteAction:self];
}

The OpenBase Manager

In addition to the developer API frameworks, OpenBase like Rhapsody, designed graphical tools to simplify tasks. OpenBase Manager simplifies the following:

  • Managing Database servers across local area networks
  • Viewing Databases
  • Editing Database schemas
  • Managing Database security

OpenBase Interactive Database Toolset

The following screen shots display OpenBase's rich set of tools.

Figure 3. OpenBase Database Manager.

Figure 4. User Administration.

Figure 5. Permission Administration.

Figure 6. Database Table Administration.

User Comments

Sirius Connections, a leading provider of internet services for the San Francisco area, uses OpenBase for billing and maintaining historical records on 15,000 customers. "Our whole operation is built on OpenBase technology, " says Andreas Glocker, CEO of Sirius Connections, "Automating our business on OpenBase has made all the difference. It has given us the competitive advantage."

"One of our programmers wrote a system using the OpenBase API in less than a day. Doing the same thing using Oracle OCI's took more than three," says Kevin Ford, President of ComputerActive located in Ontario Canada, "OpenBase demonstrates a level of quality and robustness rarely seen in the software world."

Robert L. Peek, founder of the Peek Financial Group, says, "We have adopted OpenBase as an enterprise wide solution for our firm. We have found it to be an industrial strength database with excellent support."

Contact Information

OpenBase supports ODBC for Mac OS and Windows and has a native JDBC driver. For further information about OpenBase and how you can get a FREE single-user runtime, you can contact:

OpenBase International, Ltd
58 Greenfield Road
Francestown, NH 03043
Tel: 603-547-8404 -- Fax: 603-547-2423
e-mail: info@openbase.com
internet: http://www.openbase.com


Gene Backlin, gbacklin@MariZack.com, has been programming since 1978, and is owner and principal consultant of MariZack Consulting, formed in 1991 with one purpose -- to help. He has been helping clients such as IBM, McDonnell Douglas, Waste Management Inc., the U.S. Environmental Protection Agency, AT&T, Ameritech, Discover Card, Rockwell International, Bank of America and Nations Bank. He also helps local universities in the area of education and is author of the book "Developing NeXTSTEP Applications" ISBN 0-672-30658-1 published by SAM's Publishing.

 
AAPL
$565.32
Apple Inc.
+0.00
MSFT
$29.07
Microsoft Corpora
+0.00
GOOG
$603.66
Google Inc.
+0.00
MacTech Search:
Community Search:

Empire of the Eclipse Review
Empire of the Eclipse Review By Carter Dotson on May 24th, 2012 Our Rating: :: OVERSHADOWINGiPhone App - Designed for the iPhone, compatible with the iPad Empire of the Eclipse is an ambitious strategy MMO that is very deep, and... | Read more »
Bejeweled HD Review
Bejeweled HD Review By Jennifer Allen on May 24th, 2012 Our Rating: :: ADDICTIVEiPad Only App - Designed for the iPad The iPad version of the ever addictive Match Three title.   Developer: PopCap Price: $3.99 Version Reviewed: 1... | Read more »
Facebook Releases New Camera App To Stre...
While not a replacement for Instagram, Facebook Camera is a good first step in this month+ old union of the two companies. Released today, Facebook camera looks to streamline the viewing of photos and the uploading of them. The app allows you to... | Read more »
Missile Monkey Review
Missile Monkey Review By Lisa Caplan on May 24th, 2012 Our Rating: :: FLYING LOWUniversal App - Designed for iPhone and iPad Missile Monkey is a must miss   Developer: Munsey Clan Games Price: $0.99 Version Reviewed: 1.0 Device... | Read more »
Boomlings Review
Boomlings Review By Lisa Caplan on May 24th, 2012 Our Rating: :: FUN FREEBIEUniversal App - Designed for iPhone and iPad Boomlings is a traditional matching puzzle game, with some explosive twists   | Read more »
Dave vs Cave Review
Dave vs Cave Review By Jason Wadsworth on May 24th, 2012 Our Rating: :: WATCH FOR FALLING ROCKSUniversal App - Designed for iPhone and iPad Kid falls down hole, kid gets trapped in cave, kid fights evil rock monsters to escape... | Read more »
Python Pocket Power: Python Bytes 3 – Mo...
Python fans are certain to welcome the best bits from the penultimate season of the BBC sketch comedy in a new iPhone app: Python Bytes 3 – Monty Python Series 3. If you have a flair for the obvious, you’ll correctly assume this is third in a series... | Read more »

Price Scanner via MacPrices.net

13″ 2.8GHz MacBook Pro on sale for $100 off MSRP
Adorama has lowered their price on the 13″ 2.8GHz MacBook Pro to $1399 including free shipping plus NY/NJ sales tax only. Their price is $100 off MSRP, and it’s the lowest price for this model from... Read more
Apple refurbished iPads available starting at $279
 The Apple Store Online has dropped prices on Apple Certified Refurbished iPad 2s and original iPads by as much as $50, with models now starting at $279. Apple’s one-year warranty is included with... Read more
Security Based Portable Operating System, Pocket D...
In conjunction with their consumer technology product, Pocket Desktop, a USB device that offers consumers enhanced security and portability in computing, has announced a new strategic alliance with... Read more
Apple’s Jonathan Ive Knighted By Britain’s Princes...
The BBC reports that Apple Senior Vice President Of Industrial Design Jonathan Ive is now Sir Jonathan Ive, having been knighted by Queen Elizabeth II’s daughter Anne, the Princess Royal (and an iPad... Read more
Microsoft Fixing to release Office for iOS and And...
BGR’s Jonathan S. Geller says BGR has learned from a “reliable source” that Microsoft is planning to release the company’s full Office suite for not only Apple’s iPad, but for Android tablets as well... Read more
Mac mini Server available for $949, $50 off MSRP
Adorama has Mac mini Servers on sale for $949 including free shipping. Their price is $50 off MSRP, and it’s the lowest price available for this model from any Apple Authorized Reseller. NY and NJ... Read more
21″ 2.7GHz iMac on sale for $1399, $100 off full r...
Adorama has the 21″ 2.7GHz iMac on sale for $1399 including free shipping. Their price is $100 off MSRP, and it’s the lowest price for this model from any Apple Authorized Reseller. NY and NJ sales... Read more
iMacs on sale bundled with free upgrade to 8GB RAM
MacConnection has 2011 iMacs in stock today with a free upgrade to 8GB of RAM. Shipping is also free. Their prices represent a $200+ savings over custom 8GB iMacs at The Apple Store: - 21″ 2.5GHz... Read more

Jobs Board

iPhone Mobile Developer at Mapmyfitness...
About MapMyFitness, Inc.: We're a well-funded and fast growing start-up. We're building the future of fitness applications on both the web and mobile. MapMyFitness is consistently ranked among the... Read more
Civil Engineering iPhone/iPad Applicatio...
I want to hire an application developer to design a universal iPhone/iPad application. The app is a calculator for civil engineers. Please see the attached Scope of Work. Desired Skills: iPhone, iPad... Read more
Helpdesk Support Technician - Mac Expert...
Mac hardwaresoftware preferably as a Mac Genius or Apple technician Demonstrated ability to troubleshoot ... in Mac OS X/Windows OS administration, exp supporting Mac, certified Apple and/or Windows... Read more
Mac Expert - Apple Online Store at Apple...
before calling a helpdesk for assistance). Description The Mac Expert is responsible for providing consultative ... to be effective, the Mac Expert will be knowledgeable about Mac product features... Read more
iOS Developer (iPhone and iPad) at Mahal...
Mahalo is looking for talented iOS developers to join its team of highly skilled engineers. Weve already released multiple successful apps in the Apple App Store with well over a million installs... Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.