Programming guide to Unibase

3 : A database as programming tool

In ANSI-C the routines on the internal data-structure are very hard to write. On the other hand you can store virtually everything in tables as long as the right indexes exist to get the data out again.

Slow databases

Almost all the databases are too slow for my taste, they want to have SQL queries and those queries are normally interpreted on the moment of use. The programmer cannot tell beforehand how the queries should get their data. So it is unknown if the queries are optimal or not. Some programs that uses SQL perform excellent in the test environment but when taken into production are embarrassing slow, where did we go wrong?

Direct access to data

There is no problem with using tables or indexes but only in the indirect way people access the data. The only really direct way to access a database I found in the AS/400 RPG programming language. The program picks a specific Index, finds the right spot in the data and reads the data from that point onward. This results in very robust and quick programs but the down side is that it is only available in a large and expensive black box from IBM and it is not a pleasure to write large programs in this language especially not with a user interface.

Solution

The basic way of getting information from a table in Unibase is the same as with RPG. It is a somewhat SQL like instruction that gets record from a specific index. It uses this index for the sort order and as an entry point to the table. The actual program can consist of hundredth of these queries but they are all compiled into ANSI-C code so this should not be a strain to the speed of the resulting program.

Design

The normal code of the program is converted directly to ANSI-C but this language has full string operations. The pointer type in this language points to a specific record in a table and will not generate a core dump when it points somewhere else. So there is no structure left that could crash the program. There are still possibilities to create unending loops but I'm working on it to get rid of them or at least to let an exception occur if the program makes more loops than is healthy for it.