How "Follow" button works in Graph DB - graph-databases

I am using Titan Graph DB. I want to implement "follow" button in my page i.e I a page update something, it should be know to all follower. I dont know how does this follow mechanism work.
In social networking when we follow something we keep getting all updates from that page. How does it work? What is the idea behind implementing this in Graph DB.
Suppose I am following a page XYZ and there happend one update on XYZ. then how does it sends its update info to all followers.
Is it something that it will store update info for all individual
user in graph DB
OR Is it like when a user login it will check all page that it follow
for any new update?
OR something else

The process to trigger the notification has nothing todo with the underlying database you use. This is part of your business logic, how you design your application and how you notify all the listeners about the change.
A graph database will give you the opportunity to store the information about your users and theire tweets, or your sites and the follower in a more natural and semantic way.
In a graph database, you can store your Persons, e.g. John and Doe as Vertices and a relation or edge between them, labeled with follows. In your SQL database, you would store them in a separate table plus a table for your joins to store all the followers.
If you now have a new tweet, you have to join your tables in your SQL table to find all followers to notify. In a graph database, you just have to check the incoming edges on the person who wrote the tweet. Also, in the graph database, you could store the tweet as well, where an extra edge from the person who wrote it goes to the tweet, to have all the necessary informations for your notification at one place, instead of lots of lookups in SQL tables.

Related

FaunaDB, make connection between different users, I.e. become friends

I have a use case where I want to connect two different user roles, and if they accept and want to connect, new features will open up. It is very similar to how friend requests work at Facebook or LinkedIn, opening up and showing more content. Let's call them role1 and role2.
All users are stored within a "users" collection with an id. Depending on their provided role within the document attached to the "users" collection, they can store additional data in their respective role-collection, i.e., role1 collection or role2 collection.
What is the best approach and structure to connect the two users, i.e., become "friends"? Should I have the connection stored in a new collection, named perhaps connections-collection, or multiple collections?
I'm using Next.js, NextAuth for user authentication, and FaunaDB as a database. I'm using Fauna's query language, FQL.
Have you perhaps seen fireship's video RE: fauna db? I think it covers what you want to do and how you can proceed.
Edit: There are many ways to implement this. Based on my understanding, perhaps you can have "Friends" and "Requests" arrays stored under a user document. That way you can differentiate between confirmed friends or a just request.
Example: When user1 initiates a friend request with user2, you store user1's ref under "Requests" of user2's document. When user2 confirms, you move user1's ref to the "Friends" array.
This is just a overly simplified idea and you may need to consider your options and the implications. You would need to plan and define the predicate in both roles so you would only see what is necessary.

Saving "likes" database design (Parse)

Im using Parse to save data from my social network. So far I have three class: Users, Posts, and Relationships. I want the user to be able to like a post.
Should I create a new table for Likes. If so, then on my storyboard page I would have to query through Relationships to get the user followers, then Posts to get the posts from the followers, and then Likes to get the likes from those posts?
Is it efficient to have three API requests to parse on one page. I feel like this will slow down performance but I'm not sure how else to save likes.
Another thing is, I would like to display a notifications tableView. So all likes and requested follows. So Im guessing I would save likes in Relationships and just query through it twice on the storyboard to first get followers, then likes. And on the notification page, have one class to query though once to get all recent notifications.
What are your suggestions?
Thanks.
This is sort of a broad question so there is no way that I could say for sure, but I do have a couple suggestion that you can do with parse.com.
Use the local datastore: You can save all of the likes that the user has in the local datastore as well as in the cloud of your application. So, for instance, you create the like when the user likes something, save it to the cloud, and then pin it to the local datastore. That way, you can efficiently query all of the likes that your user has created without using an API request. But in the event the user logs into the app somewhere else, you also have the likes in the cloud to retrieve. So, I would create a new table for likes.
You could use a join table to implement the followers, so, you could also pin the followers of the user to the local datastore like you would for a like. This is like is done in the Parse.com anypic tutorial.
I would also have another table for notifications. In cloud code, you could even update how many notifications the user has with an afterSave method, and then get all the notifications through a query when requested by the user.

CakePHP filter queries by user's business accounts

