Multiple things in a database, how does APIs know which to use?

I have built about 20 different forms collecting information on a project. This data is fetched by an API (most likely, unless there is a plugin for this which I haven’t found yet) which puts this data into a series of Word document templates.

It occurred to me today that as users fill out this form, there’s multiple situations where the same data can be submitted more than once into the database either legitimately (e.g. data changing over time and changes being made to said fields), or illegitimately (e.g. user presses save buttons 3 times because he wasn’t sure). In any case the database will store multiple entries all with their own identifiers.

The simple question is, when it comes to an API or even a plugin selecting what data to pull from a database where there are 5 or 6 entries is there a way to get the API to select a certain one, or will it automatically opt for the latest in terms of date/time of entry?

I wondered whether it would have been useful to have a checkbox or something at the end of the form that is marked ‘complete’ and the user checks this which will mean that when an entry in the database has this checkbox within that entry, that’s the one the API will select to export into a document. Checking this box would also grey out the fields in the that form. But I have not idea whether this is necessary or how to implement this.

This topic was automatically closed after 70 days. New replies are no longer allowed.