This question is about your opinion and common approach for relational databases. So please, do not vote me down. I really need to solve this problem.. I remove this question once I meet the answer.
I have a response from my server sth like this:
"groups":[
{
"id":"ea369ff6-cbc3-44b6-8eb6-b79e8db0145c",
"ingredients":[
{
"id":"f5126c1f-11a7-5ce5-a717-c6c86483058e",
"name":"First",
"position":1
},
{
"id":"dfcf217e-53dd-b06c-9f2b-084f8180ba1a",
"name":"Second",
"position":2
}
]
},
{
"id":"0fa91ada-1fe4-4d6d-b772-caae44758848",
"position":2,
"ingredients":[
{
"id":"9cacade2-92fe-bd5c-c84c-7c5fe36c8a5e",
"name":"Third",
"position":1
},
{
"id":"f5126c1f-11a7-5ce5-a717-c6c86483058e",
"name":"First",
"position":2
}
]
}
]
- Here are two
groups
. Each of them has unique id. - Every
group
has someingredients
. They are the same type - Every group has ingredient with name
First
. This ingredient has the sameid
in every group, which means, it is the same object.
but
First
ingredient has different values of position
depending on where it is located.
The question is:
Should they have the same id
while they are not the same? What is good approach for this problem? I need simple, quick and clarified answer.
Doesnt id mean that this is unique along with the same type of object? What If I need to save it to core data or other persistent store on device?
Very thanks.