}
}
+static void query_report_all(relation *r,tuple *query[]) {
+ int j;
+ for ( j = 0; query[j]; j++ ) {
+ fprintf( stderr, "query %s\n", tuple2string( r, query[j] ) );
+ query_report( r, query[j] );
+ }
+}
+
// Report any knocked out tuples from relation_add or relation_delete
// This will also clear and free the result vector.
static void knockout_report(relation *r,vector *v) {
}
int main(int argc,char **argv) {
+
+ // AxB
tuple *data2[] = {
TUPLE( "a", "b" ),
TUPLE( "a", "c" ),
TUPLE( 0, "d" ),
0
};
- int j;
- // AxB
relation rel2 = RELATION( &stringitem, &stringitem );
+
test_relation_add( &rel2, data2 );
query_report( &rel2, 0 );
- for ( j = 0; query2[j]; j++ ) {
- fprintf( stderr, "query %s\n", tuple2string( &rel2, query2[j] ) );
- query_report( &rel2, query2[j] );
- }
+ query_report_all( &rel2, query2 );
test_relation_delete( &rel2, query2 );
// AxBxC
+ tuple *data3[] = {
+ TUPLE( "a", "b", "c" ), // <a,b,?> <a,?,c> ***
+ TUPLE( "a", "c", "d" ), // <a,c,?> <a,?,d> ***
+ TUPLE( "a", "b", "e" ), // <a,b,?> <a,?,e> => -<a,b,c>
+ TUPLE( "b", "d", "d" ), // <b,d,?> <b,?,d>
+ TUPLE( "a", "d", "d" ), // <a,d,?> <a,?,d> => -<a,c,d>
+ TUPLE( "e", "c", "a" ), // <e,c,?> <e,?,a>
+ TUPLE( "f", "b", "d" ), // <f,b,?> <f,?,c>
+ 0
+ };
+ tuple *query3[] = {
+ TUPLE( "a", 0, "d" ),
+ TUPLE( 0, 0, "d" ),
+ TUPLE( 0, "c", 0 ),
+ TUPLE( "f", "b", "d" ),
+ 0
+ };
relation rel3 = RELATION( &stringitem, &stringitem, &stringitem );
- // AxB -> C
- relation_add_constraint( &rel3, 1, 1, 0 );
- // AxC -> B
- relation_add_constraint( &rel3, 1, 0, 1 );
+ relation_add_constraint( &rel3, 1, 1, 0 ); // AxB -> C
+ relation_add_constraint( &rel3, 1, 0, 1 ); // AxC -> B
+
+ test_relation_add( &rel3, data3 );
+ query_report( &rel3, 0 );
+ query_report_all( &rel3, query3 );
+ test_relation_delete( &rel3, query3 );
return 0;
}