Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.
Hey, to make it clear this is not about how to make a sqlite file. It's more about what steps to take to make the SQL backed app future proof
To make my question simple, an example I wana use is to make a todo app. (it's not that actually) Here's what I want to do: Add new todos, Edit todos Share todos via(email , social sites) Import todos Export/backup todos
Every new added todo wil have primarykey or ID in sqlite. Resetting or deleting todos. I don't want the pkey to auto increment. If a new todo with pkey 2 is created and the deleted, then the 2 pkey will remain unused and over a long period, there may be IDs in 3 digits.
I need a way to make IDs with fixed number of digits and kinda unique to the device.
I'm confused what mechanism should I work out. Any help is appreciated.
Sqlite uses a 32 bit integer to store Pk's. That's VERY large. If you ever reach this number, sqlite automatically finds an empty (previously deleted) PK and use it.
dljefferyPosts: 1,311iPhone Dev SDK Supporter, Registered Users
SQLite actually uses a 64 bit signed int for row ids. So if a user were to create and delete a record every second, 24 hours a day, 365 days a year (and even 366 days a year on leap years) it would take many billions of years before SQLite would need to try to reuse old row ids.
However, if you tack AUTOINCREMENT onto the end, SQLite doesn't ever reuse old rowids. So you might want to keep that in mind; otherwise you might have some very angry users a few hundred billion years from now. They would likely change their five star reviews to 1 star reviews and demand their money back.
I am curious about your comment about wanting ids to be unique to the device. Are you planning on doing some sort of migration/syncing (that is, where you need to always remember where a certain record originated)? If so, you could just pair the rowid with the device UUID for cross-device uniqueness. If you just want to share records but don't need to forever track where they came from, then this won't matter, though.
Recall It!Tag your notes. Tag your photos. Tag your thoughts. Tag your life.
SQLite actually uses a 64 bit signed int for row ids. So if a user were to create and delete a record every second, 24 hours a day, 365 days a year (and even 366 days a year on leap years) it would take many billions of years before SQLite would need to try to reuse old row ids.
However, if you tack AUTOINCREMENT onto the end, SQLite doesn't ever reuse old rowids. So you might want to keep that in mind; otherwise you might have some very angry users a few hundred billion years from now. They would likely change their five star reviews to 1 star reviews and demand their money back.
I am curious about your comment about wanting ids to be unique to the device. Are you planning on doing some sort of migration/syncing (that is, where you need to always remember where a certain record originated)? If so, you could just pair the rowid with the device UUID for cross-device uniqueness. If you just want to share records but don't need to forever track where they came from, then this won't matter, though.
thanks for the explanation. I guess this is what im looking for.
UUID seems interesting. I want to todos to be shared across devices via sync or export via email or just share it with friends. However, im not sure if i'd want to track where it came from. Its just a question of "if i'd have a use for it some time in the future with more added features". i know of some apps that do use this UUID. they store it like {appname}XXXXXX-XXXX-XXXX-XXXXXXX where XX=UUID They do have a rowid.
Replies
Just sounds like maybe its just a requirement that is just a bit over the top?
Recent Posts: Going 100% XIB-less <a href="htt
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesomeexample, if a row with primarykey 91 was deleted, i'd want the new entry to fill that spot and then proceed further.
Your right though, the requirement is kinda over the top. I tell myself that too.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeMake a donation via PayPal.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeHowever, if you tack AUTOINCREMENT onto the end, SQLite doesn't ever reuse old rowids. So you might want to keep that in mind; otherwise you might have some very angry users a few hundred billion years from now. They would likely change their five star reviews to 1 star reviews and demand their money back.
I am curious about your comment about wanting ids to be unique to the device. Are you planning on doing some sort of migration/syncing (that is, where you need to always remember where a certain record originated)? If so, you could just pair the rowid with the device UUID for cross-device uniqueness. If you just want to share records but don't need to forever track where they came from, then this won't matter, though.
Recall It! for iPad
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeUUID seems interesting. I want to todos to be shared across devices via sync or export via email or just share it with friends. However, im not sure if i'd want to track where it came from. Its just a question of "if i'd have a use for it some time in the future with more added features".
i know of some apps that do use this UUID.
they store it like {appname}XXXXXX-XXXX-XXXX-XXXXXXX where XX=UUID
They do have a rowid.
Gotto look into this more.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome