68. require 'neo4j'
class Person
include Neo4j::NodeMixin
property :name, :mutant
index :name, :mutant
has_n :interests
has_n :dates
has_n :marriages
def initialize(name, mutant = true)
name = name
mutant = mutant
end
end
Friday, November 20, 2009
69. Neo4j::Transaction.run do
magneto = Person.new('Magneto')
esme = Person.new('Esme')
rogue = Person.new('Rogue')
magda = Person.new('Magda', false)
wasp = Person.new('Wasp', false)
magneto.interests << wasp
magneto.marriages << magda
magneto.dates << rogue
esme.interests << magneto
magda.marriages << magneto
rogue.dates << magneto
end
Friday, November 20, 2009
70. magneto = Person.find(:name => 'Magneto')
# Who likes Magneto?
magneto.relationships.incoming(:interests).nodes
# Which non-mutants has Magneto dated?
magneto.dates{ !mutant? }.to_a
Friday, November 20, 2009
75. mysql> SELECT * FROM people LIMIT 1 G
*************************** 1. row ***************************
id: 1
content: ---
company: Daily Planet
name: Jimmy Olsen
title: Superman’s Pal
Friday, November 20, 2009
76. mysql> desc people;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id | int(11) | YES | | NULL | |
| name | varchar(50) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
mysql> desc attributes;
+-----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+-------+
| id | int(11) | YES | | NULL | |
| person_id | int(11) | YES | | NULL | |
| attribute | varchar(50) | YES | | NULL | |
| value | varchar(100) | YES | | NULL | |
+-----------+--------------+------+-----+---------+-------+
Friday, November 20, 2009
90. Database
List
http://internetmindmap.com/database_software
NoSQL
Google
Group
http://groups.google.com/group/nosql-‐discussion
NoSQL
Ecosystem
http://www.rackspacecloud.com/blog/2009/11/09/nosql-‐ecosystem/
Wave!
Friday, November 20, 2009