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.

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

The Legend of Heroes: Trails of Cold Ste...
I adore game series that have connecting lore and stories, which of course means the Legend of Heroes is very dear to me, Trails lore has been building for two decades. Excitedly, the next stage is upon us as Userjoy has announced the upcoming... | Read more »
Go from lowly lizard to wicked Wyvern in...
Do you like questing, and do you like dragons? If not then boy is this not the announcement for you, as Loongcheer Game has unveiled Quest Dragon: Idle Mobile Game. Yes, it is amazing Square Enix hasn’t sued them for copyright infringement, but... | Read more »
Aether Gazer unveils Chapter 16 of its m...
After a bit of maintenance, Aether Gazer has released Chapter 16 of its main storyline, titled Night Parade of the Beasts. This big update brings a new character, a special outfit, some special limited-time events, and, of course, an engaging... | Read more »
Challenge those pesky wyverns to a dance...
After recently having you do battle against your foes by wildly flailing Hello Kitty and friends at them, GungHo Online has whipped out another surprising collaboration for Puzzle & Dragons. It is now time to beat your opponents by cha-cha... | Read more »
Pack a magnifying glass and practice you...
Somehow it has already been a year since Torchlight: Infinite launched, and XD Games is celebrating by blending in what sounds like a truly fantastic new update. Fans of Cthulhu rejoice, as Whispering Mist brings some horror elements, and tests... | Read more »
Summon your guild and prepare for war in...
Netmarble is making some pretty big moves with their latest update for Seven Knights Idle Adventure, with a bunch of interesting additions. Two new heroes enter the battle, there are events and bosses abound, and perhaps most interesting, a huge... | Read more »
Make the passage of time your plaything...
While some of us are still waiting for a chance to get our hands on Ash Prime - yes, don’t remind me I could currently buy him this month I’m barely hanging on - Digital Extremes has announced its next anticipated Prime Form for Warframe. Starting... | Read more »
If you can find it and fit through the d...
The holy trinity of amazing company names have come together, to release their equally amazing and adorable mobile game, Hamster Inn. Published by HyperBeard Games, and co-developed by Mum Not Proud and Little Sasquatch Studios, it's time to... | Read more »
Amikin Survival opens for pre-orders on...
Join me on the wonderful trip down the inspiration rabbit hole; much as Palworld seemingly “borrowed” many aspects from the hit Pokemon franchise, it is time for the heavily armed animal survival to also spawn some illegitimate children as Helio... | Read more »
PUBG Mobile teams up with global phenome...
Since launching in 2019, SpyxFamily has exploded to damn near catastrophic popularity, so it was only a matter of time before a mobile game snapped up a collaboration. Enter PUBG Mobile. Until May 12th, players will be able to collect a host of... | Read more »

Price Scanner via MacPrices.net

Apple is offering significant discounts on 16...
Apple has a full line of 16″ M3 Pro and M3 Max MacBook Pros available, Certified Refurbished, starting at $2119 and ranging up to $600 off MSRP. Each model features a new outer case, shipping is free... Read more
Apple HomePods on sale for $30-$50 off MSRP t...
Best Buy is offering a $30-$50 discount on Apple HomePods this weekend on their online store. The HomePod mini is on sale for $69.99, $30 off MSRP, while Best Buy has the full-size HomePod on sale... Read more
Limited-time sale: 13-inch M3 MacBook Airs fo...
Amazon has the base 13″ M3 MacBook Air (8GB/256GB) in stock and on sale for a limited time for $989 shipped. That’s $110 off MSRP, and it’s the lowest price we’ve seen so far for an M3-powered... Read more
13-inch M2 MacBook Airs in stock today at App...
Apple has 13″ M2 MacBook Airs available for only $849 today in their Certified Refurbished store. These are the cheapest M2-powered MacBooks for sale at Apple. Apple’s one-year warranty is included,... Read more
New today at Apple: Series 9 Watches availabl...
Apple is now offering Certified Refurbished Apple Watch Series 9 models on their online store for up to $80 off MSRP, starting at $339. Each Watch includes Apple’s standard one-year warranty, a new... Read more
The latest Apple iPhone deals from wireless c...
We’ve updated our iPhone Price Tracker with the latest carrier deals on Apple’s iPhone 15 family of smartphones as well as previous models including the iPhone 14, 13, 12, 11, and SE. Use our price... Read more
Boost Mobile will sell you an iPhone 11 for $...
Boost Mobile, an MVNO using AT&T and T-Mobile’s networks, is offering an iPhone 11 for $149.99 when purchased with their $40 Unlimited service plan (12GB of premium data). No trade-in is required... Read more
Free iPhone 15 plus Unlimited service for $60...
Boost Infinite, part of MVNO Boost Mobile using AT&T and T-Mobile’s networks, is offering a free 128GB iPhone 15 for $60 per month including their Unlimited service plan (30GB of premium data).... Read more
$300 off any new iPhone with service at Red P...
Red Pocket Mobile has new Apple iPhones on sale for $300 off MSRP when you switch and open up a new line of service. Red Pocket Mobile is a nationwide MVNO using all the major wireless carrier... Read more
Clearance 13-inch M1 MacBook Airs available a...
Apple has clearance 13″ M1 MacBook Airs, Certified Refurbished, available for $759 for 8-Core CPU/7-Core GPU/256GB models and $929 for 8-Core CPU/8-Core GPU/512GB models. Apple’s one-year warranty is... Read more

Jobs Board

Solutions Engineer - *Apple* - SHI (United...
**Job Summary** An Apple Solution Engineer's primary role is tosupport SHI customers in their efforts to select, deploy, and manage Apple operating systems and Read more
DMR Technician - *Apple* /iOS Systems - Haml...
…relevant point-of-need technology self-help aids are available as appropriate. ** Apple Systems Administration** **:** Develops solutions for supporting, deploying, Read more
Omnichannel Associate - *Apple* Blossom Mal...
Omnichannel Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Operations Associate - *Apple* Blossom Mall...
Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.