Sunday, March 13, 2011

Re: [android-developers] SQLite Database - Multiple Tables

SQLite has foreign key support starting with version 3.6.19.

http://www.sqlite.org/foreignkeys.html

Some versions of Android have SQLite versions earlier than that - someone posted a breakdown recently, check the list archives.

For earlier versions, it works pretty well to do something like:

CREATE TABLE ....
.....
        ref_id_value INTEGER NOT NULL REFERENCES the_other_table (_id)


For transactions, check SQLiteDatabase docs:

http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#beginTransaction()

The above gives the usual pattern for using transactions.

-- Kostya

13.03.2011 13:16, Brad Stintson пишет:
How to use transaction and how to implement the concept of foreign key?

2011/3/13 Kostya Vasilyev <kmansoft@gmail.com>

Multiple inserts, one at a time. Preferably using a transaction.

13.03.2011 12:58 пользователь "Brad Stintson" <geek.binary@gmail.com> написал:

> How to insert multiple tables which have few fields in common?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


--  Kostya Vasilyev -- http://kmansoft.wordpress.com 

No comments:

Post a Comment