Having some fun with Spring Boot 3.4.3, Neo4J, and Graph Databases.
AWS defines Graph Databases as follows:
"A graph database is a systematic collection of data that emphasizes the relationships
between the different data entities. The NoSQL database uses mathematical graph theory
to show data connections."
I've used Graph-Theoretic approaches in several ways:
- NoSQL - relational aggregation (in leiu of JOIN statements, JOIN tables, Map-Reduce operations, and/or multiple DBRefs) - mostly a mix of Mongo DB, Dynamo DB.
- GraphQL
- A bit of AWS Neptune and Neo4J (but without standing up the DB's or configuring them).
Neo4J Cypher uses ASCII Art Syntax for queries typified by the scheme:
(nodes)-[:CONNECT_TO]→(otherNodes)
(MyNode)-[:VERB_OR_RELATION_TO]→(MyOtherNode)
docker-compose up
# If using Docker Compose Engine V2:
docker compose up
keytool -genkey \
-alias bootexample \
-keystore bootexample.p12 \
-storetype PKCS12 \
-keyalg RSA \
-storepass af3DF*34afefwefehu \
-validity 730 \
-keysize 4096
Exec into the neo4j
instance:
cypher-shell -u neo4j -p examplepw
$ > Match (c:Course {name: "Art"}) - [r:HAS_STUDENT] -> (s:Student) RETURN c, collect(r), collect(s);
$ > MATCH (c:Course {name: "Art"}) RETURN c;
$ > MATCH (s:Student {firstname: "Class", lastname: "Dunce"}) RETURN s;
Other CQL queries are available here.
(Some) Acceptance and Live Integration Tests are available here through Postman. (Some example Unit Tests have also been added and configured.)
- Access to the built-in view here is now deprecated.
- Using the recommended
docker-compose.yml
setting:NEO4J_AUTH=neo4j/examplepw
doesn't appear to stick. One can still log in afterwards withneo4j/neo4j
(the default, and it will request an immediate password change).- As such, I've opted to use
neo4j-admin set-initial-password examplepw
in the Dockerfile instead.
- As such, I've opted to use
- https://docs.spring.io/spring-data/neo4j/reference/getting-started.html
- https://neo4j.com/docs/cypher-manual/current/queries/concepts
- https://aws.amazon.com/nosql/graph
- https://www.liquidweb.com/blog/neo4j-graph-database-installing-neo4j-on-ubuntu-20-04/
- https://github.com/neo4j-examples/movies-java-spring-data-neo4j/tree/main
- https://www.baeldung.com/spring-data-neo4j-intro
- https://neo4j.com/docs/operations-manual/current/docker/docker-compose-standalone/