tproduct: Form the Cartesian product of two tables.

Package: nttools

Usage

tproduct intable1 intable2 outtable

Description

This task creates an output table which is the Cartesian product of two input tables. This Cartesian product consists of every possible combination of the rows of the two input tables. Therefore, the number of rows in the output table is the product of the number of rows in the two input tables. The output table will contain all the columns from both input tables. If a column name in the first input table is the same as a column name in the second input table, this task tries to create a unique name by appending "_1" to the first name and "_2" to the second name. If the task cannot create a unique name in this way, it stops with an error.

Parameters

intable1 [file name]
First input table.
intable2 [file name]
Second input table.
outtable [file name]
Output table containing the possible Cartesian products.

Examples

1. Find all persons sharing a phone from a phone list:

tt> tproduct phone.tab phone.tab phone.tmp
tt> tselect phone.tmp share.tmp "phone_1 == phone_2 && name_1 < name_2"
tt> tproject share.tmp share.tab phone_2 inc-
tt> delete *.tmp

Bugs

References

This task was written by Bernie Simon.

See also

tselect, tproject, tjoin