2. Neo4j Quick Review
• Benefits of a Graph Database
– Super fast when querying complex, highly connected data
– Schema-less and Efficient storage of Semi Structured Information
– Fast deep traversal instead of slow SQL queries that span many table
joins
– Very natural to express graph related problems with traversals
(recommendation engine, shortest parth etc..)
source:
http://neo4j.rubyforge.org/guides/why_gra
ph_db.html
3. Neo4j Quick Review
•
Graph Database
– A graph database is a database that uses graph structures with nodes, edges, and properties
to represent and store data (Wikipedia)
•
Node
– An entity in the database typically representing a “thing”
•
Relationship
– A one way link between two nodes
•
Node/Relationship Property
– A key-value pair that can be attached to a node or relationship
– example: { “name” : “Nicholas” }
•
Label
– A “tag” that can be attached to a node in order to make querying faster and more convenient
3
7. What Are Our Options?
• Java
– Kind of heavyweight. Bit more complex to host. But good for
control and optimizing queries.
• Ruby
– Neo4j.rb
• Uses JRuby which is still Java under the hood.
– Neography
• Uses Neo4j’s RESTful HTTP web services
• Not as fast as other options, but simple and easier to deploy and host
• Other Options
– Node.js, Python, PHP, .NET, Go, etc
– http://www.neo4j.org/develop/drivers
7
8. Our Example Today
• Why Ruby?
– Simple, popular, easy to learn.
• Why Not X Instead of Ruby?
• Why Neography?
– Communicates with Neo4j via HTTP, simply point your code to a
Neo4j server and get started
– Downside: not the best documentation or examples for newcomers
(hence this meetup)
– https://github.com/maxdemarzi/neography
• Why aren’t we looking at a Rails example?
• Thoughts on ActiveRecord
8
9. Today (part 1) We’ll Cover
• Writing Code That:
– creates nodes for Users
– creates relationships for Users
– using indexes
• Writing a Few Tests To Demonstrate
• (No webpages, Sorry , Keeping it Simple)
9
10. Technologies We’ll Cover
•
Neo4j
– Download, start and make sure Neo4j is running
– Checkout the Data Browser at http://localhost:7474
•
Ruby
– Ruby is a programming language we will use to talk to the Neo4j server
– Install Ruby: https://www.ruby-lang.org/en/installation
– Run `ruby –v` to make sure it is installed properly
•
Sinatra
– A simple framework for writing Ruby web applications or web service APIs
– Remember, use whatever language and framwork you like. Sinatra is just an example.
– (more information: http://www.sinatrarb.com)
– (great intro: http://www.slideshare.net/knaveofdiamonds/web-simplicity-ruby-sinatra-rack )
10