I am working on some functionality where I have stuck from a long time. I have three tables(I am only mentioning the required fields here):
users: id