PUT vs POST when an updated time is tracked

advertisements

I have a 6NF-esque schema in part of my database, where any time a property value is changed, a new row is created with the CURRENT_TIMESTAMP. For example

+----------+-------+---------+
| EntityID | Value | TimeSet |
+----------+-------+---------+
|        1 |   foo | 1:30 PM |
+----------+-------+---------+
|        1 |   bar | 1:31 PM |
+----------+-------+---------+

So, the PK is EntityID, TimeSet (TimeSet is a MySQL TIMESTAMP - I just used readable values for the example). Any GET requests will SELECT the latest value for the entity only (i.e. GET /entities/1/<property> would return bar only).

As of right now, there are no behaviors that depend on the time set, it's just there for auditing. My question is: when I want to set values for this attribute over HTTP, should I be using PUT or POST? Technically, a new row is being created every time the user sends a value, but from the standpoint of the API, the request is idempotent, because you could create 100 rows of the same value, and only the most recent one will be returned for any GET requests.


Meaby this can help you: The POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line. POST is designed to allow a uniform method to cover the following functions:

  - Annotation of existing resources;
  - Posting a message to a bulletin board, newsgroup, mailing list,
    or similar group of articles;
  - Providing a block of data, such as the result of submitting a
    form, to a data-handling process;
  - Extending a database through an append operation.

The PUT method requests that the enclosed entity be stored under the supplied Request-URI.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html