jeudi 28 janvier 2016

Data Model to fit the database or the view logic on android

How should I implement the Data Object of my SQLite database for an Android App.

Here is the data:

TABLE CLIENT
-- clientId (PRIMARY KEY)
-- clientName
-- clientPhoneNumber
-- clientBirthDate

TABLE ORDER
-- orderId (PRIMARY KEY)
-- orderDate
-- orderNumber
--clientId  (FOREIGN KEY)

Should the Data Object of Client looks like that:

public class ClientData{
   private int clientId;
   private String clientName;
   private String clientPhoneNumber;
   private String clientBirthDate;
   ...
}

or this

public class ClientData{
   private int clientId;
   private String clientName;
   private String clientPhoneNumber;
   private String clientBirthDate;
   private ArrayList<OrderData> orderList;
   ...
}

In the app, there is a ExpandableListView for all the client and when I click on one, it expand to show his order. So to fit the purpose I was thinking it would be more convenient to bind those order in the DataObject but then it wouldn't be the same as the database Table row... What is the best practice here? Mapping the database exactly the same or adapting it to the needs of the view.

Aucun commentaire:

Enregistrer un commentaire