Note that there are some explanatory texts on larger screens.

plurals
  1. POData modeling question
    text
    copied!<p>My clients use one of the following when they sign up for my application:</p> <ol> <li><strong>Foo API</strong> (requires a "<strong>auth_key</strong>", "<strong>password</strong>", "<strong>email</strong>")</li> <li><strong>Acme API</strong> (requires a "<strong>secure_code</strong>", "<strong>username</strong>", "<strong>password</strong>")</li> <li><strong>Bar API</strong> (requires a "<strong>xyz_code</strong>", "<strong>pass_key</strong>")</li> </ol> <p>(fake names, and about 15 more omitted for simplicity)</p> <p>I would prefer not to have 10-15 tables in my database just for the different API integration options I offer (particularly when they're all for the same thing and they just choose 1 from the whole list).</p> <p>My solution was this:</p> <p>Make a <code>api_configuration</code> table with a column called <code>api_name</code> which holds a code for a specific API (e.g. <code>"foo_api"</code>)</p> <p>Make a table called <code>credentials_attribute</code> with a foreign key back to <code>api_configuration</code>, a column called <code>name</code>, and a column called <code>value</code>.</p> <p>Then I build a UI for choosing an API. If they choose Acme API, it'll ask for a "secure_code", "username", and "password", and create a row in <code>credentials_attribute</code> for each of the name/value pairs.</p> <p>On my ORM model for <code>api_configuration</code> I can make a method for looking up <code>credentials_attribute</code> values based on the current <code>api_name</code>.</p> <p>Does this solution feel right, or is there another way you would do it, if you had to model a solution for this problem? Please explain your rationale as well (ie, better for performance, etc)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload