Parent Child - One to Many Relation ship

(Siv) #1


I've to persist documents and list of users who likes the document. During search I want retrieve/check whether that particular user has selected that document.

{"searchDocument": [{ "documentId": 1952, "isFavorite": null}, {"documentId": 1952, "isFavorite": "1"}], "userId": "845632"}

In the above same result (which I would like to achieve) there are 2 documents, userId is the user who makes search request. It is one - many relationship. One user can like multiple documents.

Can Parent - Child model be a right approach to solve this. It would be great if I get list of documents and it's Like Status together in one result. Any reference?

(Mark Walkom) #2

Yes, you can have the parent as the user and the documents as the child.

(system) #3