Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storing data as an array/list on neo4j property

I am fairly new to Neo4j and have the following problem at hand. I am trying to develop a social networking site wherein I would like to store the message exchanged between two users on their relationship property. For this, I am trying to store all their messages in the form of array/list on a relationship property. Can you please suggest if Neo4j provides such types of operation.

I would also like to know if I could just insert my message on this relationship property and the array/List updates(i.e adds new message on the next index)

For ex:

User1 -> User2 : Hi, whats up 
User2 -> User1 : Hi, I am in college

So the relationship property stores the message in the form of list such as:
["Hi,Whats up", "Hi, I am in college"]

Something in this manner..... Thanks

like image 719
ayan_2587 Avatar asked Sep 24 '13 18:09

ayan_2587


1 Answers

Neo4j supports array properties, see http://neo4j.com/docs/rest-docs/current/#rest-api-property-values.

However I'm not sure if you're using a good modeling approach here. If you store all the messages in an array you don't have the timeline of the conversation explicit in the graph. Even worse if a User1 sends 2 messages to User2 without a response from User2 in between, you'll don't know any longer who was the sender and receiver.

Therefore think of introducing a node representing a conversation. The conversation is related to two users. Another relationship points to the start (or end) of the message flow within this conversation. The messages itself are linked with NEXT and/or PREVIOUS relationships to each other.

like image 194
Stefan Armbruster Avatar answered Sep 22 '22 00:09

Stefan Armbruster