DBMS, September 1997
DBMS Online: SQL for Smarties By Joe Celko

Underwhelmed by New Technology

Joe Isn't Too Impressed With What's Out There.

You will remember that last month I was on my "World Tour" to Brazil and California. I got back to Atlanta on May 19 at 7:05 a.m. and life went on. I had a little time to catch up on my email and snail mail, do laundry, help my wife prepare for final exams, and barely get ready for Spring COMDEX on June 2-5, 1997. This was the last COMDEX show to be held in Atlanta, which lost the show for a combination of factors: lack of exhibit space in Atlanta hotels; bad timing with other computer trade shows; and the fact that COMDEX was here for Freaknik (spring break for college students) two years ago and never forgave us.

Frankly, I found nothing really innovative and exciting at this year's show. Announcements were being held off until PC Expo or other shows, so attendance was low. Someone else described it as the same stuff as last year, but this year the software worked.

COMDEX was followed by E3, the entertainment and educational computing show. Those people are very different from database people. I have fantasies about blowing holes in some of my users, but these folks get to write programs in which the death of a user is the whole idea of the system. Furthermore, they have more vaporware and hype than even the database market would tolerate.

Oracle8

Speaking of being underwhelmed, I cannot get enthusiastic about Oracle8. It is missing some key pieces. There is no Java support, the object-relation extensions are too weak, Sedona (Oracle's application development platform) is not there and might never be, and Oracle has not added missing SQL-92 features I was hoping to find, such as scalar subquery expressions and proper outer-join syntax. Instead of what I wanted to see in the product, I got a white paper on its partitioning feature. Partitioned tables are limited to strictly relational datatypes -- no object types, varrays (variable-size arrays), or nested tables are allowed.

Rich Finkelstein, president of Performance Computing Inc. and one of the few people in the trade press who is more critical than I am, said, "In a sense, Oracle was playing catch-up. IBM's DB2 already has sophisticated partitioning, monitoring, security, administration capabilities, recovery, and reliability. I can't say that Oracle has overcome IBM in these areas, but they are now directly competitive" (CommunicationsWeek, June 16, 1997.)

Oracle8 was also supposed to be the data warehousing and VLDB product, but, again, it is playing catch-up. Informix has Wal-Mart and Kmart, while UPS and Telstra in Australia are on DB2. Oracle claims that Oracle8 can support 10,000 users. But DB2 has actually supported 64,000 concurrent, active users, so even the promises look weaker than the competition.

My editor-in-chief said that I was too one-sided and should find something nice to say about the product. I tried and failed. Nobody hates it, but nobody is enthusiastic either. I asked Mike Ault (73564.544.@compuserve.com), a known Oracle expert and author, what he thought. To quote, "Oracle8 is a great idea waiting for fulfillment. I like the new nested tables, index-only tables, varray and typing, but the limitations on their use make them hard to use fully. I particularly don't like the way nested tables are implemented, no capability to properly define storage or location, difficulty indexing, etc. Varrays take from six to 25 times the amount of storage that packing the same entries into a secondary table and using a relation would take, so why use them?"

Oracle8 has a new Star Query Optimizer and parallel processing abilities to support data warehousing, but their other optimizers have been so weak that I just don't trust these features in a VLDB. Even Oracle itself was telling people in the training sessions that version 8 has poor performance that will be fixed in the later decimal point releases of the product.

A third underwhelming announcement was about Bill Gates' "Scalability Week" show, which was not well-received by the trade press. Basically, Chairman Bill went on the road, made a speech, showed some testimonials, and did a simulation with multitudes of virtual users in the same room. It was not that long ago that Mr. Gates was bad mouthing the importance of scalability and now Microsoft is trying to claim it has it. Here's a replay of Microsoft's Internet strategy: "Wait for me! I'm the leader!"

Financial Databases and the Internet

More than one in five Americans are already connected to the Internet. This should provide U.S. companies with a huge home market where products and services can be sold. Likewise, with only one percent of Europeans connected, there should be little incentive for European companies to move toward e-commerce. Yet we seem to be lagging behind Europe in many respects.

At the start of June 1997, IBM and PBS launched the first European Secure Electronic Transaction (SET) Utility. This PBS is a Danish provider of secure payment processing services in Denmark and Europe, not the Public Broadcasting System. SET was jointly developed by Visa and Mastercard in February 1996 as an open standard for credit card payments over the Internet, and provides enhanced security for the cardholder and reduces fraud. IBM was the first company with a comprehensive suite of secure end-to-end electronic commerce solutions under the name CommercePOINT. PBS already had considerable experience in working with SET by processing the first SET payment in the world last year and the first cross-border SET payment in April 1997. (For more information on SET, see Kurt Indemaur's article, "The SET Protocol," on page 91.)

The SET utility service will enable financial institutions to offer their merchants and credit card holders multiple card, secure, and international credit card payments over the Internet. The payment gateway service will be available to any bank and will provide a collection and routing point for all SET transactions captured by their merchants. Banks will be able to choose either from a range of standard interfaces or a customized interface to meet their particular requirements. The certificate management service will provide European SET certificate issuing services for card issuers who do not wish to implement the SET protocol themselves. Approval to issue certificates will remain under the control of the banks directly connected to the European SET Utility.

A major advantage for the users of the service is that PBS will handle any changes in the emerging SET standard, and will be able to add other payment mechanisms, such as debit cards, as they become available. In particular, I would expect some sort of e-money cash equivalent to develop as Europe moves toward the ECU (European Currency Unit). You can get more details on the IBM and PBS deal at www.europe.ibm.com/finance and www.pbs.dk.

I am going to speculate that the acceptance of Internet commerce across borders in Europe is due to the political importance of the Internet in Europe. Americans tend to view the Internet as a commercial or recreational activity first, and as a political tool or First Amendment issue second. Therefore, we are more willing to regulate it and pass restrictive laws in our good Puritan tradition. We do not see the Internet as we do a free press, as a right. Would anyone in public office have proposed a "Newspaper Decency Act" and been taken seriously?

In Yugoslavia, when the Milosevic government decided to close down Radio B-92, the only independent radio station in Belgrade, the station continued to broadcast to a worldwide audience through the Internet, according to Jonathan Peizer, CIO of The Open Society Institute. (See Peizer's column, "The Internet and the Open Society" at businesstech.com.)

The Open Society Institute is part of the network of foundations created and funded by philanthropist and international investor George Soros to spread democratic processes and the concept of an open society in emerging countries.

How Standards Live Forever

I received the original version of the following piece from Bill Kent at Hewlett-Packard Co. It is originally told by Professor Tom O'Hare (Germanic Languages, University of Texas at Austin; 512-471-4123; tohare@mail.utexas.edu), and it is a good explanation of how standards endure.

The U.S. Standard railroad gauge (distance between the rails) is 4 feet, 8.5 inches. This gauge is used because the English built railroads to that gauge and U.S. railroads were built by English expatriates. Why did the English build railroads to that gauge? Because the first rail lines were built by the same people who built the prerailroad tramways, and that's the gauge they used. Why did those wheelwrights use that gauge, then? Because the people who built the horse-drawn trams used the same jigs and tools that they used for building wagons, which used that wheel spacing.

Why did the wagons use that odd wheel spacing? For the practical reason that any other spacing would break an axle on some of the old, long distance roads because this is the measure of the old wheel ruts. So who built these old rutted roads? The first long distance roads in Europe were built by Imperial Rome for their legions and used ever since. The initial ruts were first made by Roman war chariots, which were of uniform military issue.

Thus, we have the answer to the original questions. The United States standard railroad gauge of 4 feet, 8.5 inches derives from the original specification for an Imperial Roman army war chariot. Specs and bureaucracies live forever. So, the next time you are handed a specification and wonder what horse's ass came up with it, you may be exactly right. Because the Imperial Roman chariots were made to be just wide enough to accommodate the back-ends of two war horses.

PUZZLE

This puzzle was proposed as a class exercise when I taught an advanced SQL course at Municipal Electric Authority of Georgia (MEAG). Joey wanted to see his name in print for proposing it; he just did. Uncle Scrooge has a will made out that tells the executor how to split up his estate among his three nephews, Huey, Louie, and Dewey. The estate is in a simple inventory table that looks like this:

CREATE TABLE Estate
(item CHAR(15) NOT NULL PRIMARY KEY,
qty INTEGER NOT NULL CHECK (qty> 0));
INSERT INTO Estate VALUES ('Comics', 50);
INSERT INTO Estate VALUES ('G.I. Joes', 100);
INSERT INTO Estate VALUES ('Marbles', 100);
INSERT INTO Estate VALUES ('Bikes', 100);
INSERT INTO Estate VALUES ('Kites', 97);

The will has some provisions for distributing some of the goods involved (for example, Huey gets all of the comic book collection), but if anything is not specifically mentioned in the will, then the executor is to divide the items up in the ratios: Huey = 50%; Louie = 30%; Dewey = 20%. If the number of items cannot be divided into these ratios evenly, then the executor is to do the best he can and leave the remainder of each item in the estate to be turned into cash and distributed later. The result table should look like this:

CREATE TABLE Distribution
(item CHAR(15) NOT NULL,
nephew CHAR(10),
shares INTEGER NOT NULL);

The nephew column can also have the value "Estate" for the undistributed items. When it is all over, all items in the estate should be accounted for in the distribution. Because wills change and nephews come and go, try to be as general as possible about your solution. (The puzzle answer is on page 22.)


Joe Celko is an Atlanta-based guru with Northern Lights Software Ltd. and a member of the National Committee for Information Technology Standards. He is also the author of two books on SQL: SQL For Smarties (Morgan-Kaufmann) and Instant SQL (Wrox Press). You can contact Joe via email at 71062.1056@compuserve.com.

Puzzle Answer

Before we start, let me say that we did not want a distribution table with a column for each nephew by name. That design would not be normalized, and it is possible that Uncle Scrooge might want to write relatives into or out of the will.

The executor's rules will be represented by this table:

CREATE TABLE Will
(item CHAR(15),
nephew CHAR(10) NOT NULL,
shares DECIMAL(6,3) NOT NULL);

INSERT INTO Will VALUES (NULL, 'Dewey', 0.200);
INSERT INTO Will VALUES (NULL, 'Huey', 0.500);
INSERT INTO Will VALUES (NULL, 'Louie', 0.300);
...
INSERT INTO Will VALUES ('Comics', 'Huey', 1.00);
INSERT INTO Will VALUES ('G.I. Joes', 'Dewey', 0.333);
INSERT INTO Will VALUES ('G.I. Joes', 'Huey', 0.333);
INSERT INTO Will VALUES ('G.I. Joes', 'Louie', 0.333);
INSERT INTO Will VALUES ('Marbles', 'Dewey', 0.500);
INSERT INTO Will VALUES ('Marbles', 'Louie', 0.500);

The first three rows are for the general distribution of items not specified in the will, with null used for the name of any such item. The other rows are for designated gifts. The first attempt is this query:

INSERT INTO Distribution (item, nephew, shares) 
SELECT E1.item, W1.nephew, 
CASE WHEN W1.nephew IS NULL
THEN E1.qty
ELSE (E1.qty * W1.shares) END
FROM Estate AS E1 LEFT OUTER JOIN Will AS W1 
ON W1.item = E1.item
WHERE E1.item IS NOT NULL;

Distribution

itemnephewshares
===============================
BikesNULL 100 <== Inheritor not specified
ComicsHuey50
G.I. JoesDewey33
G.I. JoesHuey 33
KitesNULL97 <== inheritor not specified
MarblesDewey50
MarblesLouie50
The calculation in the CASE expression will be rounded down, rounded up, or truncated when its real number result is put into an INTEGER column. Such decisions about rounding and truncation are implementation defined in the SQL-92 standard, so writing truly portable SQL for this problem is going to be hard. Let's assume that the executor considers the compiler's decision to be fair and that he will clean up any rounding problems himself later. The next step is to split up the unspecified items according to the formula given in the will:

BEGIN ATOMIC
INSERT INTO Distribution (item, nephew, shares) 
SELECT D1.item, W1.nephew, 
(W1.shares * D1.shares) 
FROM Distribution AS D1, Will AS W1
WHERE W1.item IS NULL --unspecified item
AND D1.nephew IS NULL; --unspecified inheritor
DELETE FROM Distribution -- remove now that inheritor specified 
WHERE nephew IS NULL;
END;

item nephewshares
===============================
BikesDewey20
BikesHuey50
BikesLouie30
ComicsHuey50
G.I. JoesDewey33
G.I. JoesHuey33
G.I. JoesLouie33
KitesDewey19
KitesHuey48
KitesLouie29
MarblesDewey50
MarblesLouie50

We now have to add the remaindered items that could not be split up to the distribution table:

INSERT INTO Distribution (item, nephew, shares) 
SELECT D1.item, '{Estate}', 
(SUM(E1.qty)/COUNT(*)) - SUM(D1.shares) 
FROM Distribution AS D1, Estate AS E1
WHERE E1.item = D1.item
GROUP BY D1.item
HAVING SUM(D1.shares) < SUM(E1.qty)/COUNT(*);

itemnephewshares
=============================
BikesDewey20
BikesHuey50
BikesLouie30
ComicsHuey50
G.I. JoesDewey33
G.I. JoesHuey33
G.I. JoesLouie33
G.I. Joes[Estate] 1
KitesDewey19
KitesHuey48
KitesLouie29
Kites[Estate] 1
MarblesDewey50
MarblesLouie50

This is a tricky query. The minor trick is using curvy brackets on the word "{Estate}" to assure that it will not be mistaken for a real person's name to also to force it to sort last within each grouping. The big trick is in the expression (SUM(E1.QTY)/COUNT(*)). In joining the estate to the distribution table, we also attached a copy of qty to each of the nephew rows. Dividing by COUNT(*) will restore the value of qty for that item; we are multiplying and dividing by the same number to avoid using a subquery expression and to get around the limits on aggregates in a grouped table. We then subtract the total quantity already distributed among the nephews and insert the leftovers into the distribution as belonging to the estate itself.

Finished! Well, almost. The final check is to compare the estate and the distribution by displaying any item that is not properly distributed:

SELECT * 
FROM Estate AS E1
WHERE (SELECT qty -- quantities in estate must equal
FROM Estate AS E2
WHERE E1.item = E2.item) <>
(SELECT SUM(shares) -- ... total shares of each item
FROM Distribution AS D1
WHERE E1.item = D1.item
GROUP BY D1.item);
As an aside, some of these queries could be folded into each other, but this problem is better done in steps. The executor can look at each step and make any decisions that are needed.

What did you think of this article? Send a letter to the editor.


Subscribe to DBMS and Internet Systems -- It's free for qualified readers in the United States
September 1997 Table of Contents | Other Contents | Article Index | Search | Site Index | Home

DBMS and Internet Systems (http://www.dbmsmag.com)
Copyright © 1997 Miller Freeman, Inc. ALL RIGHTS RESERVED
Redistribution without permission is prohibited.
Please send questions or comments to dbms@mfi.com
Updated Friday, August 8, 1997