开发者

Database relationships design on android platforms

Hi everyone I'm trying to think about how to get some database designs done for android and i'm thinking if the following is possible.

I'm trying to create a company-employee database where a compa开发者_StackOverflow社区ny has a many-to-many relationship with employees which in turn has a one-to-one relationship with its employee details , depending which company he's in. Basically like this

  1. Company to employee : Many to many
  2. Employee to employee_details : One to one

So the issue now is that I'm thinking of using an android device to browse the information which i'm thinking how I should populate the information ? Should I :

  1. be having the ORM for the relationship above handled by the webserver and handling each call from the device as a individual httpConnect call? or
  2. should I be having the device synchronize with the webserver everytime by downloading the information, and have the android device handle the relationships ?

I want the device to be able to browse the information without lag (which makes it seem method 2 should be the proper choice since it synchronizes the whole database into the phone and browsing is using the sqlite). But what are the choices out there ?

Any tips and comments ? Hope this is not confusing ! Thanks !


Even the second option can look like a better way it can be much more complex and the synchronization can takes a long time for larger datasets so you will not have a lag when browsing information but an user can wait for a long time before the application even starts (imagine if user is on 3G or even worse EDGE). Generally second solution have these challenges:

  • How many information to pull from the database? All? Only some companies? Only some employees?
  • How to update stored state? Reload everything? Reload only differences? How to find differences? Will it require push notifications?
  • How often to do reload? When to do initial load?

This is for reading. If you also want some modification on mobile device you can be sure that whole process will be even worse because you must avoid data modification collisions when synchronizing states from multiple devices back to the main database.

The simple way to start is using some combination of both approaches:

  • No local database
  • Data are loaded on demand when needed. For example when user opens the app you will load first 50 companies. When he request more of them you will load another 50 or you will load companies satisfying some search criteria. When user opens comapany you will show first 50 employees and you will work with them in the same way as with companies, same with details.
  • Modification always means persisting changes to the real database
  • If you don't need always fresh data you can implement some local cache and cache some data for few minutes.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