Here's the desired flow of my PHP app (yes, it's vague, but it's easier that way):
- User submits a set of, let's say, about 5 objects by integer IDs. (It'll really be more like 15, but let's say 5 for ease.)
- App checks if this collection has been submitted before, and saves it in a MySQL database if not
- App saves these objects in the database, if they haven't been saved before
(Objects and collections are many-to-many, so there is an objects table, a collections table, and a table relating the two.)
A couple sample flows:
- User submits 111, 112, 113, 114
- This set is new! The collection is saved.
- We've seen objects 111 and 112, but fetch and save the data for 113 and 114, since we haven't.
- Another user submits 111, 112, 113, 114
- We've seen this collection before. Don't bother saving.
- Since we've seen the collection, we've obviously seen the objects. Don't bother saving.
Steps 1 and 3 are simple. Step 2 is where I'm not sure how to proceed. It seems unnecessarily database-heavy to be querying the relationship for sets containing those exact IDs, so I'm about to post a few obvious solutions such as a simple ID list and hashing, but I'd also like to know if there are more ideal solutions out there.
Thanks!