We have divided the world map into 6 regions and each region will have list of countries.
We have products which we mark to make sure which are all countries has it.
How we model this as we have more than 200 countries and marking this country list for each of these products will create a huge number of rows in the table.
The data will be created through product API where we take an array of regions where the product is applied and then we either take included countries or excluded countries within each region parameter to identify which are all countries it is applicable. In case when both included countries and excluded countries are missing for a region, the default assumption is that all countries of that region are part of included countries for that product.
How to data model this scenario? We do not want to map products to excluded countries. We probably need to provide an API that can get us the list of products for the list of countries provided in filter criteria. Do we need a separate table to maintain a list of region and country mapping and then perform the computation on the incoming data before identifying countries for product?
Or
a better idea is to always get the list from the API itself either through included and excluded parameters.
| seqId | Region | Country | ProductId
|:---- |:------: | :-----: | ----:
| 1 | America | US | 10001
| 2 | America | Canada | 10001
| 3 | America | Argentina | 10001
| 4 | Asia | India | 10001
| 5 | MEA | Egypt | 10001
Sample API Request for Product Creation:
{
"productId": 10001,
"regions": [
{
"name": "America",
"includedCountries": [
"US",
"Canada"
]
},
{
"name": "Middle East"
},
{
"name": "Asia",
"excludedCountries": [
"Nepal",
"Japan"
]
}
]
}