Designing with the Group Feature
You can let multiple users share data by using groups.
This topic gives some tips on how to design data sharing with and without groups.
Data sharing versus data syncing
Data sharing and data syncing look similar but they are based on completely different features. Let us start by clarifying the difference.
If you are going to "share" your data among multiple devices of yours, that is data "syncing" and you do not need to use the group feature. You can synchronize data just by installing your mobile app on multiple devices and accessing the data in a bucket in your user scope, as shown in the figure below.
If you are going to let multiple users share data, that is data "sharing". See the figure below for an example.
How to share data
There are two methods to achieve data sharing among multiple users. The first method is to leverage the group feature. The second method is to modify the access control of the private data.
For example, suppose that we are developing a mobile app that allows two KiiUsers to exchange chat messages.
If we use the group feature, we can create a KiiGroup for those two KiiUsers, create a bucket in the group scope, and write messages in the bucket (You can optionally leverage the bucket-based push notification feature too).
If we do not use the group feature, we can create a bucket in the user scope of the KiiUser who initiates a chat and modify the access control of the bucket and KiiObjects so as to let the KiiUser who responds to the chat initiator read and write messages.
The design of your mobile app determines the method to adopt. Here are some tips to help you choose your strategy.
You can clarify the relation among users by using the group feature. Especially, if multiple users jointly own data in nature and these owners change constantly, we recommend using the group feature.
If your mobile app creates a lot of shared data, we recommend using the group feature so as to avoid changing access control excessively (i.e. every time a KiiObject is created). For some related discussion, see ACL Customization Examples.
If groups are frequently created and deleted, you might consider using the access control feature. As explained in Retrieving a Group, the group feature requires you to manage group URIs, so it might be easier to change the access control of buckets.
Even when working with users' private data, there is a case where the group feature is more efficient than the access control feature. Suppose an SNS app that allows the user to publish their own information to their friends by creating groups, as shown in the figure below. Every user owns a group for managing data that is open to their friends. If the access control feature is used, the access control of all the shared KiiObjects has to be reconfigured every time a friend is added or removed. If the group feature is used, you do not need such reconfiguration nor check the consistency between the access privileges and the friend relations. For more information about access privileges, see Securing Data. For more information about consistency, see Transactions.