Game of Thrones Family Graph using Neo4j

Game of Thrones Family Graph using Neo4j

Created By Debasis Das (15-Apr-2016)

In this post we will create the Game of Thrones Family Tree using Neo4j Graph Database.

Game Of Thrones Neo4j Family Tree

Game Of Thrones Neo4j Family Tree

Game Of Thrones Neo4j Family Tree

Game Of Thrones Neo4j Family Tree

Node and Relationship Creation Script for Game of Thrones

CREATE (WESTEROS:kingdom {name:'WESTEROS'}),
(ARRYN:house {houseName:'ARRYN', FLAG:'BIRD'}),
(BARATHEON:house {houseName:'BARATHEON', FLAG:'HORNED DEER'}),
(LANNISTER:house {houseName:'LANNISTER', FLAG:'LION'}),
(TULLY:house {houseName:'TULLY', FLAG:'FISH'}),
(TYRELL:house {houseName:'TYRELL', FLAG:'SHIELD'}),
(GREYJOY:house {houseName:'GREYJOY', FLAG:'CROSS'}),
(TARGARYEN:house {houseName:'TARGARYEN', FLAG:'DRAGON'}),
(STARK:house {houseName:'STARK', FLAG:'WOLF'}),
(KINGS_COUNCIL:house {houseName:'KINGS COUNCIL', FLAG:''}),
ARRYN-[:house]->WESTEROS,
BARATHEON-[:house]->WESTEROS,
LANNISTER-[:house]->WESTEROS,
TULLY-[:house]->WESTEROS,
TYRELL-[:house]->WESTEROS,
GREYJOY-[:house]->WESTEROS,
TARGARYEN-[:house]->WESTEROS,
STARK-[:house]->WESTEROS,
(JOANNA:person {name:'JOANNA'}),
(TYWIN:person {name:'TYWIN'}),
(KEVAN:person {name:'KEVAN'}),
(DORNA:person {name:'DORNA'}),
(GRAND_MASTER_PYCELLE:person {name:'GRAND MASTER PYCELLE',nickName:'COUNCELLOR HEALER'}),
(LORDPETERBAELISH:person {name:'LORD PETER BAELISH',nickName:'LITTLE FINGER, MASTER OF COIN'}),
(JON:person {name:'JON',nickName:'HAND OF KING'}),
(VARYS:person {name:'VARYS',nickName:'MASTER OF WHISPERERS'}),
(STANNIS:person {name:'STANNIS',nickName:'MASTER OF SHIPS'}),
(RENLY:person {name:'RENLY',nickName:'MASTER OF LAWS'}),
(ROBERT:person {name:'ROBERT',nickName:'THE KING'}),
(CERSEI:person {name:'DOARNA',nickName:''}),
(SER_JAIME:person {name:'SER JAIME',nickName:'KNIGHT OF THE KINGSGUARD'}),
(TYRION:person {name:'TYRION',nickName:'THE IMP'}),
(RICKARD:person {name:'RICKARD'}),
(BENJEN:person {name:'BENJEN',nickName:''}),
(BRANDON:person {name:'BRANDON',nickName:''}),
(LYANNA:person {name:'LYANNA',nickName:''}),
(WYLLA:person {name:'WYLLA',nickName:''}),
(EDDARD:person {name:'EDDARD',nickName:'NED'}),
(HOSTER:person {name:'HOSTER',nickName:''}),
(CATELYN:person {name:'CATELYN',nickName:''}),
(LYSA:person {name:'LYSA',nickName:''}),
(EDMURE:person {name:'EDMURE',nickName:''}),
(MACE:person {name:'MACE',nickName:''}),
(WILLAS:person {name:'WILLAS',nickName:''}),
(GARLAN:person {name:'GARLAN',nickName:''}),
(MARGAERY:person {name:'MARGAERY',nickName:''}),
(LORALTYRELL:person {name:'LORAS TYRELL',nickName:'KNIGHT'}),
(JOFFREY:person {name:'JOFFREY',nickName:''}),
(MYRCELLA:person {name:'MYRCELLA',nickName:''}),
(TOMMEN:person {name:'TOMMEN',nickName:''}),
(LANCEL:person {name:'LANCEL',nickName:'KINGS SQUIRE'}),
(JONSNOW:person {name:'JON SNOW',nickName:'BASTARD'}),
(ROBB:person {name:'ROBB',nickName:''}),
(SANSA:person {name:'SANSA',nickName:''}),
(ARYA:person {name:'ARYA',nickName:''}),
(BRAN:person {name:'BRAN',nickName:''}),
(RICKON:person {name:'RICKON',nickName:''}),
(SERBARRISTAN:person {name:'SER BARRISTAN SELMY',nickName:'KINGS GUARD COMMANDER'}),
(SERILYNPAYNE:person {name:'SER ILYN PAYNE',nickName:'HEADSMAN'}),
(SANDORCLEGANE:person {name:'SANDOR CLEGANE',nickName:'THE HOUND BODYGAURD'}),
(SERGREGORCLEGANE:person {name:'SER GREGOR CLEGANE',nickName:'THE MOUNTAIN'}),
(JANOSSLYNT:person {name:'JANOS SLYNT',nickName:'COMMANDER OF THE CITY WATCH'}),
(AERYSII:person {name:'AERYSS II',nickName:'MAD KING'}),
(RHAELLA:person {name:'RHAELLA',nickName:''}),
(ELIA:person {name:'ELIAN',nickName:''}),
(RHAEGAR:person {name:'RHAEGAR',nickName:''}),
(VISERYS:person {name:'VISERYS',nickName:''}),
(DAENERYS:person {name:'DAENERYS',nickName:'MOTHER OF THE DRAGONS'}),
(KHAL_DRAGO:person {name:'KHAL DRAGO',nickName:''}),
(RHAENYS:person {name:'RHAENYS',nickName:''}),
(AEGON:person {name:'AEGON',nickName:''}),
(SER_JORAH_MORMONT:person {name:'SER JORAH MORMONT',nickName:''}),
(BALON:person {name:'BALON', nickName:''}),
(ASHA:person {name:'ASHA', nickName:''}),
(MARON:person {name:'MARON', nickName:''}),
(RODRIK:person {name:'RODRIK', nickName:''}),
JOANNA-[:OF_house]->LANNISTER,
TYWIN-[:OF_house]->LANNISTER,
KEVAN-[:OF_house]->LANNISTER,
DORNA-[:OF_house]->LANNISTER,
STANNIS-[:OF_house]->BARATHEON,
RENLY-[:OF_house]->BARATHEON,
ROBERT-[:OF_house]->BARATHEON,
RICKARD-[:OF_house]->STARK,
HOSTER-[:OF_house]->TULLY,
MACE-[:OF_house]->TYRELL,
AERYSII-[:OF_house]->TARGARYEN,
RHAELLA-[:OF_house]->TARGARYEN,
BALON-[:OF_house]->GREYJOY,
JOANNA-[:MARRIED_TO]->TYWIN,
KEVAN-[:MARRIED_TO]->DORNA,
CERSEI-[:MARRIED_TO]->ROBERT,
CERSEI-[:LOVES]->SER_JAIME,
EDDARD-[:MARRIED_TO]->CATELYN,
DAENERYS-[:MARRIED_TO]->KHAL_DRAGO,
ELIA-[:MARRIED_TO]->AERYSII,
CERSEI-[:CHILD_OF]->TYWIN,
SER_JAIME-[:CHILD_OF]->TYWIN,
TYRION-[:CHILD_OF]->TYWIN,
LANCEL-[:CHILD_OF]->KEVAN,
BENJEN-[:CHILD_OF]->RICKARD,
BRANDON-[:CHILD_OF]->RICKARD,
LYANNA-[:CHILD_OF]->RICKARD,
WYLLA-[:CHILD_OF]->RICKARD,
EDDARD-[:CHILD_OF]->RICKARD,
CATELYN-[:CHILD_OF]->HOSTER,
LYSA-[:CHILD_OF]->HOSTER,
EDMURE-[:CHILD_OF]->HOSTER,
WILLAS-[:CHILD_OF]->MACE,
GARLAN-[:CHILD_OF]->MACE,
MARGAERY-[:CHILD_OF]->MACE,
LORALTYRELL-[:CHILD_OF]->MACE,
JOFFREY-[:CHILD_OF]->ROBERT,
MYRCELLA-[:CHILD_OF]->ROBERT,
TOMMEN-[:CHILD_OF]->ROBERT,
ASHA-[:CHILD_OF]->BALON,
MARON-[:CHILD_OF]->BALON,
RODRIK-[:CHILD_OF]->BALON,
JONSNOW-[:CHILD_OF]->EDDARD,
ROBB-[:CHILD_OF]->EDDARD,
SANSA-[:CHILD_OF]->EDDARD,
ARYA-[:CHILD_OF]->EDDARD,
BRAN-[:CHILD_OF]->EDDARD,
RICKON-[:CHILD_OF]->EDDARD,
RHAEGAR-[:CHILD_OF]->AERYSII,
VISERYS-[:CHILD_OF]->AERYSII,
DAENERYS-[:CHILD_OF]->AERYSII

Query to get all nodes and relationship in Neo4j

START N=NODE(*) RETURN N;
Posted in Graph Database Tagged with: , , , ,
One comment on “Game of Thrones Family Graph using Neo4j
  1. Saurav Bhuyan says:

    A must-needed refresher just-in-time. Cool trick!!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Recent Posts


Hit Counter provided by technology news