0
I have a question that I believe is basic for those who are starting with nosql and comes from the classic relational structures.
Well, let’s look at a simple example for relational structures:
- I have the table person with id and name_person;
- I have the address table with id, id_pessoa, street and number;
In the above description I have a basic one to many relationship where a person has many addresses. In a standard CRUD I can update an address of the person with the address id. If I want to list all addresses of a person is also simple by simply filtering the address table by the id_person.
Now let’s go to nosql. In the searches I did, the ideal is the address to be a sub-document person, which would look something like this:
"Pessoa":{
"_id": "12asdf213",
"nome": "João da Silva",
"endereços": [{
"logradouro": "Vila do Chavez",
"numero": 71
}, {
"logradouro": "Cidade Z"
"numero": 14
}]
}
My question is, how could I update the street number of "Vila do Chavez" without having an identifier?
In research I also found that I can reference, creating a document for the address and making a common relationship between the two documents. But that for the nosql is not very performatic nor indicated.
Thank you. I thought this might be the answer. But it sounds strange, even for spending years working with relational banks. But I believe that this is characteristic of modeling.
– Javeson Yehudi