0

This is my database schema:

enter image description here

Is it possible? Because I want to prevent duplication of data.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
  • you can store the id of the sponsor in the tournaments/sponsors collection – Munsif Ali Apr 12 '23 at 04:41
  • Are you asking if you can copy data from one location to another and then remove it from the first collection? Or are you asking about performing a query? Also, the question mentions `tournaments subcollection` but it doesn't appear that `tournaments` is a subcollection - it seems to be at the root level along with the sponsor collection. – Jay Apr 12 '23 at 18:07

1 Answers1

0

Can I retrieve the data from the sponsor collection and bring it to tournaments subcollection?

Yes, you can. How can you achieve that? Simply by iterating through the sponsor top-level collection for getting all documents, and then writing them into the new location.

I want to prevent duplication of data.

If you don't want to have the same data in both locations, after adding all documents to the new location, you can then delete the documents from the old location. However, duplicating data is quite normal in the NoSQL world. For that, I recommend you see my answer in the following post:

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193