Implement subitem in SQLite

Posted by Mohit Deshpande on Stack Overflow See other posts from Stack Overflow or by Mohit Deshpande
Published on 2011-01-02T14:50:25Z Indexed on 2011/01/02 14:53 UTC
Read the original article Hit count: 263

Filed under:
|
|

How could I implement a sub item where the item would have a parent to that of the same item. For example, I have a database that holds tasks/todos. Each todo has a title(TEXT), completed(INTEGER [1 if true, 0 if false]), and due date(TEXT) column. I would like to add functionality to have subtasks, where a task could possibly have a parent task. How would I implement this in SQLite for Android? NOT IN SQL! So no foreign keys (triggers are allow, though)! Could I just have a separate table (subtask) and have a foreign key trigger to link subtask(INTEGER parent) to task(INTEGER PRIMARY KEY AUTOINCREMENT _id)? Or should I add a column to my original task table(INTEGER parent)? How could I implement this?

© Stack Overflow or respective owner

Related posts about android

Related posts about sqlite