Frage

In my app I have 4 json file that I should parse. I show you a single element of json to understand.

JSON1 (Area) -> {"id"="...","id-locality"=["...","...","..."], "name"="..."}
JSON2 (Nation) -> {"id"="...", "name"="..."}
JSON3 (Provence) -> {"id"="...", "name"="..."} 
JSON4 (Locality) -> {"id"="...", "name"="..."}

As you can see JSON1 "Area" can have multiple values for locality. I created 4 entity in this way, but I'm not sure, about what type of relationship I should to use between Area and Locality identities. I have this doubt because Locality is an identity for all locality and not only for Area identity.

My prospect is this

enter image description here

can you help me to understand?

thanks

War es hilfreich?

Lösung

An Area has many Localities, and a Locality belongs to a single Area:

enter image description here

Also, don't use id for identifiers, you'll get clashes with Core Data's internal id attribute, use a specific name for your id as I've shown in my diagram.

Edited following comment

If a Person also has localities:

enter image description here

And now you also have an implied link between Person and Area.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top