Hi, I am building REST API in php with memcache layer on top for caching all resources. After some reading/experience it turns out it's best when documents are as simple as posible...mainly due to dropping cache sequences.
So if there is 'building','room' entities for the 'room' document I would only place the id of the 'building' and not the whole data of it. Then on api client side I would merge data as needed.
Problem becomes when I need to update/insert (most cases more than one table). I update one resource but on second update system fails or whatever and there becomes database inconsistancies.
I see several solutions:
Implement rest transactions which I find wrong and complex as idea is to be stateless and easy.
On update/insert actions I pass more complex data (not single entities) so I can force transactions on API level. But this will make it weird that your GET document structure is same as PUT document structure. And again somehow make drop sequences complex.
Any pointers are more than welcome. Cheers,