[ALL] let's think about Query Language for 2.0

Ruslan Zasukhin sunshine at public.kherson.ua
Fri May 23 22:11:53 CDT 2003


on 5/23/03 1:52 PM, Andreas Grosam at agrosam at computerworks.ch wrote:

> A more C++ like example:
> 
> This shows some code examples which reside in the client side (as
> interfaces and libraries).
> 
> - Note that this is just an idea! (However, several parts have already
> been implemented and proofed to work in a
> previous framework)
> - Note that this example is in C++ and uses templates, which may be not
> available in all languages,
> but can be bypassed or it can be implemented in a slightly modified way.
> 
> 
> // Suppose these classes have been defined in namespace db elsewhere:
> class db::Relation;
> class db::Tuple;
> class db::TupleDescriptor;
> calss db::ColumnDescriptor;
> class db::Predicate;
> class db::equal_pred;
> class db::less_than_pred;
> 
> 
> 
> 
> // Create a "tuple descriptor". It describes a tuple(mainly attributes
> and types). Can be re-used.
> // A tuple descriptor is a list of column descriptors.
> // In this case, a tuple descriptor will be created which has two
> column descriptors,
> // one which is labeled "FirstName" and is of type string, the other is
> labeled
> // "DOB" (means, "day of birth") and is of type date:
> TupleDescriptor td;
> td.push_back(ColumnDescriptor("FirstName", make_type_desc<string>()));
> td.push_back(ColumnDescriptor("DOB", make_type_desc<date>()"));
> 
> // Note that a column descriptor may have several properties - which
> are not shown here.
> 
> // Create a relation with a specified tuple descriptor and attach it
> the base table "Persons".
> // Note that this may throw an exception if the tuple descriptor is not
> applicable.
> Relation persons(td);         // c-tor with explicit row-descriptor
> persons.open("Persons");      // may throw "descriptor_does_not_match"

Okay Andreas,

Now I see that your term Relation is analog of "virtual table -- VIEW" in
Standard SQL. Correct?

Please look on next syntax then:

    I_Table* pPersons; // pointer on Persons Table.
    I_Table* pMySubTable = pPersons->MakeView( "FirstName", "DOB" );

I think this syntax is more short and readable.
Table pPersons already know type of fields FirstName and DOB.

Okay, you will say that your syntax allow apply tuple descriptor to any
table that have fields with name "FirstName" and DOB.
Then we can modify syntax:

    I_Table* pMySubTable = MakeView( "FirstName", "DOB ");
    pMySubTable->OpenOn( pPersons );
    
Or even more short:

    I_Table* pMySubTable = MakeView( pPersons, "FirstName", "DOB ");

I think in 99% cases developer what in view the same types as in original
table.


-- 
Best regards,
Ruslan Zasukhin      [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com

To subscribe to the Valentina mail list go to:
http://lists.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------



More information about the Valentina mailing list