I'm new to CakePHP 2.4 and trying to understand conceptually if I'm on the right track before I start building the following.
By default, when a User first logs in to his online account, he sees Orders, Invoices, and Documents for ALL ACCOUNTS that he has access to. Using an Account dropdown and the button "Go", he can filter Orders, Invoices, and Documents for only ONE ACCOUNT.
Currently, pre-CakePHP, this is all handled in query logic. The User-Account (N:N) relationship is in the database. Any active Account_Id is stored in the SESSION. What is the CakePHP to do this?
The Model looks like:
User hasAndBelongsToMany Accounts
Account hasMany Orders
Account hasMany Invoices
Account hasMany Documents
1.) Should I code the relationship between Users and Accounts in a Model (hasAndBelongsToMany) or in the ACL/Auth component (User is ARO, Account is ACO)?
2.) To show ALL ACCOUNTS, what is the best way to "query for" this filter and apply it to each Model. Or is that done automatically by the Model?... or by ACL/Auth?
3.) To show ONE ACCOUNT, is storing an Id in the Session still the best approach? ...or should I be thinking about a new set of actions in each of the Orders, Invoices, and Documents Controllers?
I will support you with set of links to CakePHP cookbook which clarifies all your queries:
First of all you should read about linking models.
Next thing is creating correct database and tables in there following CakePHP conventions
Another step is "baking" your models/controllers/ views
After that step all you need to do is just play arround with data you get from your models
To be honest you dont have to code any relations at all if you just correctly create your database with corect foreing key names which Cake will detect and build relations through interactive shell (you will be asked if you want console to create relation for you through cake bake ).
$this->ModelName->find('all')
will give you all data of given ModelName and also all related data,
using
$this->ModelName->recursive=-1
will make your model to retrive only data from ModelName without any related data.
In practice some things will probably work for you out of the box but some of things you will have to simply implement. Hope that helps.

URL to open Access Web DB form at specific record

I would like to create an email workflow using an Access Web DB form to manage holiday requests. The user will create a request from the form, save it - which triggers the SendMail data macro, ideally with a link in it for the approver to click and go to the approval form filtered to the correct request ID.
Does anybody know:
a) If it is possible to load the form in the browser filtered at the specific record ID. I have tried appending ?ID=1 to the form URL and so on, without any joy so far.
https://mysharepointserver.com/sites/mywebapp/default.aspx?ID=1
b) If possible, what steps do I need to go through to get it working?
This is an Access 2010 web database hosted on a heavily bespoke Sharepoint platform. Any help appreciated.
I have worked it out, using:
?Page={ID}
However, the one caveat with this is that if you delete a record then the page number refers to the records position in the table, not specifically the ID. If you can ensure that records are never deleted from the table it will remain aligned with Page number and ID number.
Its a bit of a pain, but if anyone finds a way of referencing ID directly that would be the ideal solution.
You can also use something along the lines of:
http://...sp_site_path.../default.aspx#Type=Form&Path=NavForm.Subform&Name=ActualForm&DataMode=Edit&Where=%3DID%3D1000
I believe the key part here is...
&Where=%3DID%3D1000
...which in this case refers to the database field [ID] and record 1000, ie:
[ID]=1000
The rest of the URL is refers to a specfic form within your site, however is you only have one, it is potentially not important for your purpose, and you would be able to get by with something like:
http://...sp_site_path.../default.aspx#Where=%3DID%3D1000
Since all my sites use navigation pages, I haven't tested this out

Using themoviedatabase.org's database to fill my own database, best practices

I'm building a site where I want to allow users to keep wishlists of movies they want to see and movies they already have seen. To do this I want to use data from the movie tmdb, but I'm not sure how to handle this.
What if a user comes on my site and enters the query 'Batman', what is the next step I should take?
Search my own database for 'Batman'
Search API for 'Batman'
Merge results from own database and external and print, but don't save anything to my db
If a user then clicks on a result that's not in my database I would do another request to the API for the more detailed information, also saving images and so on before showing it to the user.
Is this the way I should go about this or is there a better way?
You should browse API for this movie. Data in TMDB Api is often changing, so I suggest you not to store it for a long time in your db.

Resources