I am developing an Android application in which i am trying to integrate couchbase lite for storing customers information. Each customer information is in the form of a nested json so i decided to save it in documents. I have following queries related to couchbase lite implementation.
How a collection is created? I read collection (Table is SQL) a bucket in couchbase lite is not created and only databases are created, so if i want to store customers information in 1 bucket and products information in another do i need to create 2 database instances? and then store documents in it?
Can somebody please help me out with this?
Couchbase Lite doesn’t have collections. You can store all types of documents in the same database, using a property like
type to indicate what type a document is.
“Collection” in the sense being asked about here is a namespace of documents in a bucket, similar to a table in a SQL database. It’s a new Server feature we haven’t added to Lite yet.
As Jens said, your options is Logical separation of documents using “type” property identifier
Physical separation with multiple instances of couchbase Lite instance is an overkill for your use case.
You may want to check out these docs on json data modeling.
Hi, thanks for responding.
And what if i require not to save different categories documents in same COLLECTION (Couchbase lite instance ), For different categories i need to maintain different collections (Couchbase lite instances) as a requirement.
What will be the drawbacks then? Will it slow down the performance of app? Or will it slow down query processing or any other major drawback?
It would be helpful to understand the basis of that requirement. What’s the concern?
Having a separate instance of couchbase lite , each instance corresponding to a “table” in the relational world is not the right approach to modeling your data for a JSON store . I think its important to rethink your data model as it would apply to a NoSQL document store rather than retrofitting your relational style model. For instance, take advantage of nested objects and arrays in JSON - hopefully the link I shared provided guidance.
If you want specifics , here are few big ones - Queries are scoped to a database instance, you can’t do things like cross database joins
Can you explain why that’s a requirement? It’s not going to work well in Couchbase Lite, since you can’t query across multiple databases.
Right. discussed and resolved the issue, Will use TYPE property to differentiate.