8

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

ayan_2587
  • 833
  • 2
  • 11
  • 21

1 Answers1

5

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.

Scott Wardlaw
  • 652
  • 1
  • 8
  • 13
Stefan Armbruster
  • 39,465
  • 6
  • 87
  • 97
  • Thanks for your reply Stefan !!! I am actually planning to store the conversation in a property of a relationship between the two nodes being represnted as users. I would be storing the messages along with timestamps in json format. Please let me know if this approach sounds good !!! Thanx – ayan_2587 Sep 28 '13 at 08:02
  • That's okay if the message is not "a thing of it's own" in the context of your application. If you e.g. want later people rate or tag messages they're hidden. If you have modelled them explicitly as node, they are referenceable from nodes representing tags or ratings. – Stefan Armbruster Sep 28 '13 at 09:56
  • @StefanArmbruster The link to documentation is not working. – tuxdna Sep 27 '16 at 09:00
  • As I understand it, array properties are deprecated/removed – GreenAsJade May 10 '19 at 08:43
  • What's the source of that information? It's definitely wrong, array properties won't get removed at all. – Stefan Armbruster May 12 '19 at 14:58