Have an existing flat table with just 2 columns, with one columns data repeating itself. Example Below (sample data for demonstration purposes)
Table: OPEC_MEMBER_COUNTRY (represents countries that belong under OPEC)
Data:
opec_id | member_country |
---|---|
OPEC | USA |
OPEC | Oman |
OPEC | Canada |
OPEC | Mexico |
Have an existing flat table with just 2 columns, with one columns data repeating itself. Example Below (sample data for demonstration purposes)
Table: OPEC_MEMBER_COUNTRY (represents countries that belong under OPEC)
Data:
opec_id | member_country |
---|---|
OPEC | USA |
OPEC | Oman |
OPEC | Canada |
OPEC | Mexico |
Need to write a REST API to get[all countries of OPEC]/add/delete member countries. Considering different design options for API model/Object model (and best "resources" && URI) that gives clarity for users (to support operations around member countries).
Different options that could come up with
Looking for advice/suggestions for modelling/resource identifications (although aware that REST architectural principles are completely independent of the technology that is used to persist information).
When designing an API, it is better to focus on the convenience and needs of users, rather than on the internal structure of data storage.
If you have or plan to have other organizations in your system, then I would choose the following option:
Getting all members of the organization:
GET /orgs/{org_id}/members
Adding a new member:
POST /orgs/{org_id}/members
The list of members to add is passed in the request body.
Removing an organization member:
DELETE /orgs/{org_id}/members/{country_code}
Firstly, your database should be refined further. It doesn't make sense to have a column with just one data in it. either your DB holds both data (e.g. OPEC & Non-OPEC) and the DB table_name is good enough to asses that list has only OPEC Countries in it.
For your REST API, the most logical uri path would be /opec/member_countries for OPEC based
If you planning to make it extensible, then /org/{OPEC}/member-countries would be a better uri.