How do I model social network connections in neo4j?

SeanKilleen

Thinking about how to model a simple graph for a Side project.

The project's users will be able to add social networks so that they can find other users with social information.

Given neo4j's architecture, which I'm new to, is the correct way to do this:

  1. A different type for each social network (e.g, twitter, LinkedIn) and a relationship of user --> has_twitter_account / user --> has_linkedin_account with relevant keys
  2. one type (SocialMediaAccount) with user --> has_socialmedia_acct relationship with relevant keys In a more generic way and an attribute for name of social network
  3. adding social networks as attributes under each User entity?
  4. Something else I haven't thought of?

I'm leaning towards number 1 but given that I'm a newcomer I want to make sure this isn't an anti-pattern or setting me up for pain later.

Michal Bachman

Not sure if I understand you requirements correctly, but in general, it's good to model real world entities as nodes and relationships between things, quite naturally, as relationships.

In your case, I'd go one of the two following ways, depending on how much you want to do with their social media accounts.

1) A node for each social media, e.g. (LinkedIn), (Twitter), (Facebook). Then a single relationship type, call it HAS_ACCOUNT, which links (user) nodes to accounts. For example:

(user1)-[:HAS_ACCOUNT]->(LinkedIn)

2) If you find you're storing too many properties in the HAS_ACCOUNT relationship, or even that you feel like it should be linked to something else (e.g. links between social media accounts), create a node for each account the user has.

(user1)-[:HAS_ACCOUNT]->(user1LinkedInAccount)-[:IS_ACCOUNT]->(LinkedIn)

That way, your model is more flexible and you can link users account together with a different kind of relationship. Say user1 follows user2 on Twitter:

(user1TwitterAccount)-[:IS_LINKED_TO]->(user2TwitterAccount)

Hope it makes sense.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I model social connections in ElasticSearch?

From Dev

How to store social network's actions in NEO4J?

From Dev

How do I uniquely identify only network connections that are *not* VPN connections?

From Dev

How do I return coordinates of nodes in neo4j

From Dev

Load Social Network Data into Neo4J

From Dev

neo4j percentage of attribute for social network

From Dev

How do I set ufw to allow internal network connections?

From Dev

Neo4J Nodes and Relationships : Do I have to model everything as a Node?

From Dev

Neo4J Nodes and Relationships : Do I have to model everything as a Node?

From Dev

How do I query for paths in spring data neo4j 4?

From Dev

How do I query for relationship data in spring data neo4j 4?

From Dev

How do I query for relationship data in spring data neo4j 4?

From Dev

How do I see if DELETE was successful om Neo4j via REST API?

From Dev

How do I create relationships from substrings in Neo4J

From Dev

Neo4j: How do I delete a specific relationship with cypher?

From Dev

How do I extract raw data from the neo4j examples?

From Dev

How do I add a second label to a node in Spring Data Neo4J 3.0.0 (Release)?

From Dev

How do I get the already existing constraints in Neo4j?

From Dev

How do I create a relationship in neo4j between two nodes?

From Dev

how do i delete all relationship of a specific type in Neo4j

From Dev

Neo4j: how do I delete all duplicate relationships in the database through cypher?

From Dev

How do I ignore the yield value from a java stored procedure in cypher (neo4j)?

From Dev

How do I list all labels in my neo4j database using the java api?

From Dev

How do I create a node with Label via REST API in Neo4j 2.0

From Dev

how do i delete all relationship of a specific type in Neo4j

From Dev

How do I configure Neo4j HA backup through NAT

From Dev

How do I create a spacial index in neo4j using only cypher?

From Dev

How do I get the Neo4J primary key back in a query result?

From Dev

How do I create a Neo4j relationship via the rails console?

Related Related

  1. 1

    How can I model social connections in ElasticSearch?

  2. 2

    How to store social network's actions in NEO4J?

  3. 3

    How do I uniquely identify only network connections that are *not* VPN connections?

  4. 4

    How do I return coordinates of nodes in neo4j

  5. 5

    Load Social Network Data into Neo4J

  6. 6

    neo4j percentage of attribute for social network

  7. 7

    How do I set ufw to allow internal network connections?

  8. 8

    Neo4J Nodes and Relationships : Do I have to model everything as a Node?

  9. 9

    Neo4J Nodes and Relationships : Do I have to model everything as a Node?

  10. 10

    How do I query for paths in spring data neo4j 4?

  11. 11

    How do I query for relationship data in spring data neo4j 4?

  12. 12

    How do I query for relationship data in spring data neo4j 4?

  13. 13

    How do I see if DELETE was successful om Neo4j via REST API?

  14. 14

    How do I create relationships from substrings in Neo4J

  15. 15

    Neo4j: How do I delete a specific relationship with cypher?

  16. 16

    How do I extract raw data from the neo4j examples?

  17. 17

    How do I add a second label to a node in Spring Data Neo4J 3.0.0 (Release)?

  18. 18

    How do I get the already existing constraints in Neo4j?

  19. 19

    How do I create a relationship in neo4j between two nodes?

  20. 20

    how do i delete all relationship of a specific type in Neo4j

  21. 21

    Neo4j: how do I delete all duplicate relationships in the database through cypher?

  22. 22

    How do I ignore the yield value from a java stored procedure in cypher (neo4j)?

  23. 23

    How do I list all labels in my neo4j database using the java api?

  24. 24

    How do I create a node with Label via REST API in Neo4j 2.0

  25. 25

    how do i delete all relationship of a specific type in Neo4j

  26. 26

    How do I configure Neo4j HA backup through NAT

  27. 27

    How do I create a spacial index in neo4j using only cypher?

  28. 28

    How do I get the Neo4J primary key back in a query result?

  29. 29

    How do I create a Neo4j relationship via the rails console?

HotTag

Archive