I have a Repository, LocalDataSource, ContentProvider and Sqlite Database like in this architecture : https://github.com/googlesamples/android-architecture/tree/todo-mvp-contentproviders/
Objects have identifiers values (not necessary int type, herited from reading an API). Some objects have a combinaison of multiple values as identifier.
What is the best implementation in terms of readability, maintenability ? (I have no problem of data integrity)
Choice 1 :
- Database has a (local) id primary key autoincrement
- Content provider use this id during insert (with check if already exist), update and delete operations
- Repository and LocalDataSource implements the logic of identifiers values
In this choice, the complexity is on repository.
Choice 2 :
- Database have the real id of data as primary key (and sometimes foreign key).
- Content provider use the real id of data during insert (with check if already exist), update and delete operations.
- Repository and LocalDataSource implements a simple logic of insert, update delete.
In this choice, the complexity is on content provider.