Relationships

To include multiple nodes in a TQL MATCH statement, you must use relationships to connect the nodes, and then use the RETURN clause to reference the assigned aliases to retrieve the data that you want.

The following graph shows some of the relationships that you can use to connect nodes in a query:

Figure 1. Nodes and relationships in the Technopedia graph

In a query, you prefix relationships with a colon (:) and nest them inside square brackets, for example [:OWNS]

  • Unidirectional relationships are indicated by an arrowhead (->)
  • Bidirectional relationships are indicated by two hyphens, for example, -[:Relationship]-
  • Like nodes, relationships can have attributes. Typically, relationships have quantitative attributes, such as time intervals.

For any queries that use relationships, follow the relationship direction that's shown in Figure 1.

For example, you might want to get the owner name and product data by making one Technopedia query.

In the following example, the owner 'Galitt' is cross-referenced from the OWNER node to the ASSET node by using the OWNS relationship:
This query returns product data for the owner: Galitt.

MATCH (n:OWNER {type:'Manufacturer', owner: 'Galitt'})-[:OWNS]->(x:ASSET) RETURN x LIMIT 1

The following query result returns product data for Galitt.

Figure 2. Query result with product data for Galitt

The following query example uses the CLASSIFIED_AS relationship from the ASSET node to the CATEGORY_2 node:
Return assets with 'Workbench' in their product title and include the CATEGORY_2 classification details.

MATCH (x:ASSET {type: 'Product'})-[:CLASSIFIED_AS]->(c:CATEGORY_2) WHERE x.title CONTAINS 'Workbench' RETURN x, c LIMIT 5

The following image shows two results for this query:

Figure 3. Products that have 'Workbench' in their title with their category two classification

Note the relationship direction in the node and relationship graph (Figure 1.)

Figure 4. Relationship directions

The following query examples use relationships that are shown in the node and relationship graph (Figure 1.).

Query example one

For a product named 'Fan', get asset, owner, category one, and category two data.

To get this data, you must connect four nodes and use the relationship types and directions that are shown in the Node and Relationship graph (Figure 1.). By adding an alias to each node, you can use the RETURN clause to reference the aliases and retrieve the data that you want.

MATCH (c1:CATEGORY_1)<-[:BELONGS_TO]-(c2:CATEGORY_2)<-[:CLASSIFIED_AS]-(a:ASSET)<-[:OWNS]-(o:OWNER) where a.product = 'Fan' RETURN a, c2, c1, o limit 2

The following image shows one result for the query:

Figure 5. Query results for example one

Query example two

For the manufacturer 'Electronic Arts', get owner data and products data.

MATCH (n:OWNER {type:'Manufacturer', owner: 'Electronic Arts'})-[:OWNS]->(x:ASSET) RETURN DISTINCT x, n LIMIT 1

The following image shows one result for the query that returns owner and asset data from Electronic Arts:

Figure 6. Query results for example two

Query example three

Get any four assets from Technopedia, and include the Category one, two, and group labels for those assets.

MATCH (asset:ASSET)-[:CLASSIFIED_AS]->(cat2:CATEGORY_2)-[:BELONGS_TO]->(cat1:CATEGORY_1)-[:BELONGS_TO]->(catgrp:CATEGORY_GROUP) RETURN asset.product, cat2.label, cat1.label, catgrp.label LIMIT 4

The following image shows two results for the query that returns owner and asset data for Electronic Arts:

Figure 7.Query results for example three

Query example four

Get asset data for any asset that is manufactured by 'Anthony Baldwin'.
MATCH (n:ASSET)<-[:OWNS]-(x:OWNER {type: 'Manufacturer', owner: 'Anthony Baldwin'}) RETURN n LIMIT 1

The following image shows one result for owner and asset data for Anthony Baldwin:

Figure 8. Query results for example four

When you include relationships in MATCH statements, you must use the relationship direction from the graph diagram.

The release attribute returns edition, version, release, and product data.

Query examples

