Specifying Field Names

TIBCO Patterns closely follows the SQL conventions for handling field names in joined searches.

The table name precedes the field name and is separated by a period. Note that, as TIBCO Patterns allows blanks in both table names and field names, no blank separators are allowed on either side of the period.
A table name qualifier is only required when the field name is not unique across the set of tables in the joined search.
As in SQL, an alias can be assigned for a child table. However, unlike SQL, an alias name cannot be assigned to the parent table in a joined search. When an alias name is assigned, it must be used instead of the actual table name in all the field names for that query.

Modifying the example to include aliases for the child tables the SQL query is:

 

SELECT * FROM Persons, Addresses AS A, Phones AS P
WHERE Persons.id = A.person_id AND Persons.id = P.person_id
...
AND A.street = “123 Main St.”

TIBCO Patterns Java API:

 

NetricsJoin join_def = new NetricsJoin(“Persons”,
NetricsJoin.JOIN_FULL_AND_PARTIALS,
false,
String [] { “A”, “P” },
String [] { “Addresses”, “Phones” }
);
...
NetricsQuery q_street = NetricsQuery.Simple(
“123 Main St.”,
new String [] {“A.street”},
null
);

There are some restrictions on alias names.

All alias names must be unique.

Invalid Example

 

NetricsJoin join_def = new NetricsJoin(“Persons”,
NetricsJoin.JOIN_FULL_AND_PARTIALS,
false,
String [] { “A”, “A” }, // invalid!
String [] { “Addresses”, “Phones” }
);
An alias name cannot be the same as a table in a different position.

Invalid Example

 

NetricsJoin join_def = new NetricsJoin(“Persons”,
NetricsJoin.JOIN_FULL_AND_PARTIALS,
false,
String [] { “A”, “Addresses” }, // invalid!
String [] { “Addresses”, “Phones” }
);

Invalid Example

 

NetricsJoin join_def = new NetricsJoin(“Persons”,
NetricsJoin.JOIN_FULL_AND_PARTIALS,
false,
String [] { “Phones”, “P” }, // invalid!
String [] { “Phones”, “Phones” }
);

Valid Example

 

NetricsJoin join_def = new NetricsJoin(“Persons”,
NetricsJoin.JOIN_FULL_AND_PARTIALS,
false,
String [] { “Addresses”, “P” }, // OK.
String [] { “Addresses”, “Phones” }
);
Alias names must be used when the same child table appears multiple times in the child tables list. Each child table must have a unique identifier. If the same table is used multiple times it must be assigned different alias names.

The special parent key field name

A special field name: “^parent”, that is, the special character caret (Unicode code point 5E) followed by the word “parent”, is used to refer to the parent record key value of a child record. This special field name is used only for joined searches. As this special field exists for each child record it must always be qualified with a table (or alias) name when more than one child table is specified in the search. This special field is treated as having a field type of non-searchable text. Therefore, it can’t be used in simple or cognate searches. It can be used in predicate expressions, in both filtering predicates or query predicates.