CREATE TABLE `social_activity_stream` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`social_actor_id` int(11) NOT NULL,
`social_activity_id` bigint(20) NOT NULL,
`social_activity_type_id` int(11) NOT NULL,
`social_share_policy_id` int(11) DEFAULT NULL,
`social_user_friend_id` bigint(20) DEFAULT NULL,
`date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`date_read` datetime DEFAULT NULL,
PRIMARY KEY (`id`))
Every social actor creates a social activity, with share policy PUBLIC, PRIVATE, FRIENDS
Lets say there are 3 actors:
A, B, C
They’re friends
An activity shared by A with FRIENDS (policy) would create 3 rows in the table:
- One for A [A, A TEXT POST, FRIENDS, NULL]
- One for B [B, A TEXT POST, FRIENDS, A->B]
- One for C [C, A TEXT POST, FRIENDS, A->C]
B wants to browse A’s activity stream:
Here is the pseudo query:
- GET PUBLIC ACTVITIES by A’ stream
- GET PRIVATE ACTIVITIES by A’stream with FriendId = A->B
- GET FRIENDS ACTIVITIES by A’stream but only if that activity exists
in B’s stream (otherwise it could be for a friend D of A who is not
friend of B)
Any idea this can be done in a single query?
Duh, that was simple. Poor question indeed.