relational tables and objects

From: Arkadiy Vertleyb <vertleyb_at_hotmail.com>
Date: 27 Oct 2002 03:12:38 -0800
Message-ID: <2f56064a.0210270312.104a330f_at_posting.google.com>



Hi everybody,  

We are trying to determine if there is any interest in a C++ library we recently wrote:  

The library implements an STL-compatible "relational table" container.  The items of this container, tuples, can contain fields of any built-in or user-defined types: integers, strings, pointers, smart pointers, functors, windows, people, monsters, etc. The access to fields is completely type-safe -- no void pointers or reinterpret casts (only template meta-programming :o) ).  

Here is an example on how you can create and populate such a table:  

COLUMN(ssn, int);
COLUMN(name, std::string);  

typedef tuple<list<ssn, list<name> > > employee;  

table<employee> employees;
employees.insert(employee(1, "Bob"));
employees.insert(employee(2, "John"));  

The full set of relational operators is implemented:  

-selection,
-projection,
-cross-product,
-join,
-union,
-difference,
-intersection,
-groupby,


etc.  

The operators are also STL-compatible. They provide bi-directional const_iterators.  

The operators can be combined in expressions using the technique known as "expression templates", so something like this can be written:  

print(projection<list<name> >(selection(eq<ssn>(1), employees))); // select an employee with ssn = 1, and print the name  

Indexing and range queries (equal_range, upper_bound, lower_bound) are also possible on both tables and operators. Range queries on operators are implemented through range queries on their arguments.  

We think that such a lightweight library could bring relational algebra into the areas where it previously was not considered because of the overhead and limitations traditional RDBMSs impose. Consider writing a simulation system or a game. Which objects are located close to each other and so need to interact? All such pairs are easily found with join. What are integral characteristics of the system? Use groupby. And so on.  

The library is currently submitted to Boost for determinning possible interest, and is available in the Boost files section:  

http://groups.yahoo.com/group/boost/files/tables.zip  

Thanks in advance for any comments,  

Arkadiy Received on Sun Oct 27 2002 - 12:12:38 CET

Original text of this message