Hi Jordi, thanks for reaching out and for already taking so much into consideration.
I think your idea is a really good fit for a graph database like Neo4j. Your entities will be represented as nodes (with labels or attributes as tags), and connections as named relationships. I recommend that you have a look at our online developer resources on neo4j.com/developer <http://neo4j.com/developer> and our online course neo4j.com/online-course <http://neo4j.com/online-course> to learn our query language which allows you get started quickly. Downloading and starting Neo4j should be fast too (it also comes with integrated guides and tutorials). I add some example queries for your use-cases. Feel free to ask more. And perhaps it makes sense to take your email + some sample data and the cypher queries and turn it into a GraphGist page <http://graphgist.neo4j.com/about> for documentation and discussion. Michael > Am 15.03.2015 um 10:42 schrieb Jordi Chacón <[email protected]>: > > Hi! > > I am working on a project where a graph database might be a good fit for data > storage. > > Such databases are completely new to me, so I'm not sure they would be the > right approach. If so, I would also appreciate some input on the data model I > have come up with. > > > What do I want to store? > > Examples of things I want to store from the perspective of a user: > - store that I am grateful to person P1 because of reason R1, R2 and R3. (me:Person)-[:GRATEFUL_TO {reason:[R1,R2,R3]}]->(p1:Person) alternatively model Gratefulness as a node to connect other information to it. > - store that I did activity A1 with person P1 and P2, that I have a positive > memory PM1 about it and that we took pictures PI1 and PI2. (me:Person)-[:DID_ACTIVITY]->(a:Activity)<-[:DID_ACTIVITY]-(p1:Person),(a)<-[:DID_ACTIVITY]-(p2:Person), (a)-[:HAS_PICTURE]->(pic1:Picture) > - store that person P1 is an important person for me. (me:Person)<-[:IMPORTANT_FOR]-(p1:Person) > - store that person P1 is a person that I would like to meet more often. (me:Person)-[:WANT_MEET_MORE]->(p1:Person) > - store that I like activity A1 because I get the feeling F1 when I do it, > and because it connects to a personal value PV1 of mine. (me:Person)-[:DID_ACTIVITY]->(a:Activity)-[:CAUSES_FEELING]->(f1:Feeling), (a)-[:VALUE]->(v:Value)<-[:PERSONAL]-(me) > - store that activity A1 is a preferred activity and that it needs planning > beforehand. > > So, as you can see, a few entities in our data model are: person, activity, > image, personal value, feeling, memory and many more. > > Each entity can have relationships with many other entities. Also, some > entities like person or activity can have multiple tags like: preferred, > most_important, spontaneous, planned, look_forward_to, inspiring, and so on. > > > What do I want to query? > > I want to query things like: > - give me a person who I have done at least 2 activities with MATCH (:Person {name:"Me"})-[:DID_ACTIVITY]->(a:Activity)<-[:DID_ACTIVITY]-(p1:Person) WITH p1, count(*) as activities WHERE activities >= 2 RETURN p1 > - give me a person who I am grateful for for at least 2 reasons, and give me > those reasons MATCH (me:Person)-[g:GRATEFUL_TO]->(p1:Person) WHERE size(g.reasons) > 1 RETURN p1, g.reasons (different queries if you model gratefulness as node (see above)) > - give me a preferred activity that I have not done in a while MATCH (:Person {name:"Me"})-[did:DID_ACTIVITY]->(a:Activity:Preferred) WHERE did.when < timestamp() - 1000*3600*24* days RETURN a > - give me a personal value that is not connected to any activity MATCH (a)-[:VALUE]->(v:Value)<-[:PERSONAL]-(me:Person {name:"me"}) WHERER NOT (me)-[:DID_ACTIVITY]->(a:Activity)-[:VALUE]->(v) RETURN v > > I also want to perform many updates: > - mark this existing person as important match (p:Person {name:{name}},(me:Person {name:"me"}) CREATE (p)-[:IMPORTANT]->(me) > - mark this existing activity as spontaneous and preferred MATCH (a:Activity {name:"activity"}) SET a:Spontaneous:Preferred > - connect this existing activity with this existing personal value MATCH (v:Value {value:"value"})<-[:PERSONAL]-(me:Person {name:"me"}), (a:Activity {name:"foo"}) CREATE (a)-[:VALUE]->(v) > > The data of each user is going to be completely independent of the data from > other users, meaning that entities (nodes) from a user will not be connected > to entities from other users. There will be a few thousand entities per user. > > > With this in mind, I have a bunch of questions for you: > - are graph databases a good fit for the problem I am trying to solve? > - if so, could neo4j be a good fit too? If not, what other backends could I > look at? Neo4j would be a good fit > > A few more questions related to neo4j and my data model: > - since I want to tag my entities in multiple ways (an entity can be: > activity, preferred, spontaneous), and I want to be able to query things like > an activity who is preferred and spontaneous, should I use labels to store my > tags? Yes labels are a good fit if you also want to quickly iterate over them > - how do I store the nodes so I know to what user they belong? do I tag them > all with the user_id? Or do I create a user node and connect that one to all > other nodes belonging to that user? via the connections > - is there any library to easily and clearly visualize both the labels and > the properties of each node? you can check out alchemy.js and linkurious.js see http://neo4j.com/developer/guide-data-visualization/ <http://neo4j.com/developer/guide-data-visualization/> and http://neo4j.com/developer/ecosystem/#_visualization_libraries <http://neo4j.com/developer/ecosystem/#_visualization_libraries> Michael > > Thank you so much, any insights are greatly appreciated! > > -- > You received this message because you are subscribed to the Google Groups > "Neo4j" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
