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
$524.94
Apple Inc.
+5.93
MSFT
$40.01
Microsoft Corpora
-0.39
GOOG
$536.10
Google Inc.
-20.44

MacTech Search:
Community Search:

Software Updates via MacUpdate

Mac DVDRipper Pro 4.1.7 - Copy, backup,...
Mac DVDRipper Pro is the DVD backup solution that lets you protect your DVDs from scratches, save your batteries by reading your movies from your hard disk, manage your collection with just a few... Read more
PDFpenPro 6.2 - Advanced PDF toolkit for...
PDFpenPro allows users to edit PDF's easily. Add text, images and signatures. Fill out PDF forms. Merge or split PDF documents. Reorder and delete pages. Even correct text and edit graphics! Create... Read more
PDFpen 6.2 - Edit and annotate PDFs with...
PDFpen allows users to easily edit PDF's. Add text, images and signatures. Fill out PDF forms. Merge or split PDF documents. Reorder and delete pages. Even correct text and edit graphics! Features... Read more
Monolingual 1.5.9 - Remove unwanted OS X...
Monolingual is a program for removing unnecesary language resources from OS X, in order to reclaim several hundred megabytes of disk space. It requires a 64-bit capable Intel-based Mac and at least... Read more
Maya 2015 - Professional 3D modeling and...
Maya is an award-winning software and powerful, integrated 3D modeling, animation, visual effects, and rendering solution. Because Maya is based on an open architecture, all your work can be scripted... Read more
Starcraft II: Wings of Liberty 1.1.1.180...
Download the patch by launching the Starcraft II game and downloading it through the Battle.net connection within the app. Starcraft II: Wings of Liberty is a strategy game played in real-time. You... Read more
Sibelius 7.5.0 - Music notation solution...
Sibelius is the world's best-selling music notation software for Mac. It is as intuitive to use as a pen, yet so powerful that it does most things in less than the blink of an eye. The demo includes... Read more
Typinator 5.9 - Speedy and reliable text...
Typinator turbo-charges your typing productivity. Type a little. Typinator does the rest. We've all faced projects that require repetitive typing tasks. With Typinator, you can store commonly used... Read more
MYStuff Pro 2.0.16 - Create inventories...
MYStuff Pro is the most flexible way to create detail-rich inventories for your home or small business. Add items to MYStuff by dragging and dropping existing information, uploading new images, or... Read more
TurboTax 2013.r17.002 - Manage your 2013...
TurboTax guides you through your tax return step by step, does all the calculations, and checks your return for errors and overlooked deductions. It lets you file your return electronically to get... Read more

Latest Forum Discussions

See All

Where's My Water? Featuring XYY (G...
Where's My Water? Featuring XYY 1.0 Device: iOS Universal Category: Games Price: $.99, Version: 1.0 (iTunes) Description: iPod Touch 4th Gen, iPhone 3GS or iPad 1 are not compatible with this app. | Read more »
The Amazing Spider-Man 2 (Games)
The Amazing Spider-Man 2 1.0.0 Device: iOS Universal Category: Games Price: $4.99, Version: 1.0.0 (iTunes) Description: *IMPORTANT* The Amazing Spider-Man 2 requires an iPad 2 (or newer), iPhone 4s (or newer), or iPod touch 5th... | Read more »
Living Planet - Tiny Planet Videos and P...
Living Planet - Tiny Planet Videos and Photos 1.0 Device: iOS Universal Category: Photography Price: $.99, Version: 1.0 (iTunes) Description: 50% OFF LAUNCH SPECIAL! BUY NOW BEFORE THE PRICE GOES UP... | Read more »
Livescribe 3 Smartpen Review
Made by: Livescribe Price: $149.99 for Livescribe 3 Hardware/iOS Integration Rating: 4.5 out of 5 stars Usability Rating: 4 out of 5 stars Reuse Value Rating: 4.75 out of 5 stars Build Quality Rating: 4.5 out of 5 stars Overall Rating: 4.44 out of... | Read more »
Unpossible Review
Unpossible Review By Carter Dotson on April 17th, 2014 Our Rating: :: RALPH WIGGUM APPROVESUniversal App - Designed for iPhone and iPad Unpossible is much better than its English!   | Read more »
Hitman GO Review
Hitman GO Review By Carter Dotson on April 17th, 2014 Our Rating: :: GO HITMAN, GO!Universal App - Designed for iPhone and iPad Hitman GO is not the obvious way to do a mobile version of the Hitman series, but it’s an incredibly... | Read more »
Monster High Ghouls and Jewels is a Frea...
Monster High Ghouls and Jewels is a Freaky Fashion-Forward Match-3 Puzzler Posted by Rob Rich on April 17th, 2014 [ permalink ] | Read more »
Dinosaur Train A to Z Review
Dinosaur Train A to Z Review By Amy Solomon on April 17th, 2014 Our Rating: :: DINO DETAILSUniversal App - Designed for iPhone and iPad Dinosaur Train A to Z is an educational app about dinosaurs that includes In-App Purchases... | Read more »
Easter Comes to Junk Jack X – Bringing N...
Easter Comes to Junk Jack X – Bringing New Crafts, Chemistry, and More Posted by Rob Rich on April 17th, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
Call of Cookie Review
Call of Cookie Review By Jordan Minor on April 17th, 2014 Our Rating: :: COOKIE CRUMBLESUniversal App - Designed for iPhone and iPad Call of Cookie proves that plants aren’t the only fighting foods out there.   | Read more »

