Before start with ArangoDB lets see what is arangodb and it"s going to help me to create a social networking with less effort:
ArangoDB is designed as a native multi-model database which enables you to model your data in a very flexible way. A native multi-model database like ArangoDB uses the same core and the same query language for all data models. Thereby users are able to combine different models and their features in one query. ArangoDB doesn"t "switch" between the models behind the scenes and doesn"t shovel data from a to b all the time in order to execute queries. This leads to strong performance advantages compared to "layer-approaches" and ArangoDB"s suitability for high performance needs. ArangoDB store data as key/value pair in a document and we can model the database as collection of document as well as graph.
Every document consists of a unique key and contains values to certain attributes. If you store one value in a document then ArangoDB serves as a classic, highly scalable key/value store which you might need for e.g. temporarily storing products in a user shopping-cart of an ecommerce platform or sensoric data in IoT applications and so on. We can store as many attributes in a document as you like (default size of a document is 33.5MB [From ArangoDB 3.x], but configurable to our needs). ArangoDB has a wide feature-set for querying and working with documents like joins, secondary indexes or acid transactions. We can horizontally scale join usage to the technically possible.
ArangoDB provides also the full featureset of a mature graph store (e.g. pattern matching, shortest path, full blown traversals) and due to a little magic it can perform graph queries very fast compared to many other leading graph solutions. Strongly simplified, here is how we do it:
When building a graph with ArangoDB a special type of document is created to represent edges and vertices. These documents contain a _to and _from attribute pointing to the connected document(s). By creating and using an edge-index on those relationships graph queries can be processed with high performance.
A unique characteristic of ArangoDB"s approach is that those edges and vertices can contain complex data (nested properties) and all graph functions are deeply integrated into our query language AQL. Both characteristics allow ArangoDB to at least compete with other graph solutions concerning performance. With ArangoDB you have also the possibility to distribute your graph to a cluster.
Now coming to ArangoDB Social Modeling:
Let say we have users for our website and we have some case for example:
1) User can be a part of any number of group.
2) User can follow any number of user.
Taking this design into consideration we can 1st create a collection
Now the above collection will contain the user information in User collection and group information in Group collection. Now both the collection do not know each other data means when we say User collection contain user data of multiple users (e.g User are deb, sandip, gourav, sekher, shruti, indu etc), each user will contain there own data like name, mobile number, password, userid etc. And if we consider Group, here Group collection contain only group information like groupname, groupabout etc.
Now let"s see the relationships between User and Group
User <-> Friend <-> User
User <-> Follow/ing <-> User
User <-> Follow/er <-> Group
User <-> Cretaed <-> Group
Now to create the relationships we can create an edge between User and Group where will store the relations between User and Group.