I wish to make use of a graph database using php. Are you able to explain some assets on where you'll get began? Can there be any example code / tutorial available? Or are there more techniques of storing data that report to one another in totally random/abstract situations?
Very abstract illustration of the relations needed: John pertains to Mary, both connect with School, John is Tall, Mary is Short, John has Blue Eyes, Mary has Eco-friendly Eyes, query I would like is which individuals are based on 'Short somebody that has Eco-friendly Eyes and visit School' -> answer John
TrackA -> ArtistA -> ArtistB -> AlbumA -----> [ label ] -> AlbumB -----> [ A ] -> TrackA:Remix -> Genre:House -> [ Album ] -----> [ label ] TrackB -> [ C ] [ B ]
Which Genre is TrackB nearer to? answer: House - since it is associated with Album C, which relates to TrackA and relates to Genre:House
Get all Genre:House related albums of Label A : result: AlbumA, AlbumB - simply because they have TrackA which relates to Genre:House
It's possible in MySQL however it would need a fixed group of characteristics/posts for every item along with a complex non-flexible query, rather I want every attribute to become a product alone and rather than 'belonging' to something, to become 'related' to something.
There's some work going onto result in the Neo4j graph database offered by PHP, see this wiki page to learn more! Concerning how to model your domain like a graph, the user subscriber list is commonly pretty awesome.
Update: there's now a brief getting began blog publish for any PHP neo4j Relaxation client.
Sounds in my experience a bit just like a "typical" Prolog problem... the industry quite different programming language than PHP. But possibly you can use popen.
Or else you define an SQL table with posts [ id, predicate, atom1, atom2 ], to keep the truthness of "Mary has Eco-friendly Eyes": predicate = "has", atom1 = "Mary", atom2 = "Eco-friendly Eyes".
You now could join and filter the predicates and characteristics using the SQL of your liking.
It appears just like a semantic web problem. So you've to determine the best way to use PHP and also the semantic web together. Maybe this link http://bnode.org/blog/2009/05/25/back-from-new-you are able to-semantic-web-for-php-designers-trip might help?
It type of seems like you need to approach it by doing this:
1) Code a graph object that enables you to query your computer data how you want.
2) Write a persistence layer for the object
3) optimize the calls which do your query's within the graph resist use database calls when appropriate (for instance, if you want to conserve memory).
My suggestion would be to choose a Java-based graph DB like OrientDB or neo4j after which utilize it through the PHP/Java bridge. Soon neo4j (and sooner or later OrientDB too) should get native php support and you will replace the bridge with native access.
Take additionally a turn to this short article about using OrientDB with PHP: http://www.odino.org/346/orientdb-the-graph-db-for-the-web
well taking into consideration this is baby, it could be interesting to notice that can be done this type of query with every rdf datastore that supports sparql or comparable languages.