CONNECTED AS

Previous Next

CONNECTED AS clauses in the USoft Rule Language serve to identify a USoft relationship (as declared in USoft Definer) that defines how data from multiple tables are to be joined.

CONNECTED AS in a USoft context is a synonym of RELATE. Because RELATE, in turn, is equivalent to conventional WHERE clauses that spell out how the parent column(s) correspond(s) to the child column(s), CONNECT AS is also a synonym of these conventional WHERE clauses.

Syntax

CONNECTED AS   table-alias-1 single-string-parent-role  table-alias-2

where the required and all-capitals single-string-parent-role is the same or similar to the (all-capitals) Parent Role value for the relationship as defined in USoft Definer:

If the Parent Role value does NOT contain a space, it is equivalent to single-string-parent-role, whether surrounded by optional double quotes or not;

If the Parent Role value DOES contain one or more spaces, you must surround single-string-parent-role by double quotes.

For example, if you have a relationship "Customer PAYS FOR Rental" with Parent Role = PAYS FOR, and you use table alias "c" for customer and "r" for rental, the CONNECTED AS looks like this:

CONNECTED AS   c "PAYS FOR" r

Example

USoft Rule Language

USoft SQL Equivalent

Conventional SQL Equivalent

FOR                drivers d
,                  rentals r
,                  "business parties" b
CONNECTED AS       d "REGISTERED IN" r

,                  b "PAYS FOR" r
DO NOT ALLOW THAT  b.id = d.id
AND                r.paid = 'N'

SELECT       ''
FROM         driver d
,            rental r
,            business_party b
RELATE       d "REGISTERED IN" r

,            b "PAYS FOR" r
WHERE        b.id = d.id
AND          c.paid = 'N'

SELECT       ''
FROM         driver d
,            rental r
,            business_party b
WHERE        d.id = r.driver_id

AND          b.id = r.customer_id
AND          b.id = d.id
AND          c.paid = 'N'