liveBook · Manning

Relationship type

As explained in Graph Algorithms for Data Science

A relationship type is a label that identifies the kind of connection represented by a graph relationship.

A relationship type is a label that identifies the kind of connection represented by a graph relationship. In a labeled-property graph, every relationship is directed and has one type, giving the connection semantic meaning; relationships can also carry key-value properties. section 2.2.1 section 11.1.1

Choose relationship types that describe the domain connection precisely:

  • Use FRIEND or FRIENDS for social connections, WRITES_FOR for an employment or organizational connection, and IS_IN for geographic containment. section 1.2.1 section 3.3
  • Treat direction as part of the meaning when reversing a connection changes its interpretation; friendship can often be traversed without caring about direction. section 2.2.1
  • Prefer specific types such as HAS_TAG over a generic HAS relationship, improving clarity, maintainability, consistency, and potentially query performance. section 2.4.2

Creating and querying a typed connection

A Cypher model can connect a person to an organization with an EMPLOYED_BY type: CREATE (p:Person{name:'Tomaz'}), (o:Organization {name: "Acme Inc"}) CREATE (p)-[e:EMPLOYED_BY]->(o) RETURN *. The type distinguishes this connection from FRIENDS, IS_IN, or other relationships. section 3.3 section 2.2.1

Figure 2.9 Labeled-property graph model representing the example data
02-09

Use the labeled-property graph model to inspect how node labels, relationship types, direction, and properties work together. section 2.2.1

How Graph Algorithms for Data Science covers it

How deep it goes
Explains relationship semantics, direction, properties, naming quality, and graph triples without descending into database implementation internals.
Examples
Demonstrates FRIEND, WRITES_FOR, EMPLOYED_BY, IS_IN, HAS_TAG, and SIMILAR relationships through graph models, Cypher listings, and network projections.
What you can do after
Apply relationship types via Cypher to create, retrieve, traverse, and interpret typed graph connections.
How it connects
Connects relationship types to directed graphs, labeled-property graphs, relationship properties, Cypher, graph projection, and knowledge graph triples.

Also explained in

Compare how 2 books explain relationship type →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Graph Algorithms for Data Science. The section links point to the parts of the book it draws on.