Well, maybe this is too big for StackOverflow, but is there a good generalized way to collect data in relational tables into hierarchical JSON?
For example, let's say we have a “customers” table and an “orders” table. I want the result to look like this:
{ "customers": [ { "customerId": 123, "name": "Bob", "orders": [ { "orderId": 456, "product": "chair", "price": 100 }, { "orderId": 789, "product": "desk", "price": 200 } ] }, { "customerId": 999, "name": "Fred", "orders": [] } ] }
I would prefer not to write a lot of procedural code in order to iterate over the main table and select orders several times and apply them. It will be very slow.
I am using MS SQL Server database, but I will need to do the same with MySQL soon. I use Java and JDBC for access. If one of these databases had some kind of magical way to build these records on the server side, that would be ideal.
How do people migrate from relational databases to JSON databases like MongoDB?
ccleve
source share