Given the scenario that I would like to store sales of a store in a table in a database in Google Cloud Spanner. That table would (in addition to the sale ID as the primary key) have to store a list of product IDs sold, along with the quantity of each product sold. Ideally, this would be in the form of a column such as
productsSold ARRAY<product OBJECT <productID INT64, quantity INT64>>
I.e. each element in the array would be an object containing the product ID along with the quantity of the corresponding product sold. I saw the STRUCT datatype in Google Cloud Spanner, which would be ideal, but it seems you can't create columns using that.
Alternatively, it could just be stored in two separate arrays as
productIDs ARRAY
quantities ARRAY
But this has the possibility of the arrays being out of sync as each element in productIDs isn't directly linked to a corresponding element in quantities.
What would you recommend is the ideal way to store this data according to the best database conventions and through what is possible with Google Cloud Spanner? Thanks in advance!