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

Top Mobile Game Discounts
Every day, we pick out a curated list of the best mobile discounts on the App Store and post them here. This list won't be comprehensive, but it every game on it is recommended. Feel free to check out the coverage we did on them in the links... | Read more »
Price of Glory unleashes its 1.4 Alpha u...
As much as we all probably dislike Maths as a subject, we do have to hand it to geometry for giving us the good old Hexgrid, home of some of the best strategy games. One such example, Price of Glory, has dropped its 1.4 Alpha update, stocked full... | Read more »
The SLC 2025 kicks off this month to cro...
Ever since the Solo Leveling: Arise Championship 2025 was announced, I have been looking forward to it. The promotional clip they released a month or two back showed crowds going absolutely nuts for the previous competitions, so imagine the... | Read more »
Dive into some early Magicpunk fun as Cr...
Excellent news for fans of steampunk and magic; the Precursor Test for Magicpunk MMORPG Crystal of Atlan opens today. This rather fancy way of saying beta test will remain open until March 5th and is available for PC - boo - and Android devices -... | Read more »
Prepare to get your mind melted as Evang...
If you are a fan of sci-fi shooters and incredibly weird, mind-bending anime series, then you are in for a treat, as Goddess of Victory: Nikke is gearing up for its second collaboration with Evangelion. We were also treated to an upcoming... | Read more »
Square Enix gives with one hand and slap...
We have something of a mixed bag coming over from Square Enix HQ today. Two of their mobile games are revelling in life with new events keeping them alive, whilst another has been thrown onto the ever-growing discard pile Square is building. I... | Read more »
Let the world burn as you have some fest...
It is time to leave the world burning once again as you take a much-needed break from that whole “hero” lark and enjoy some celebrations in Genshin Impact. Version 5.4, Moonlight Amidst Dreams, will see you in Inazuma to attend the Mikawa Flower... | Read more »
Full Moon Over the Abyssal Sea lands on...
Aether Gazer has announced its latest major update, and it is one of the loveliest event names I have ever heard. Full Moon Over the Abyssal Sea is an amazing name, and it comes loaded with two side stories, a new S-grade Modifier, and some fancy... | Read more »
Open your own eatery for all the forest...
Very important question; when you read the title Zoo Restaurant, do you also immediately think of running a restaurant in which you cook Zoo animals as the course? I will just assume yes. Anyway, come June 23rd we will all be able to start up our... | Read more »
Crystal of Atlan opens registration for...
Nuverse was prominently featured in the last month for all the wrong reasons with the USA TikTok debacle, but now it is putting all that behind it and preparing for the Crystal of Atlan beta test. Taking place between February 18th and March 5th,... | Read more »

Price Scanner via MacPrices.net

AT&T is offering a 65% discount on the ne...
AT&T is offering the new iPhone 16e for up to 65% off their monthly finance fee with 36-months of service. No trade-in is required. Discount is applied via monthly bill credits over the 36 month... Read more
Use this code to get a free iPhone 13 at Visi...
For a limited time, use code SWEETDEAL to get a free 128GB iPhone 13 Visible, Verizon’s low-cost wireless cell service, Visible. Deal is valid when you purchase the Visible+ annual plan. Free... Read more
M4 Mac minis on sale for $50-$80 off MSRP at...
B&H Photo has M4 Mac minis in stock and on sale right now for $50 to $80 off Apple’s MSRP, each including free 1-2 day shipping to most US addresses: – M4 Mac mini (16GB/256GB): $549, $50 off... Read more
Buy an iPhone 16 at Boost Mobile and get one...
Boost Mobile, an MVNO using AT&T and T-Mobile’s networks, is offering one year of free Unlimited service with the purchase of any iPhone 16. Purchase the iPhone at standard MSRP, and then choose... Read more
Get an iPhone 15 for only $299 at Boost Mobil...
Boost Mobile, an MVNO using AT&T and T-Mobile’s networks, is offering the 128GB iPhone 15 for $299.99 including service with their Unlimited Premium plan (50GB of premium data, $60/month), or $20... Read more
Unreal Mobile is offering $100 off any new iP...
Unreal Mobile, an MVNO using AT&T and T-Mobile’s networks, is offering a $100 discount on any new iPhone with service. This includes new iPhone 16 models as well as iPhone 15, 14, 13, and SE... Read more
Apple drops prices on clearance iPhone 14 mod...
With today’s introduction of the new iPhone 16e, Apple has discontinued the iPhone 14, 14 Pro, and SE. In response, Apple has dropped prices on unlocked, Certified Refurbished, iPhone 14 models to a... Read more
B&H has 16-inch M4 Max MacBook Pros on sa...
B&H Photo is offering a $360-$410 discount on new 16-inch MacBook Pros with M4 Max CPUs right now. B&H offers free 1-2 day shipping to most US addresses: – 16″ M4 Max MacBook Pro (36GB/1TB/... Read more
Amazon is offering a $100 discount on the M4...
Amazon has the M4 Pro Mac mini discounted $100 off MSRP right now. Shipping is free. Their price is the lowest currently available for this popular mini: – Mac mini M4 Pro (24GB/512GB): $1299, $100... Read more
B&H continues to offer $150-$220 discount...
B&H Photo has 14-inch M4 MacBook Pros on sale for $150-$220 off MSRP. B&H offers free 1-2 day shipping to most US addresses: – 14″ M4 MacBook Pro (16GB/512GB): $1449, $150 off MSRP – 14″ M4... Read more

Jobs Board

All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.