Currently exploring Fauna DB as a possible backend for a new SaaS and was hoping to better understand a possible schema we might use. This is a B2C SaaS. The primary user is a single-user that signs up for a monthly plan.
In the most primitive way, the service allows a user to manage “lists”, where each “list” contains an arbitrary number of records. Because the fields of a record are user-defined, an unstructured datastore like FaunaDB is appealing. There’s nothing particularly novel about this. It’s your basic “spreadsheet” where each “list” is a spreadsheet with arbitrary columns and each row is a record.
In Fauna DB, we see “Lists” as being one Collection and “Records” being another Collection. Every list document and every record document would need some sort of user_id
field.
With respect to FaunaDB, we have the following questions:
-
Collections seem very lightweight, is there any advantage to create a List collection for every user? (i.e.: One List Document that describes all of a user’s lists?)
-
Alternatively, could you make a Collection for each user’s lists? Since a Collection Name is unique, we’d need to create unique names, but presumably we could just do something like “
user_id.list_name
”. If you had thousands of users and with dozens of lists each, this would create a large number of Collections. Is that ok? -
The same applies to the
Records
Collection. Do you put all records, for all users, in the same Collection, or is it better to create one Collection per user or even one Collection per user per list? -
We want users to be able to perform some data analysis on each list. Obvious examples might be computing the sum, min, max, count, etc., of a field. Searching and querying are equally important, and since the fields are user-defined, creating indexes seems less useful.
-
In relational database parlance, we would likely be doing a lot of “full table scans” computing such values or performing such queries. Does that impact the decisions above? (i.e.: Is there a cost difference between iterating all documents in a Collection that match a
user_id
vs just iterating all Documents in a Collection that is wholly owned by a user?) -
Finally, we’re trying to understand pricing. We suspect the vast majority of our operations will be read-based. (Import once in bulk from CSV files, then organize and analyze data.) If a user has a Collection with 1,000,000 Documents in it and they perform a search for “all documents where ‘xx =y’”, does that equate to “1,000,000 read operations” in the Pricing table? If that same user did 10 different searchs in a day, did they just burn up 10,000,000 reads?
Thanks in advance for any insight you can offer. Fauna DB looks very interesting, but we’re a bit concerned with the schema and, in particular, the pricing model so hoping to get some clarification so we can move forward.
Cheers