• Antelope Release 5.10 Linux CentOS release 7.6.1810 (Core) 3.10.0 2020-05-12

 

NAME

dbfind_join_keys - find join keys between two tables

SYNOPSIS

int dbfind_join_keys ( Dbptr db1, Dbptr db2, Tbl **keys1, Tbl **keys2 )

DESCRIPTION

dbfind_join_keys implements the method Datascope employs to infer the natural keys on which joins between two tables should occur. The keys are inferred based on the primary, alternate, and foreign keys for the two tables, and is based on matching names for the keys of the two tables. It proceeds as follows:

The process is complicated somewhat by the presence of ranges, for example a time range. A range matches another range with the same start and end names. (As a special concession to the CSS 3.0 database, time::endtime also matches ondate::offdate. The original decision to have the fields ondate and offdate was flawed.) A range also matches a single field which has the same name as the start of the range. For instance, time matches time::endtime.

Table which are the result of joins inherit a subset of the keys possessed by their parents. This process is strictly ad-hoc, and is not guaranteed to produce the correct subsequent joins. However, it is very often correct, and by careful choice of the order in which you join tables, you can usually force the correct join.

RETURN VALUES

dbfind_join_keys returns 0 for success; dbINVALID indicates a bad dbptr, while 1 indicates a failure to find matching keys. If successful, the matching keys for each table are returned in the two Tbl lists. These lists should be freed with freetbl(tbl,0).

LIBRARY

$(DBLIBS)

SEE ALSO

dbjoin(1), dbfind_join_tables(3)

AUTHOR

Daniel Quinlan
Printer icon