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
$100.96
Apple Inc.
-0.83
MSFT
$47.52
Microsoft Corpora
+0.84
GOOG
$596.08
Google Inc.
+6.81

MacTech Search:
Community Search:

Software Updates via MacUpdate

Chromium 37.0.2062.122 - Fast and stable...
Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all Internet users to experience the web. FreeSMUG-Free OpenSource Mac User Group build is... Read more
Attachment Tamer 3.1.14b9 - Take control...
Attachment Tamer gives you control over attachment handling in Apple Mail. It fixes the most annoying Apple Mail flaws, ensures compatibility with other email software, and allows you to set up how... Read more
Duplicate Annihilator 5.0 - Find and del...
Duplicate Annihilator takes on the time-consuming task of comparing the images in your iPhoto library using effective algorithms to make sure that no duplicate escapes. Duplicate Annihilator detects... Read more
jAlbum Pro 12.2 - Organize your digital...
jAlbum Pro has all the features you love in jAlbum, but comes with a commercial license. With jAlbum, you can create gorgeous custom photo galleries for the Web without writing a line of code!... Read more
jAlbum 12.2 - Create custom photo galler...
With jAlbum, you can create gorgeous custom photo galleries for the Web without writing a line of code! Beginner-friendly, with pro results Simply drag and drop photos into groups, choose a design... Read more
Quicken 2015 2.0.4 - Complete personal f...
Quicken 2015 helps you manage all your personal finances in one place, so you can see where you're spending and where you can save. Quicken automatically categorizes your financial transactions,... Read more
iMazing 1.0 - Complete iOS device manage...
iMazing (formerly DiskAid) is the ultimate iOS device manager with capabilities far beyond what iTunes offers. With iMazing and your iOS device (iPhone, iPad, or iPod), you can: Copy music to and... Read more
Xcode 6.0.1 - Integrated development env...
Apple Xcode is Apple Computer's integrated development environment (IDE) for OS X. The full Xcode package is free to ADC members and includes all the tools you need to create, debug, and optimize... Read more
Apple Safari 7.1 - Apple's Web brow...
Apple Safari in OS X Mavericks brings you all-new ways to find and enjoy the best of the web. It works with iCloud to give you a seamless browsing experience across all your devices. It looks out for... Read more
Delivery Status 6.1.2 - Check delivery s...
Delivery Status displays delivery status of packages for a variety of shipment services. Can't wait for your packages to arrive? Don't waste your time checking the site constantly, just open this all... Read more

Latest Forum Discussions

See All

