Collections and Scopes

Hello!

I am new to Couchbase and I was reading the documentation when I got surprised by these statements:
“Collections might be assigned to different scopes according to content-type, or to deployment-phase (ie, test versus production).”
“Items can optionally be assigned to different collections according to content-type.”
Do they mean that a collection can belong to multiple scopes, and that an item can belong to multiple collections?
(Here is the related documentation: Couchbase Documentation - Scopes and Collections)

It seems to me that what I’m saying just above is wrong, and that an item belongs to a single collection, and that a collection belongs to a single scope, but I am not sure because of the doubt I have about my understanding of the statements above.

Could someone bring me some clarity about that?
I would be very grateful.

Thanks in advance.

Best regards,
Cyrille Dakhlia

@Cyrille_Dakhlia The documentation here is talking about how you might choose to organize your data, i.e. you might put all your customer data into a scope called myBucket.customerScope and all your order data into a scope called myBucket.orderScope. Within these you can have different collections to further segregate data. The documentation’s use of the word “assigned” is probably what is a bit confusing here – it is talking about what decisions you might make, not some other action Couchbase Server takes independently under the covers.

You are correct that a specific document does belong to a specific collection, a collection belongs to a single scope, a scope belongs to a single bucket, thus forming a hierarchy.

bucket.scope.collection in Couchbase are analagous to database.schema.table in an RDBMS.

2 Likes

Thank you so much Kevin for your very quick answer, I couldn’t expect something clearer! :pray:t3:
I now understand how this part of the documentation should be read!

Best regards,

Cyrille Dakhlia

@Cyrille_Dakhlia Thank you for the kind words – glad I was able to help.

1 Like