Price Scanner via MacPrices.net

Apple restocks refurbished Mac minis starting...
The Apple Store has restocked Apple Certified Refurbished Mac minis for up to $150 off the cost of new models. Apple’s one-year warranty is included with each mini, and shipping is free: - 2.5GHz Mac... Read more
Hyundai Brings Apple CarPlay To The 2015 Sona...
Hyundai Motor America has announced it will bring Apple CarPlay functionality to the 2015 Sonata. CarPlay is pitched as a smarter, safer and easier way to use iPhone in the car and gives iPhone users... Read more
Updated iPads Coming Sooner Than We Had Thoug...
MacRumors, cites KGI securities analyst Ming Chi Kuo, well-respected as an Apple product prognisticator, saying that Apple will introduce an upgraded iPad Air and iPad mini in 2014/Q3, meaning the... Read more
Toshiba Unveils New High And Low End Laptop M...
Toshiba has announced new laptop models covering both the high-end and low-end of the notebook computer spectrum. Toshiba 4K Ultra HD Laptop Toshiba’s new Satellite P55t features one of the world’s... Read more
Save up to $270 with Apple refurbished 13-inc...
The Apple Store has Apple Certified Refurbished October 2013 13″ Retina MacBook Pros available starting at $1099, with models up to $270 off MSRP. Apple’s one-year warranty is standard, and shipping... Read more
Apple now offering refurbished iPad mini with...
The Apple Store has Certified Refurbished 2nd generation iPad minis with Retina Displays now available starting at $339. Apple’s one-year warranty is included with each model, and shipping is free.... Read more
Microsoft Blinks – Drops Microsoft Office 365...
Microsoft has dropped the annual subscription fee for Microsoft Office 365 Personal – which is needed in order to create and edit documents in Microsoft Office for iPad. However, Apple’s iOS and OS X... Read more
New AVG Vault Apps for iOS and Android Help K...
AVG Technologies N.V. an online security company for 177 million active users, has announced the launch of its latest mobile application, AVG Vault. The free app introduces an innovative user... Read more
Free Local Carrot iPhone App Helps Find Fresh...
I love fresh vegetables. I’m not a vegan, although I was for several years in the 1980s, but fresh vegetables and other whole foods are still my dietary mainstays as a matter of taste rather than... Read more
CarSO Pro – Car Service and Finance Manager/O...
Lviv, Ukraine-based BM-Studios’ CarSO Pro is a tool to manage operations concerning your car. Never forget to change the oil or prolong the insurance for your car. Remember when you’ve done the car... Read more

Jobs Board

*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
*Apple* Retail - Manager - Holyoke - Apple I...
Job Summary Keeping an Apple Store thriving requires a diverse set of leadership skills, and as a Manager, you’re a master of them all. In the store’s fast-paced, Read more
*Apple* Retail - Manager - Apple (United Sta...
Job SummaryKeeping an Apple Store thriving requires a diverse set of leadership skills, and as a Manager, you're a master of them all. In the store's fast-paced, dynamic Read more
*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
*Apple* Retail - Market Leader - Cincinnati...
…challenges of developing individuals, building teams, and affecting growth across Apple Stores. You demonstrate successful leadership ability - focusing on excellence Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.