dimanche 24 janvier 2016

Android The right way for database design of nested objects

I have app that should store values from Foursquare API. Model of objects has complex nested structure, e.g.:

public class Item {

    @SerializedName("venue")
    @Expose
    private Venue venue;
    @SerializedName("tips")
    @Expose
    private List<Tip> tips = new ArrayList<Tip>();
    @SerializedName("referralId")
    @Expose
    private String referralId;

...

public class Venue {

    @SerializedName("id")
    @Expose
    private String id;
    @SerializedName("name")
    @Expose
    private String name;
    @SerializedName("contact")
    @Expose
    private Contact contact;
    @SerializedName("location")
    @Expose
    private Location location;

As for database structure in terms of normalization I saw quite often two similar approaches - store id of the nested tables row(locations, contacts, photos, tips) in the main table(venues) or store id of the main table rows in nested tables. Which approach is more proper and better from point of database architecture design?

Aucun commentaire:

Enregistrer un commentaire