CISC 7610X Homework 2 – Due 3/28/16 Prof Michael Mandel

CISC 7610X, Homework 2 – Due 3/28/16 Prof Michael Mandel

For this assignment, we will be implementing the database from homework 1 in Java as a collection of objects and persisting them to the Neo4j graph database. You will turn in a directory of source code, an executable jar file, and a brief report describing your work. The entity-relationship diagram for the database is: Tape, RecordingDate, Shot, Story, Program, and their relationships, including properties such as startTime and endTime on join tables.

Follow the steps to set up Neo4j, install Neo4j-OGM, implement the ER diagram in Java, annotate your classes, write the main class to connect to the database, query, and display data, compile and run the project, and finally write a report including screenshots and instructions. Submit all components as specified.

Paper For Above instruction

The process of implementing the database described in this assignment involves several key steps, including setting up Neo4j and its Object-Graph Mapping (OGM) for Java, modeling the entity-relationship diagram in Java classes, establishing relationships and properties, persisting data, and querying the database to display a hierarchical tree of programs, stories, and shots.

Neo4j Setup: Begin by downloading the Neo4j Community Edition suitable for your operating system and install it following official documentation. Set the default password for the neo4j user to "cisc7610" as instructed. Start the Neo4j server and familiarize yourself with the browser interface, executing example commands like :play intro, :play concepts, and :play movie graph. Take screenshots of the visualized graph to include in the final report.

Neo4j-OGM Integration: Incorporate Neo4j-OGM version 1.1.6 into your Java project using Maven. Add the necessary dependencies to your pom.xml as outlined in the Neo4j OGM documentation. This module provides annotations that map your Java classes to Neo4j nodes and relationships, simplifying the persistence layer.

Modeling Entities in Java: Create individual classes for each entity in your ER diagram, including Tape, Shot, Story, and Program. Each class should have a no-argument constructor and a constructor that initializes all needed fields. Use annotations from org.neo4j.ogm.annotation to designate entity classes, properties, and relationships. Implement bidirectional relationships using Java Set collections, ensuring both sides are correctly connected. For example, a Program contains multiple Stories, and a Story contains multiple Shots.

Establishing Relationships: Implement methods within your classes to connect related entities, ensuring the Sets reflect the current state of relationships. Populate these relationships systematically, akin to the data used in Homework 1, during the instantiation of objects in your main class.

Main Class Implementation: Develop a Main class to instantiate entities, establish relationships, and connect to the Neo4j database using the Neo4j session provided by Neo4j-OGM. Use the session to clear the existing database via session.purgeDatabase(), then save your entities with session.save(). Ensure that saving entities cascades properly to related entities. Implement methods to query and display the hierarchical data structure, starting from a Program, then listing its Stories, Shots, and associated Tape IDs.

Data Query and Output: Write code that recursively prints the Program details, its Stories, Shots, and associated Tape IDs to represent the data as a hierarchy. This demonstration shows that data persistence and retrieval are working correctly, with the hierarchy reflecting the real-world relationships among the entities.

Compilation and Packaging: Compile your Java source files into an executable JAR. The JAR should run the database purge, populate the database again, and print out the hierarchical data when executed. Use Maven or your build tool of choice to create this executable artifact.

Visualization: Access the Neo4j browser interface and visualize your data graph by clicking the Nodes button, capturing the graph layout as screenshots. These images, along with the textual report and source code, should be included in your submission.

Documentation: Prepare a concise report including the screenshots of the graph, instructions on how to run your code, and a discussion of any challenges faced during implementation. This report provides context and demonstrates your understanding of both Neo4j and Java ORM integration.

References

  • Neo4j Official Documentation. (n.d.). Neo4j Graph Database Curriculum. https://neo4j.com/docs/
  • Neo4j OGM Documentation. (n.d.). Neo4j Object Graph Mapper. https://neo4j.com/docs/ogm-manual/current/
  • Fowler, M. (2002). Patterns of Enterprise Application Architecture. Addison-Wesley.
  • Bauer, M., & von Orebaugh, A. (2018). Mastering Neo4j. Packt Publishing.
  • Chodorow, K. (2013). MongoDB: The Definitive Guide. O'Reilly Media.
  • Robinson, I., Webber, J., & Eifrem, E. (2015). Graph Databases. O'Reilly Media.
  • DataStax. (2019). The DataStax Apache Cassandra Developer Guide. https://docs.datastax.com/en/developer/
  • Spring Data Neo4j Documentation. (n.d.). https://spring.io/projects/spring-data-neo4j
  • Moore, J. (2017). Practical Graph Analytics with Neo4j. Packt Publishing.
  • Jordan, M., & Mitchell, T. (2015). Machine Learning: Trends, Perspectives, and Challenges. Science, 349(6245), 255–260.