iphone - Is there a way to load sqlite tables without knowing the name of the table? -
my application allows users save data sqlite file. ensure unique table name, want create table name of (date/time) kind of format when user presses "save". there way load of tables in sqlite file without explicitly stating names of tables?
i have list of foods in sqlite file. sqlite file contains bunch of information each of food items in it. user can create own recipe going through sqlite file , adding items list. each item in list represented cell in tableview. when recipe done, want user able save it, , have system automatically add recipe cell in different table view. way, when selects cell, entire recipe displayed (not name of recipe cell title) in next tableview
i don't think you're using sqlite database correctly.
it sounds you're using table per user data item.
the strength of database store data multiple users, multiple items or multiple whatever few tables , retrieve data specific users or items later. tables should have rows added, updated or deleted, in general, tables should not created , destroyed individual data elements.
i suspect you're not understanding concept of joins.
a design describe might this:
user --------------- id first_name last_name email_address ingredient --------------- id name description recipe --------------- id user_id name description serving_size ingredients_id date_created recipe_ingredients --------------------- id ingredient_id quantity unit_of_measure get list of recipes john doe (this query assumes can have 1 john doe), you'd do: select * recipe r r.user_id = (select id user first_name = 'john' , last_name='doe')
or list of recipes ingredients:
select * recipe r join recipe_ingredients ri on r.ingredients_id = ri.id join ingredient on ri.ingredient_id = i.id r.user_id = (select id user first_name = 'john' , last_name='doe')
using design this, whenever user adds new recipe, add row(s) recipe , recipe_ingredients table. or, when add new ingredient, add row ingredients table.
here's link sql joins tutorial.
Comments
Post a Comment