0
Kaiso	
  -­‐	
  an	
  object	
  persistence	
  framework	
  for	
  
Python	
  and	
  Neo4j
David	
  Szo>en

onefinestay	
  ...
Overview
• About	
  onefinestay	
  
• We	
  care	
  about	
  homes	
  
• How	
  we	
  track	
  our	
  homes	
  using	
  Neo...
onefinestay	
  -­‐	
  the	
  unhotel	
  
3

©	
  Lifealike	
  Limited,	
  2013.
onefinestay	
  -­‐	
  the	
  unhotel
• Guests	
  live	
  like	
  a	
  local	
  
– but	
  with	
  services	
  and	
  ameniNe...
How	
  do	
  we	
  do	
  it?
• Provision:	
  Home	
   	
  Unhotel	
  
– Clean	
  
– Pack	
  away	
  certain	
  items	
  
•...
We	
  care	
  about	
  our	
  homes.	
  A	
  lot.
• Every	
  home	
  is	
  different	
  
• We	
  require	
  inNmate	
  know...
Previous	
  system
• Custom	
  storage	
  soluNon	
  
• Dates	
  back	
  to	
  when	
  we	
  were	
  much	
  smaller	
  
•...
New	
  system
• Want	
  to	
  model	
  our	
  homes	
  
– both	
  layout	
  and	
  contents	
  
!

• Need	
  flexibility	
 ...
Enter	
  Neo4j
• Handle	
  complex	
  data	
  structures	
  
!

• Ensure	
  extensibility	
  for	
  future	
  needs	
  
!
...
Flexibility	
  requirements
• We	
  want	
  to	
  associate	
  informaNon	
  with	
  classes	
  
as	
  well	
  as	
  objec...
Kaiso	
  -­‐	
  an	
  object	
  persistence	
  framework
# (import some stuff)!

!

