I would like some advice about data modeling in XTDB. For now I’m using V1 because V2 isn’t ready yet. I wish it was because XTQL looks awesome, and I’m struggling with limitations in catalog. In particular the question of nesting vs linking documents is something I have found hard to follow in the various examples in the documentation because they tend to be very abstract, or super verbose. It would be good if there was an example with a real world data model one could implement in a RDBMS - something like “how not to think RDBMS terms” by porting a model from, say, PostgreSQL to XTDB.
I am using Biff which uses malli for schema validation and have no problem on that end. The difficulty is querying based on criteria in nested maps. Let’s say I have:
{:xt/id #uuid"..."
:company/name "ACME, Inc"
:company/address {:address/address-1 "123 Acme Way"
:address/city "Anywhere"
:address/state "Ohio"
:address/zip "12345"}}
I want to query all company records where the address is in Ohio.
I don’t want to do something like:
{:xt/id #uuid"..."
:company/name "ACME, Inc"
:company.address/address-1 "123 Acme Way"
:company.address/city "Anywhere"
:company.address/state "Ohio"
:compnay.address/zip "12345"}
because address is a recurring type I’d like to use across documents (malli makes it easy to validate such composite data elements), but not necessarily make into a first class document. Though it may make sense to do so.
Or is it really necessary to make “address” a first class document and link it by ID? In which case, how can I query company to also add in the address data? How it looks above is how my UI wants to interact with it.
If this doesn’t make sense I can probably provide some of my examples. I also have questions about many-to-many type relationships and how to model them as well.
Still transitioning from RDBMS mindset so any assistance welcome!