Skip to content Skip to sidebar Skip to footer

Android: Creating A Sqlite Database With A Relationship

I am trying to create an application which requires a two table SQLite database with a one to many relationship. Basicly the first table will allow a user to create an employee, w

Solution 1:

This tutorial leads me to successfully creating DAO class implementation: http://www.vogella.de/articles/AndroidSQLite/article.html

There's no enforced relationship though, I heard it's not good for performance anyway so I stop looking.

I end up having one DBHandler that keep tracks of DB version for create/update tables. I also have DBOpenHelper for help opening/close connections. Since I have two tables (for the purpose of example I will stick with Employee and Contact), I have one DAO of each type both contain DBOpenHelper.

Hope this helps :)


Solution 2:

A search on Google gave this tutorial. It demonstrates QUERIES on multiple tables using JOIN. You could probably extrapolate the QUERY concept and use them to add entries. Just a thought really, but hope it helps you go in the right direction.

http://mobile.tutsplus.com/tutorials/android/android-sqlite/

A similar question on SO: Android: SQLite one-to-many design

This one does not have a definitive answer either. But, again, it might help.


Solution 3:

For those who are seeing this question now arguably has a great design here: http://greendao-orm.com/


Post a Comment for "Android: Creating A Sqlite Database With A Relationship"