Create two nodes with labels and properties in a Neo4j® database. Access the data in the nodes.
Assume that you have graph data stored in a Neo4j database that represents a social neighborhood. This database has seven nodes and eight relationships. Each node has only one unique property key name
with a value ranging from User1
through User7
. Each relationship has the type knows
.
Create a Neo4j database connection using the URL http://localhost:7474/db/data
, user name neo4j
, and password matlab
.
Check the Message
property of the Neo4j connection object neo4jconn
. The blank Message
property indicates a successful connection.
Create a table with two rows that contain the names and job titles of two people (users).
Create two nodes that represent these two people in the database by using the Neo4j database connection. Use the 'Labels'
name-value pair argument to specify the node labels Person
and Employee
. Then, use the 'Properties'
name-value pair argument to specify the node properties using the props
table.
nodeinfo=2×3 table
NodeLabels NodeData NodeObject
__________ ____________ ___________________________________
28 {2×1 cell} [1×1 struct] [1x1 database.neo4j.http.Neo4jNode]
21 {2×1 cell} [1×1 struct] [1x1 database.neo4j.http.Neo4jNode]
nodeinfo
is a table with two rows, one for each person. The table contains these variables:
Node label
Node data
Neo4jNode
object
Access the properties of the first node. This structure contains the properties of the node as fields and values.
ans = struct with fields:
Title: 'Analyst'
Name: 'User8'
Access the Neo4jNode
object for the first node.
data =
Neo4jNode with properties:
NodeID: 28
NodeData: [1×1 struct]
NodeLabels: {2×1 cell}
data
is a Neo4jNode
object with these properties:
Node identifier
Node data
Node label
Close the database connection.