Hi! I’m new in NoSQL world, I started with MongoDB, I have a doubt
I Have 2 collections
-
users: { name: String,
phone: String,
date_start_customer: Date} -
services: { name: String
value: int}
and I want to create a 3rd collection, called sales. The main idea, is this collection has info from users and services, but idk what info should insert in sales collection, for example:
option 1:
sales: {id_user: (foreignField from users),
id_service: (foreignField from services),
date: Date}
or maybe option 2:
sales: {name_service: (foreignField from services),
phone_user: (foreignFiel from users),
date: Date}
or last option 3:
sales: { service: (a object with info from services like name and value)
user: (a object with info from users like name and phone)
date: Date}
I wanted to know what of this options is the best practice to create a collection with foreign fields. I watched a few videos, and NOSQL use nested documents, so i tought that doing this would work, but i get this error:
so, i need help for this,
thx