Thanks for the response Jens.

Yes, the app I wrote is called Tap Forms Organizer. www.tapforms.com and 
you can define your own forms with as many fields as you like and then 
create records within those forms to populate the data. It's all very 
dynamic and ad-hoc. Think Bento or FileMaker Pro. In fact, I even have a 
Bento importer to import native Bento template files into Tap Forms.

I'm hoping that Couchbase will help me with improving performance and also 
the biggest thing is sync. Right now I sync via generating change files 
(stored in encrypted SQLite files using SQLCipher) based on the 
modification date of everything in the database. I upload those to either 
iCloud Drive or Dropbox, depending on the user's choice of sync services. 
Then I merge the data from those change files with the data in the local 
database when the devices receive notification of updated sync files. But 
it's fraught with complications. I'm really impressed with what you've done 
with CBL. I am also excited to be able to offer peer to peer syncing, which 
is something I can't do yet (other than beaming a single record at a time 
using Multipoint Connectivity).

I can make the field keys based on the names of the fields and even convert 
them into a more JSON friendly structure. For example, "The Movie Title" 
becomes "the_movie_title". But yes, customers can rename fields as they 
wish. They can even have fields with the same name in the form. When Tap 
Forms adds a new field, it will create a default field name based on the 
type of field the user chooses. So for example, a Photo field would have 
the name "Photo" by default. If they added 5 Photo fields, they'd have the 
same named field 5 times unless they decided to rename them manually. So 
that's why I chose the primary key / UUID of the field object to use for 
the key.

I actually currently am using NSPredicate to store user defined queries in 
the database. I break those down and manually convert them into SQL 
statements, combining multiple predicates from any compound predicates into 
SQL INTERSECTION statements to reduce the number of results. I will need to 
somehow convert those into something usable by CouchbaseLite. I have read 
about CBLQueryBuilder and it sounds very promising. What I didn't 
understand about it is that it dynamically creates views for you. Is that 
right? So I don't have to bother making my own views then for any user 
generated dynamic queries? The user can also just type in a search term 
into the search field and it will currently search all Number, Text, and 
Note fields simultaneously and return the results. Plus there's the more 
advanced search where they have to specify which fields to query against, 
combining multiple search rules together which are ANDed (via the 
INTERSECTION mentioned above). Sorry if I'm being redundant here. I do that 
sometimes :-)

I will need some built-in views of course for regular things like fetching 
all the fields for a form or fetching all the saved searches for a form. Or 
if they delete a field, I will need to delete not only the field, but 
everywhere the field is referenced. It could be something as simple as 
nilling out a to-one relationship or just removing the field's key from 
each and every value where it's referenced from all documents. It also 
supports linking forms together via a one-to-many and many-to-many 
relationship. So if you delete a record, I have to remove all references to 
that record from all documents.

I'm hoping that it will be possible for me to still provide all this using 
Couchbase. I know it's going to be a challenge. But your sync strategy is 
just too compelling for me not to give it a shot.

Thanks!

Brendan

On Friday, June 5, 2015 at 9:53:43 AM UTC-6, Jens Alfke wrote:
>
> Interesting — so you have sort of a build-your-own-database app, where 
> users can define their own fields and then populate records with them?
>
> The JSON you showed looks reasonable, although it’ll help performance if 
> you can avoid using UUIDs for the field identifiers. The shorter the 
> better. Have you considered making the field identifier be the user-visible 
> name of the field, perhaps with a prefix added to disambiguate it from the 
> built-in fields like “sortOrder”? The only drawback would be that if you 
> allow these fields to be renamed, it would require updating every document 
> containing that field.
>
> I also need to be able to query by any of the fields in the database in a 
> variety of ways. For example, date ranges, numeric ranges, full text 
> queries, empty values, not empty values, possibly all combined.
>
>
> Couchbase Lite isn’t super good at this. It’s easy to do in SQL because 
> you can piece together a SELECT statement at runtime and the database will 
> evaluate it, and even if the data isn’t indexed for that query it’ll do its 
> best by linear searching. It also knows how to combine results from 
> multiple indexes. Couchbase Lite’s map/reduce system requires that you have 
> an index for what you want to search on, and if you need to merge results 
> from multiple indexes you have to do it by hand. We’d like to improve this 
> in the future (possibly by adopting the N1QL query language) but that 
> doesn’t help you now.
>
> Take a look at the new CBLQueryBuilder 
> <https://github.com/couchbase/couchbase-lite-ios/wiki/Query-Builder> class 
> available in 1.1 for iOS/Mac. It’s similar to Core Data’s NSFetchRequest: 
> it lets you define a query using NSPredicate, NSExpression and 
> NSSortDescriptor. Behind the scenes it will create a view to generate the 
> necessary index. If you’re using this for ad-hoc queries, it may end up 
> creating a lot of views, which can reduce performance, so you may want to 
> manually delete them from time to time.
>
> —Jens
>

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/0bb2461e-2c07-47d2-9654-108c5a455532%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to