One stream with extensive use of keys vs multiple streams

+4 votes
So far I'm learning how to use streams in multichain to store and retrieve data. In a sample I've been working imagine I have a "Product", and then I store a json representation of this product in the multichain in a single stream, one for every product (e.g. Product1 and Product2 have different streams).

Then I was curious about the "key" attribute, and it seems that, in a single stream, you can retrieve the transactions associated with that key, so I could potentially have a single stream and multiple keys and maybe have the exact same behaviour as I mentioned before.

What would be the advantages and disadvantages of either approach? Thank you!
asked Oct 30, 2018 by David Jiménez

1 Answer

+2 votes
A stream can be considered somewhat like a database table, as a way to group related information together. For example each node subscribes to its chosen streams, and does not need to subscribe to others.

In this case it sounds like you should have a single stream and use the key attribute, since this will give you more flexibility in future. For example you can retrieved by timestamp from this single stream, across all keys. This is harder to do if you use separate streams.
answered Oct 31, 2018 by MultiChain
I appreciate the answer, it helped me a lot understanding the concept. Thank you!
...