B
B
Bogdan Gerasimenko2021-05-28 12:51:33
Database design
Bogdan Gerasimenko, 2021-05-28 12:51:33

Create multiple tables or try to unify?

Tell me what you would do in such a situation.

When designing a database, I need to create a table (or tables) that will store data to connect to various APIs.

The problem is that each API provider has its own set of data required for authorization - somewhere only one key is enough, somewhere you need a login and password, somewhere two keys. The data that the API returns after authorization also differ.

Try to unify everything and create one table, but with the maximum number of fields (unnecessary put down as NULL), or split into several tables - each API provider has its own table?

There was also an idea to create one table of the settings type and store three fields in it: id, parameter name, parameter value, and retrieve the necessary data by the prefix api_provider-name_parameter-name (but in this case, most likely, you need a table with the names of providers) .

I would be grateful for any ideas and guidance :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2021-05-28
@melkij

json field.
Authorization data is only needed by specific code that works with this authorization. Search by authorization token, which API service this token belongs to, you will not care anyway. (although it will be possible if desired and a fairly modern DBMS)

but in this case, most likely, you need a table with the names of providers

And you still have or will have it.
Although you yourself work with the API and for each service there is a maximum of one set of authorization data (the table where the keys will be stored will be such a table with the names of providers). Although you give your users the opportunity to add an API to themselves - then you will have a user_id, api_provider_id, credentials label

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question