Should i use neo4j in my project?

Hi guys. I'm new in graph databases and neo4j.
I need to use neo4j in my school project but i'm not sure if it ok to use it for what i planned. I'm planning to create site similar to 9gag where user can login upload images, like images, comment, etc.
Now is it good idea to use neo4j for this project? I was thinking every picture can be one node, and every picture will have relation to correct category, etc.

Is this ok plan or i have to change project? Do you have any idea for what type of project i can use neo4j.

Thank you guys in front.

P.S. Sorry for my english :)

This sounds like a great project for Neo4j. There have been a few examples that might help you plan out how to tackle this kind of project:

Are you thinking you would like to build a functioning full stack application or just the database for now?

2 Likes

Thank you man you are awesome!

Yeah i will build full stack ASP.net MVC application with redis and neo4j for database. But i'm not sure what will i use redis for but i need to use it :smiley: Maybe you have some suggestion for what to use redis?

Again thank you.

Unfortunately I know nothing about redis, but someone on the community might

1 Like

Yeah i hope so. Thank you man for everything you really helped me :)

@Hazaaa You could use redis for caching credentials (access token) for logged in users. That would be a valid use-case. Hit the cache first, then fall back to the db.

So if you built the social network part (ask questions here as you go), with a few use cases, like login, make a friend, post some content, etc you could then refactor to store session in a cache.

About redis: I'm running a social network, using Neo4j, with 400,000 users, and still no need for it. But I understand that it is fun to play around with the tech, and see how things can fit together.

Good luck with your project :)

1 Like

Thank you man! That is exactly what I needed.

1 Like

Jasper i have question for you.
I want to implement private messages in my project but i have two solutions how would i store messages in neo4j.
First is this:

I would have SEND and RECEIVED relationships between user and message and RESPONSE relationship between messages if message is response to received message.

And second one is: (no picture for this)
I have message node and it has one property named "mainMessageId" or something like that, that will save id of first message that was send from one user to another and every message after that will have this property set to that first message so when i pull them from db i just pull them by that id not with relationship.

I hope i made it clear how i want to implement it :) I really appreciate your suggestion and thank you in front.

The first one looks good to me, @hazaaa, as a starting point, unless you want to be able to group messages into a conversation.

Remember that we only need IDs for initial lookup or starting point for graph traversal.

So i should use response relationship but still to have id for first message?

After that when we want all response of one message we just match that first message node with id that we stored in response and start searching from that node?

It depends what you want. But probably:

  • Every user is unique. You want to be able to look up an individual, and know things. Since people can have the same first and last names. Therefore you give the user a unique ID. Most common is Universally unique identifier - Wikipedia

  • But once you look up a unique user, you can traverse the graph, eg, what messages did she send, and to who? In a graph database relationships are first class citizens.

  • If you're building a social network, and it has chat features, you want to look up a user and who they chatted with. Since you're looking up by user, individual messages and/or conversations probably don't need a unique ID. It won't hurt if you give them one, anyway.

For your follow relationships, you could maybe avoid having one in each direction, instead have a follow, and have two properties 'followDate' and 'reciprocatedDate'

Does it make sense?

1 Like
  • Users will be unique by their username and aspId (that ASP authorization creates).

  • Yes now i understands that the power of graph database is in relationships. But in ASP i have to create model for every relationship and for now i am confused how should i use them...

  • I asked professor and he confirmed me that my first solution for messages is ok, and it's ok to have id of first message in every response so it's easier to get all response (like you said before).

We didn't really talked about bidirectional-relationships but it make sense what you said. I'm not just sure when i return relationship in C# from db to controller i need to map it somehow and how that model should look. Isn't easier to have one model that will store followed user and follower user and date when he followed?

I'm sure that all this sounds trivial for you but i'm really trying to understand neo4j and graph dbs at all. Hope i'm not really that annoying :)

Don't be afraid to ask a lot of questions. Another nice thing about Neo4j besides the technology, is that the community is pretty friendly.

With regards to modelling, why don't you have a try at something, see if you can get it working, then we'll look at where it can be improved.

Yeah i can see that. You guys are really amazing.

Of course i already implemented some of things but i want to implement the right way.

Thanks again jasper :)

Doing the right way depends on what you want to build and how you want to understand your data. As you continue to learn you can always adjust and restructure as you go. That is one of the best things about learning and using Neo4j. Just jump right in and make mistakes and learn.