Showing posts with label Neo4j. Show all posts
Showing posts with label Neo4j. Show all posts

Friday, 23 March 2012

NeoClipse and Neo4j

The home icon is the built-in starting point* for my database. From there I can traverse nodes (data stores) relationships (named links between data stores) to find what I am looking for. I am going to follow the relationship marked 'NUMBER'. This is a boring link to the  number nodes, there is one node for each number from 1-200. From there I select the node with numberValue=128. The database only contains flat horses so this should only link to very good horses.

* For a similar example check out the Visual Thesaurus. I believe the word 'set' will keep you busy for a while.

Tuesday, 17 January 2012

Why I Dropped Mysql For Neo4j

If you would like to run the queries in this post the SQL is available here.

One segment of the Horse Racing Information System I worked on in college involved finding horses from a given race that had raced against each other.

This is the more general example where I have a given horse and wish to find all the horses they have run against:

SELECT h2.horsename
FROM horse h1
JOIN raceentrants r1 ON h1.horseid = r1.horseID
JOIN raceentrants r2 ON r1.raceID = r2.raceID
JOIN horse h2 ON h2.horseid = r2.horseID
WHERE r1.horseID =1
AND h2.horsename NOT
IN (
'Horse A'

My representation of the steps involved are:

  1. Select the correct horse from the Horse table
  2. Join this to the RaceEntrants table on horseId to find all the horse's races
  3. Join this to the RaceEntrants table on raceId to find all other entrants in these races
  4. Join this to the Horse table to find the other horses
  5. Make sure we do not return the original horse
If I really wantd just the names I could have used 'distinct' but it is more likely that in a ful database you would be returning on all horse-race combinations.

This is quite cumbersome but it gets worse ...

Monday, 16 January 2012

Finding Anagrams With Neo4j (Pattern Matching)

In my previous post on this subject I showed how I found anagrams by implementing ReturnableEvaluator. After I finished writing that program, I found this article that included a section on pattern matching. I wrote a method to see how this would work.

Note: the problem I am trying to solve is from horse racing. I cannot currently solve that problem because I do not have the information in a database. This is an analogous problem where the could easily be placed in the database.

Monday, 9 January 2012

Finding Anagrams With Neo4j (Returnable Evaluator)

I have a Neo4j database with 128,985 words from The English Open Word List. Each word is stored as 'node' and 'done' are in the video below. The ideas here was not to solve anagrams but to solve a problem where multiple pieces of information had to be found at a node. Here that means does this word have exactly 1 'n', does this word have exactly one 'o', and so forth.

Arrow Key Nav