Open bsagal opened 11 years ago
Do we know if Android supports foreign keys? I have never used them in an app because I assumed they were not supported and they are often an unnecessary overhead, however it should be easy enough to add.
What do you think?
Sqlite supports (http://www.sqlite.org/foreignkeys.html) it and it provides constancy when adding records,
So there are a few interesting issues with this, looks like foreign key contraints were available from Android 2.2 but have to be enabled with a PRAGMA Statement:
http://code.google.com/p/android/issues/detail?id=11607
The stack post is interesting because its only until Android 4.1 (API LEVEL 16) that a specific method was introduced to enable foreign keys:
I can look at implementing this feature after I finish writing docs (currently rewriting documentation), and I am also willing to except pull requests that implement it.
Any progress on integrating the foreign key definitions into the grammar of mechdb? I would be keen trying this out.
I can see if I can get some time to add the grammar constructs, I put this off because I am yet to make an app that enforces key constraints, I have always seen Android DB as a lightweight data cache so i try to keep my tables as flat as possible, I believe this is how most apps use it.
I am happy to except pull requests that add grammar support to this! :) Anyone willing to give it a try should gain an understanding of xtext http://www.eclipse.org/Xtext/
There does not seem to be a way the specify Foreign key references in MECHDB