To use the MATCH statements in the following examples, you add the MATCH statement to the following /tql endpoint and make a GET request from an API client or use cURL.

https://data.technopedia.com/tql?q=<MATCH Statement>

MATCH (a:OWNER)-[:OWNS]->(y:ASSET) 
RETURN a, y 
LIMIT  2

RESPONSE

{
    "results": [
        {
            "a.city": "Minnetonka",
            "a.country": "United States",
            "a.email": "info@digi.com",
            "a.employees": 643,
            "a.employees_date": "2012-09-30T00:00:00Z",
            "a.fiscal_end_date": "2012-09-30T00:00:00Z",
            "a.legal": "Corporation",
            "a.owner": "Digi International",
            "a.profits_date": "2012-09-30T00:00:00Z",
            "a.revenue": 191,
            "a.revenue_date": "2012-09-30T00:00:00Z",
            "a.state": "Minnesota",
            "a.street": "11001 Bren Road East",
            "a.symbol": "DGII",
            "a.technopedia_id": "42560c73-2c61-436a-8d17-66f96b5729a6",
            "a.tier": 3,
            "a.type": "Manufacturer",
            "a.website": "http://www.digi.com/",
            "a.zip": "55343",
            "y.class": "Software",
            "y.created_at": "2011-03-25T17:08:31Z",
            "y.is_major": "FALSE",
            "y.modified_at": "2017-05-31T17:48:34Z",
            "y.owner": "Digi International",
            "y.product": "Connectware Manager",
            "y.technopedia_id": "6f46a3c4-8b15-4704-bd4d-b5da4fb08d4e",
            "y.title": "Digi International Connectware Manager 3.3",
            "y.type": "Version",
            "y.version": "3.3",
            "y.version_group": "3",
            "y.version_order": "6"
        },
        {
            "a.city": "Minnetonka",
            "a.country": "United States",
            "a.email": "info@digi.com",
            "a.employees": 643,
            "a.employees_date": "2012-09-30T00:00:00Z",
            "a.fiscal_end_date": "2012-09-30T00:00:00Z",
            "a.legal": "Corporation",
            "a.owner": "Digi International",
            "a.profits_date": "2012-09-30T00:00:00Z",
            "a.revenue": 191,
            "a.revenue_date": "2012-09-30T00:00:00Z",
            "a.state": "Minnesota",
            "a.street": "11001 Bren Road East",
            "a.symbol": "DGII",
            "a.technopedia_id": "42560c73-2c61-436a-8d17-66f96b5729a6",
            "a.tier": 3,
            "a.type": "Manufacturer",
            "a.website": "http://www.digi.com/",
            "a.zip": "55343",
            "y.class": "Software",
            "y.created_at": "2011-03-25T17:08:38Z",
            "y.is_major": "TRUE",
            "y.modified_at": "2017-05-31T17:48:34Z",
            "y.owner": "Digi International",
            "y.product": "Connectware Manager",
            "y.technopedia_id": "df17a5e8-9282-44b5-ba01-b4e78d20f3d7",
            "y.title": "Digi International Connectware Manager 2.0",
            "y.type": "Version",
            "y.version": "2.0",
            "y.version_group": "2",
            "y.version_order": "1"
        }
    ]
}
MATCH (xxx:OWNER {type: 'Manufacturer', owner: 'DigiPortal Software'})-[:OWNS]->(yyy:ASSET)
RETURN xxx, yyy LIMIT 1

RESPONSE

{
    "results": [
        {
            "xxx.legal": "Corporation",
            "xxx.owner": "DigiPortal Software",
            "xxx.symbol": "Private",
            "xxx.technopedia_id": "3810664f-6045-4c08-ad07-32c7020a1b71",
            "xxx.tier": 3,
            "xxx.type": "Manufacturer",
            "xxx.website": "http://www.digiportal.com/",
            "yyy.class": "Software",
            "yyy.created_at": "2007-08-28T01:55:40Z",
            "yyy.modified_at": "2011-09-07T11:31:19Z",
            "yyy.owner": "DigiPortal Software",
            "yyy.product": "ChoiceMail",
            "yyy.technopedia_id": "05bc3ad3-7314-4228-ad4e-36ba915633e1",
            "yyy.title": "DigiPortal Software ChoiceMail",
            "yyy.type": "Product",
            "yyy.url": "http://www.digiportal.com/index.html",
        }
    ]
}
MATCH (s:ASSET {class:'Software', type:'Product'})-[:CLASSIFIED_AS]->(v:CATEGORY_2) RETURN s, v LIMIT 1

RESPONSE

{
            "s.class": "Software",
            "s.created_at": "2005-08-26T11:50:20Z",
            "s.family": "AllFusion",
            "s.is_suite": "FALSE",
            "s.modified_at": "2015-05-12T16:54:37Z",
            "s.owner": "CA Technologies",
            "s.product": "Advisor",
            "s.technopedia_id": "416b6a77-9c38-4461-a2ed-90638b7bebf6",
            "s.title": "CA Technologies AllFusion Advisor",
            "s.type": "Product",
            "s.url": "http://supportconnectw.ca.com/public/erwin/infodocs/prodcomp.asp",
            "v.description": "The process of exploration and analysis of business data to discover and identify new and meaningful information and trends to obtain an optimal or realistic decision based on existing data",
            "v.label": "Analytics"
        }
    ]
}
MATCH (sss:ASSET {class: 'Software', type: 'Version' })<-[:OWNS]-(ggg:OWNER) 
RETURN sss, ggg LIMIT 1

RESPONSE

{
    "results": [
        {
            "ggg.city": "Mississauga",
            "ggg.country": "Canada",
            "ggg.email": "01com@01com.com",
            "ggg.legal": "Corporation",
            "ggg.owner": "01 Communique Laboratory",
            "ggg.revenue": 1,
            "ggg.state": "Ontario",
            "ggg.symbol": "TSX: ONE",
            "ggg.technopedia_id": "55d104f8-b036-471c-97a4-a3d9f9543b1e",
            "ggg.tier": 3,
            "ggg.type": "Manufacturer",
            "ggg.website": "http://www.01com.com",
            "sss.class": "Software",
            "sss.created_at": "2008-09-08T00:31:00Z",
            "sss.is_major": "TRUE",
            "sss.modified_at": "2018-01-11T20:20:03Z",
            "sss.owner": "01 Communique Laboratory",
            "sss.product": "COMMUNICATE!",
            "sss.technopedia_id": "eaaa6031-17d2-4611-8565-b8e5a905fe1e",
            "sss.title": "01 Communique Laboratory COMMUNICATE! 10.0",
            "sss.type": "Version",
            "sss.version": "10.0",
            "sss.version_group": "10",
            "sss.version_order": "1"
        }
    ]
}
MATCH (s:ASSET {class: 'Software', product: 'UniData' })-[:CLASSIFIED_AS]->(c2:CATEGORY_2) RETURN s, c2 LIMIT 1

{
    "results": [
        {
            "c2.description": "A system intended to organize, store, and retrieve large 
             amounts of data that is shared by many users throughout the organization
             easily. Includes IBM DB2, non-personal Oracle, non-mobile Sybase, 
             Informix, MS SQL Server, RDB, Time 10, Teradata, etc.",
            "c2.label": "Enterprise",
            "s.class": "Software",
            "s.created_at": "2005-01-31T00:00:00Z",
            "s.family": "Information Management - DB2",
            "s.is_suite": "FALSE",
            "s.modified_at": "2017-06-01T11:41:18Z",
            "s.owner": "IBM",
            "s.product": "UniData",
            "s.technopedia_id": "57211a40-056d-48c7-81ed-9caebc54efa5",
            "s.title": "IBM Information Management - DB2 UniData",
            "s.type": "Product",
            "s.url": 
            "http://www-306.ibm.com/software/data/u2/unidata/requirements.html"
        }
    ]
}

Relationships


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.