Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Aug 2, 2011, 02:34 PM   #1
mraheel
macrumors regular
 
Join Date: Apr 2009
Using UUID as pkey in sqlite db

Hey guys,

I wanted to know more about this UUID for iOS.

Quote:
UUID’s are 128-bit values which are guaranteed to be unique – typically the value is based on a machines ethernet address combined with the current time since October 15, 1582.
UUID’s are string values separated by hyphens, for example, here is how a UUID may look: 13222F23-C76A-7781-0C12-0293E3B34398.
I know some todo app that uses it as a task ID. perhaps suffixing it with their own tag or something.

I wanted to know what are the advantages of using such identifiers in SQLite instead of say a normal integer based / autoincrementing primarykey.

Apparently they are guaranteed to be unique, Can I trace a UUID to something? say date/time created or attach it to some device?

My intention is to use it in an app that has to do with Storage purposes using Sqlite and no, its not another todo app.

any any comment is appreciated.
mraheel is offline   0 Reply With Quote
Old Aug 2, 2011, 06:23 PM   #2
idelovski
macrumors regular
 
Join Date: Sep 2008
I am not sure what is the real question here, but let's assume it was "what are the advantages of using such identifiers in SQLite instead of say a normal integer...?"

Well, for example this comes handy if you need to combine records from two or more sources into a single centralized database.
idelovski is offline   0 Reply With Quote
Old Aug 3, 2011, 07:15 AM   #3
PhoneyDeveloper
macrumors 68030
 
PhoneyDeveloper's Avatar
 
Join Date: Sep 2008
The UUID is unique for each device. Each device has one and only one and no other device has the same one.

I don't see why you would use it for a sqlite db on the device.

It is used by some to identify data sent from users to a server-based db. Some security professionals consider using the UUID in this manner to be an invasion of privacy. Many analytics and ad-servers etc do send the UUID off the device and use it as a unique identifier, behind the back of the user.
PhoneyDeveloper is offline   0 Reply With Quote
Old Aug 3, 2011, 10:01 AM   #4
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by PhoneyDeveloper View Post
The UUID is unique for each device. Each device has one and only one and no other device has the same one.
UUID is a Universally Unique IDentifier. It's a generated value, and changes each time it's generated. It has a statistically low probability of being generated by another device, or at another time (practically unique).

UDID is the device's Unique Device IDentifier. It's a stored immutable value, that is always the same on each device, but different across devices (guaranteed unique). It's effectively the device's unique serial number.
chown33 is offline   0 Reply With Quote
Old Aug 3, 2011, 02:11 PM   #5
bbarnhart
macrumors 6502a
 
bbarnhart's Avatar
 
Join Date: Jan 2002
Location: Stilwell, Kansas
Send a message via Skype™ to bbarnhart
There is no benefit in using a UUID or GUID as a key compared to an autoincrement integer.
bbarnhart is offline   0 Reply With Quote
Old Aug 3, 2011, 03:29 PM   #6
idelovski
macrumors regular
 
Join Date: Sep 2008
Now I'm lost - are we talking about device id here or about the value returned by CFUUIDCreate() function? At first I was sure it's the later.

Code:
   CFUUIDRef    newUniqueID    = CFUUIDCreate (kCFAllocatorDefault);
   CFStringRef  newUniqueIDStr = CFUUIDCreateString (kCFAllocatorDefault, newUniqueID);
idelovski is offline   0 Reply With Quote
Old Aug 3, 2011, 03:53 PM   #7
mraheel
Thread Starter
macrumors regular
 
Join Date: Apr 2009
Thanks for the input guys.

@PhoneyDeveloper, I got you confused, i should have stressed it. I'm referring to UUID and not UDID as chown33 pointed out.

Quote:
I don't see why you would use it for a sqlite db on the device.
I know a todo app that uses this UUID with a custom 5 letter suffix.
A UUID is assigned to each task created. Which can be shared via email with another app. They have pushnotification reminders etc.

This app kinda inspired me to ask the utility of UUID.

Im in the process of making similar app with enduser storage management using sqlitedb. Just wanted to make things "future proof" if and when i decide to add certain features. The presence of UUID should make things easier.

I have no clue as to what those features might be!
mraheel is offline   0 Reply With Quote
Old Aug 3, 2011, 05:03 PM   #8
admanimal
macrumors 68040
 
Join Date: Apr 2005
Quote:
Originally Posted by bbarnhart View Post
There is no benefit in using a UUID or GUID as a key compared to an autoincrement integer.
There is if you want the keys to be unique across devices, although I'm not sure if it's technically more efficient to use a regular integer as the primary key and have the UUID be another column that you only use when you need to find/compare things across devices.
admanimal is offline   0 Reply With Quote
Old Aug 3, 2011, 06:32 PM   #9
mraheel
Thread Starter
macrumors regular
 
Join Date: Apr 2009
Quote:
Originally Posted by admanimal View Post
although I'm not sure if it's technically more efficient to use a regular integer as the primary key and have the UUID be another column that you only use when you need to find/compare things across devices.
Thats what I wana find out. I guess it wouldnt be efficient. But how bad could it be?
And again, the benefit? apart from its uniqueness across devices; practically what are its applications?
mraheel is offline   0 Reply With Quote
Old Dec 2, 2011, 01:28 PM   #10
siggimoo
macrumors newbie
 
Join Date: Dec 2011
Quote:
Originally Posted by bbarnhart View Post
There is no benefit in using a UUID or GUID as a key compared to an autoincrement integer.
This is untrue. The main point of UUIDs is the lack of a need to consult a central authority in order to generate an identifier. Each party can just make up their own whenever they need to. Sequential values, on the other hand, have to be coordinated. Now whether or not this capability is a benefit to a given system system depends on the needs of that system.
siggimoo is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Tags
pkey, sqlite, uuid

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
UUID Command in Terminal? cdoolittle17 Mac Programming 3 Feb 28, 2014 12:54 PM
Computer shut down, Anonymous UUID? Politis MacBook Pro 4 Jun 20, 2013 08:55 PM
Edit Mac Hardware UUID (Universal Unique Identifier) padgo iMac 0 Feb 7, 2013 10:44 PM
2nd hand iMac, probably hardware UUID issue, buy or not? Serafijn iMac 4 Oct 31, 2012 07:41 AM
I think I know why they don't check UUID anymore... FrancoisC iOS 6 1 Jun 30, 2012 10:17 PM

Forum Jump

All times are GMT -5. The time now is 10:29 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC