samedi 18 février 2017

NoSQL to SQL adapter design pattern

I have 2 existing applications that I'd like to bridge somehow. Both have similar domains (Product Catalogs), but the first application uses a NoSQL document store for records, and the 2nd application uses SQL tables.

An example record from the first table looks something like:

{
  "productId": 123,
  "sku": "abc",
  "packageSizes": {
    "container": 20,
    "pallet": 50
  }
}

Whereas the same item in the 2nd domain would be 1 row in the ProductItem table:

| id  | sku |
| 123 | abc |

Then 2 rows in the ProductPackageSizes table:

| productId | type      | size |
| 123       | container | 20   |
| 123       | pallet    | 50   | 

The systems currently are completely independent, but I'd like it so that whenever a record is created in the NoSQL application to have the same item created in the SQL application.

I can write a one off script for this, that just creates it procedurally based on what the data looks like currently. However, I would be interested to know if there are any established design patterns to describe such transformations? Particularly if there are new packageSizes or other relations added in the future.

Aucun commentaire:

Enregistrer un commentaire