View Source – HTML, JavaScript and CSS...
View Source – HTML, JavaScript and CSS 1.0 Device: iOS Universal Category: Utilities Price: $.99, Version: 1.0 (iTunes) Description: View Source is an app plus an iOS 8 Safari extension that makes it easy to do one key web developer... | Read more »
Avenged Sevenfold’s Hail To The King: De...
Avenged Sevenfold’s Hail To The King: Deathbat is Coming to iOS on October 16th Posted by Jessica Fisher on September 19th, 2014 [ permalink ] Just in time for Halloween, on October 16 Avenged Sevenfold will be launching | Read more »
Talisman Has Gone Universal – Can Now be...
Talisman Has Gone Universal – Can Now be Played on the iPhone Posted by Jessica Fisher on September 19th, 2014 [ permalink ] | Read more »
Tap Army Review
Tap Army Review By Jennifer Allen on September 19th, 2014 Our Rating: :: SHOOT EM ALLUniversal App - Designed for iPhone and iPad Mindless but fun, Tap Army is a lane-based shooter that should help you relieve some stress.   | Read more »
Monsters! Volcanoes! Loot! Epic Island f...
Monsters! Volcanoes! Loot! | Read more »
Plunder Pirates: Tips, Tricks, Strategie...
Ahoy There, Seadogs: Interested in knowing our thoughts on all this plundering and pirating? Check out our Plunder Pirates Review! Have you just downloaded the rather enjoyable pirate-em-up Plunder Pirates and are in need of some assistance? Never... | Read more »
Goat Simulator Review
Goat Simulator Review By Lee Hamlet on September 19th, 2014 Our Rating: :: THE GRUFFEST OF BILLY GOATSUniversal App - Designed for iPhone and iPad Unleash chaos as a grumpy goat in this humorous but short-lived casual game.   | Read more »
A New and Improved Wunderlist is Here fo...
A New and Improved Wunderlist is Here for iOS 8 Posted by Jessica Fisher on September 19th, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
Evernote Update for iOS 8 Adds Web Clipp...
Evernote Update for iOS 8 Adds Web Clipping, Quick Notes, and More Posted by Ellis Spice on September 19th, 2014 [ permalink ] | Read more »
Apple Names Ultimate Productivity Bundl...
Apple Names Ultimate Productivity Bundle by Readdle as the Essential Bundle on the App Store Posted by Jessica Fisher on September 19th, 2014 [ permalink | Read more »

Price Scanner via MacPrices.net

Mac Pros available for up to $260 off MSRP
Adorama has Mac Pros on sale for up to $260 off MSRP. Shipping is free, and Adorama charges sales tax in NY & NJ only: - 4-core Mac Pro: $2839.99, $160 off MSRP - 6-core Mac Pro: $3739.99, $260... Read more
13-inch 2.6GHz/256GB Retina MacBook Pros avai...
B&H Photo has the 13″ 2.6GHz/256GB Retina MacBook Pro on sale for $1379 including free shipping plus NY sales tax only. Their price is $120 off MSRP. Read more
Previous-generation 15-inch 2.0GHz Retina Mac...
B&H Photo has leftover previous-generation 15″ 2.0GHz Retina MacBook Pros now available for $1599 including free shipping plus NY sales tax only. Their price is $400 off original MSRP. B&H... Read more
21″ 2.7GHz iMac available for $1179, save $12...
Adorama has 21″ 2.7GHz Hawell iMacs on sale for $1179.99 including free shipping. Their price is $120 off MSRP. NY and NJ sales tax only. Read more
iOS 8 Adoption Rate Slower than iOS 7, 6, Hit...
Apple began pushing out iOS 8 updates to eligible devices around 1pm ET on September 17, 2014. However, unlike with iOS 7, which boasted a wide variety of differences from its predecessor iOS 6, in... Read more
LIkely Final Definitive OS X 10.9.5 Mavericks...
Apple has released what will almost certainly be the last incremental version number update of OS X 10.9 Mavericks (save for futire security updates) before OS X 10.10 Yosemite is released next month... Read more
Fingerprints, Apple Pay and Identity Theft Wa...
On Sep 9th, CEO Tim Cook unveiled Apple Pay, along with the new iPhone 6 and iWatch. Apple Pay is a newly developed technology that utilizes a near field communication (NFC) to enable customer... Read more
Amazon Introduces Two All-New Kindles
Amazon on Thursday introduced the 7th generation of its Kindle dedicated e-reader device: Kindle Voyage, its top-of-the-line e-reader, and the new $79 Kindle, with a 20% faster processor, twice the... Read more
Save up to $300 on the price of a new Mac wit...
Purchase a new Mac or iPad at The Apple Store for Education and take up to $300 off MSRP. All teachers, students, and staff of any educational institution qualify for the discount. Shipping is free,... Read more
13-inch 2.8GHz Retina MacBook Pro available f...
B&H Photo has the new 2014 13″ 2.8GHz Retina MacBook Pro on sale for $1699.99 including free shipping plus NY sales tax only. They’ll also include free copies of Parallels Desktop and LoJack for... Read more

Jobs Board

Project Manager, *Apple* Financial Services...
**Job Summary** Apple Financial Services (AFS) offers consumers, businesses and educational institutions ways to finance Apple purchases. We work with national and Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.