very basic question to get me started. Suppose I have a database of sales by country:
[{:sales/country "CN" :sales/amount 1000 :sales/account "XYZ"} ...]
I would like to also have a list of facts about each country something like:
[{:country/short-name "CN" :country/long-name "China" ...}]
And then do queries of the type "list all sales that happened in China (using the long-name)".
Is that one database? How do I make it clear there are two distinct schemas? Do I transact the first schema then the sales data, and later the country schema and data?
EDIT: sorry my question wasn't clear. Here is live example:
(d/transact! conn
[{:country/code "BR" :country/name "Brazil"}
{:country/code "CN" :country/name "China"}])
(d/transact! conn
[{:sales/country "CN" :sales/amount 1000 :sales/account "XYZ"}
{:sales/country "CN" :sales/amount 1000 :sales/account "AAA"}
{:sales/country "BR" :sales/amount 1000 :sales/account "BBB"}}
])
I was able to run a query to join the tables and get the results I wanted. What I don't understand is what is best practice to define my schema. Is it just one schema or two of them, one for each table. Can I do this:
(def schema {:country/code {:db/valueType :db.type/string :db/unique :db.unique/identity}
:country/name {:db/valueType :db.type/string}
:sales/account {:db/valueType :db.type/string :db/unique :db.unique/identity}
:sales/country-code {:db/valueType :db.type/string}
:sales/amount {:db/valueType :db.type/integer}
})
And is there a better way to define in the schema that country/code and sales/country-code are the same "key"?
Thanks,