"how to create nested tables in sqlite database?? (android)" Code Answer

5

what you're describing isn't possible; there is no way to include a table within a row in another table. standard practice is to create "parent/child" tables by including the primary key of the parent table as a column in the child table; for instance:

parent table

id | name
---------
1  | fred
2  | bob

child table
id | parent_id | name
---------------------
1  | 1         | john
2  | 1         | jim
3  | 2         | joe
4  | 2         | jane

this pair of tables would have "john" and "jim" as the children of "fred", and "joe" and "jane" as children of "bob". you could get the set of all children of "bob" (parent id=2) with the query:

select * from child_table where parent_id = 2
By Seb Andraos on March 22 2022

Answers related to “how to create nested tables in sqlite database?? (android)”

Only authorized users can answer the Search term. Please sign in first, or register a free account.