NYC Neo4j Meetup 003 Slides: Realistic Neo4j with Ruby (Part 1)
-
Upload
nick-manning -
Category
Technology
-
view
104 -
download
0
description
Transcript of NYC Neo4j Meetup 003 Slides: Realistic Neo4j with Ruby (Part 1)
1
Meetup Jan 29th, 2014
Realistic Neo4j: Neo4j + Ruby (part 1)
source: http://neo4j.rubyforge.org/guides/why_graph_db.html
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..)
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
4
Examplenode node
property: valueproperty: valueproperty: value
label
relationship type
label
name: ‘Joe’age: 27
:User
:UPLOADS
:Photo
filename: ‘cat.png’
on: 2013-11-18
5
Example
name: ‘Joe’age: 27
:User
:FOLLOWS
weight: 10
name: ‘Jane’bday: 19800115
name: ‘Joe’age: 27
filename: ‘cat.png’
:FOLLOWS
weight: 2
:LIKES
on: 20131118
:PHOTO
6
Queries are Traversals
end
start
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
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
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)
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-r
ack
)
11
Finding Help
– https://github.com/seenickcode/nycneo
4j-sinatra-example-1/tree/master/meetu
p-003-sinatra-example-1
– Neography
– http://maxdemarzi.com/2012/01/04/gett
ing-started-with-ruby-and-neo4j/
– https://github.com/neo4j-contrib/neo4j-h
eroku-seeds/tree/master/ruby/sinatra-ne
ography
12
Thanks for Coming
• @seenickcode
• [email protected] for
questions
• Next time we’ll expand on this!
• Want to present? Let me know.