class Animal(Entity):!
id = Uuid(uniqu...
Kaiso:	
  Create	
  some	
  instances
# import types, connect to db!

!

manager = Manager("http://localhost:7474/db/data/...
Instances	
  are	
  saved	
  in	
  the	
  graph...

FRIENDOF

[6]	
  Penguin:	
  Fred

13

[7]	
  Lion:	
  Tom

©	
  Lifea...
...	
  and	
  so	
  is	
  the	
  class	
  hierarchy
[1]	
  Type:	
  Animal
ISA

ISA

[4]	
  Type:	
  Herbivore

[2]	
  Typ...
Kaiso:	
  Queries	
  based	
  on	
  the	
  type	
  hierarchy
START!
Herbivore=node:persistabletype(id="Herbivore"),!
Carni...
Thank	
  you
QuesNons?	
  
!
!

Kaiso	
  
github.com/onefinestay/kaiso	
  
!
github.com/davidszo;en	
  
@davidszo;en
16

©	...
Upcoming SlideShare
Loading in...5
×

Kaiso: Modeling Complex Class Hierarchies with Neo4j - David Szotten @ GraphConnect London 2013

1,008

Published on

In this talk David will summarize business and technical use cases and introduce Kaiso. He will give a basic overview of how to use it, along with some examples of how one might use it to model complex class hierarchies. This will include some interactive code demonstrations. David will explore the main design goals of the project, the current state of the project, and take a look at what’s ahead on Kaiso’s roadmap.

Published in: Technology
1 Comment
2 Likes
Statistics
Notes
  • Hi there... nice work. Is there any reason why you did not base your work e.g. on RDF+RDFS+OWL?

    Cheers
    Achim
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
1,008
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
20
Comments
1
Likes
2
Embeds 0
No embeds

No notes for slide

Transcript of "Kaiso: Modeling Complex Class Hierarchies with Neo4j - David Szotten @ GraphConnect London 2013"

  1. 1. Kaiso  -­‐  an  object  persistence  framework  for   Python  and  Neo4j David  Szo>en
 onefinestay   ! ! ! @szo;en   github.com/davidszo;en 1 ©  Lifealike  Limited,  2013.
  2. 2. Overview • About  onefinestay   • We  care  about  homes   • How  we  track  our  homes  using  Neo4j   • Kaiso  demo 2 ©  Lifealike  Limited,  2013.
  3. 3. onefinestay  -­‐  the  unhotel   3 ©  Lifealike  Limited,  2013.
  4. 4. onefinestay  -­‐  the  unhotel • Guests  live  like  a  local   – but  with  services  and  ameniNes  of  a  hotel   ! • Members  with  disNncNve  homes  earn
 hassle-­‐free  income   ! • From  just  a  handful  of  homes  in  2010  to
 over  1000  homes  in  4  ciNes  in  2013 4 ©  Lifealike  Limited,  2013.
  5. 5. How  do  we  do  it? • Provision:  Home    Unhotel   – Clean   – Pack  away  certain  items   • Make  wardrobe  space   • Deprovision:  Unhotel    Home   – Clean   – Put  everything  back 5 ©  Lifealike  Limited,  2013.
  6. 6. We  care  about  our  homes.  A  lot. • Every  home  is  different   • We  require  inNmate  knowledge   ! • For  guests:  “I  can’t  walk  up  stairs”,  “Where  is  the  iron?”   • For  members:  “Please  put  my  fragile  vase  away  before   the  guests  arrive”   • For  us:  “How  much  bed  linen  do  I  need  to  take  to  this   home  for  this  booking?” 6 ©  Lifealike  Limited,  2013.
  7. 7. Previous  system • Custom  storage  soluNon   • Dates  back  to  when  we  were  much  smaller   • Problems:   – Siloed   – Hard  to  query    denormalised  copies 7 ©  Lifealike  Limited,  2013.
  8. 8. New  system • Want  to  model  our  homes   – both  layout  and  contents   ! • Need  flexibility   – Our  needs  are  likely  to  grow  and  change   ! • Track  not  only  objects,  but  their  classes   – Ideally  treat  the  taxonomy  itself  as  data 8 ©  Lifealike  Limited,  2013.
  9. 9. Enter  Neo4j • Handle  complex  data  structures   ! • Ensure  extensibility  for  future  needs   ! • Easy  to  create  powerful  queries   ! • Makes  for  a  nice  conceptual  model  of  our  data 9 ©  Lifealike  Limited,  2013.
  10. 10. Flexibility  requirements • We  want  to  associate  informaNon  with  classes   as  well  as  objects   – This  dishwasher  is  of  make  Electropool   – (All)  appliances  need  PAT  tesNng   ! • Unlike  convenNonal  object  mappers,  the   taxonomy/class  hierarchy  needs  to  be  editable   by  users,  and  so  should  be  part  of  the  data 10 ©  Lifealike  Limited,  2013.
  11. 11. Kaiso  -­‐  an  object  persistence  framework # (import some stuff)! ! class Animal(Entity):! id = Uuid(unique=True)! name = String()! friend_of = Outgoing(FriendOf)! ! class Carnivore(Animal): pass! class Herbivore(Animal): pass! ! class Penguin(Herbivore):! favourite_ice_cream = String()! ! class Lion(Carnivore):! n_siblings = Integer()! 11 ©  Lifealike  Limited,  2013.
  12. 12. Kaiso:  Create  some  instances # import types, connect to db! ! manager = Manager("http://localhost:7474/db/data/")! ! manager.save(Lion)! manager.save(Penguin)! ! # create some instances! fred = Penguin(name="Fred")! tom = Lion(name="Tom")! ! relation = FriendOf(fred, tom)! ! manager.save(fred)! manager.save(tom)! manager.save(relation) 12 ©  Lifealike  Limited,  2013.
  13. 13. Instances  are  saved  in  the  graph... FRIENDOF [6]  Penguin:  Fred 13 [7]  Lion:  Tom ©  Lifealike  Limited,  2013.
  14. 14. ...  and  so  is  the  class  hierarchy [1]  Type:  Animal ISA ISA [4]  Type:  Herbivore [2]  Type:  Carnivore ISA ISA [3]  Type:  Lion [5]  Type:  Penguin INSTANCEOF INSTANCEOF FRIENDOF [6]  Penguin:  Fred 14 [7]  Lion:  Tom ©  Lifealike  Limited,  2013.
  15. 15. Kaiso:  Queries  based  on  the  type  hierarchy START! Herbivore=node:persistabletype(id="Herbivore"),! Carnivore=node:persistabletype(id="Carnivore")! ! MATCH! Carnivore <-[:ISA*]-()<-[:INSTANCEOF]-(carnivore),! Herbivore <-[:ISA*]-()<-[:INSTANCEOF]-(herbivore),! ! ! (herbivore)-[:FRIENDOF]->(carnivore)! RETURN! "The herbivore",! herbivore.name,! “is a friend of the carnivore",! carnivore.name;! ! => +--------------------------------------------------------------------+! => | "The herbivore" | "Fred" | "is a friend of the carnivore" | “Tom" | => +--------------------------------------------------------------------+ 15 ©  Lifealike  Limited,  2013.
  16. 16. Thank  you QuesNons?   ! ! Kaiso   github.com/onefinestay/kaiso   ! github.com/davidszo;en   @davidszo;en 16 ©  Lifealike  Limited,  2013.
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×