I have an application, very basic description:
- Users login -> they post “activities” (like snowboarding)
- Users have friends
- Users can bind multiple friends to activities
- Users can “like” activities created by friends
What I need is a query to check if the user is allowed to “like” an activity by one of their friends. They are only allowed when one of the users friends was bound to the target activity.
users: id, name
usersFriends: id, uid, friendUid
activities: id, description
activitiesUsers: id, activityId, uid
activitiesLikes: id, activityId, uid
I hope someone can help me with this query, and if possible to return true or false. I hope my question is clear and thanks for your time 🙂
This should produce a list of
activities.idfor all of the user’s friends.Wrapped in an
EXISTS, it looks like:Or something with an
IN()clause that attempts to get everything fromactivitiesowned by any of the user’s friends.