![]() ![]() The SQLite FOREIGN KEY clause is a rule (constraint) that says that the value of the column MUST be an existing value in the table/column(s) specified. "referencedColumns": is annotation that adds the SQLite FOREIGN KEY clause. Public Notes(int noteID, int sourceID, int commentID, int questionID, int quoteID, int termID, int topicID, int deleted)` (`TopicID`)" Private int = "Deleted", defaultValue = "0") Private int = "TermID", defaultValue = "0") Private int = "QuoteID", defaultValue = "0") Private int = "QuestionID", defaultValue = "0") I thought about try an OnConflict annotation but wanted to reach out for some thoughts and suggestions.ĮNTITY = "Notes", foreignKeys = Sources.class, parentColumns = "SourceID", childColumns = Comments.class, parentColumns = "CommentID", childColumns = Questions.class, parentColumns = "QuestionID", childColumns = Quotes.class, parentColumns = "QuoteID", childColumns = Terms.class, parentColumns = "TermID", childColumns = Topics.class, parentColumns = "TopicID", childColumns = "TopicID")}, Since Android Room is in essence wrapping the SQLite for ease of use, so far, I haven't been able to determine how to get it to accept zero values on foreign keys. However, based on the user entries, there are 3 foreign keys which it is possible the user did not add anything to be referenced. What I'm trying to do: This join table captures ids from 6 tables. I will still be re-reading some at the time of this post but I'm sure I'm just overlooking some thing - the old 80/20 rule. ![]() I tried default values but and setting up for null but can't seem to get it to work. I've read some posts here and elsewhere with examples, and even removed the foreign key declarations that would return zero, but then I had difficulty with the schema starting to trigger on a different table altogether. ![]() What I have tried: I do have this application in a desktop version using SQLite and I have no issue and have tried to set it up the same. I'm still trying to learn Android Room so I'm sure I have overlooked something in the documentation and tutorials. Problem: With Android Room, I'm receiving an foreign key constraint error on a join table when entering zero (0). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |