Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do you decide the length of GUID field?
Message
From
29/08/2008 08:56:11
 
 
To
28/08/2008 06:03:37
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01336497
Message ID:
01343053
Views:
18
Cetin, I do not use GUID in PK just because of performance. I don't think they are a waste of space.

I call waste of space when, for example:
- The tables are not well normalized
- The programmer tries to store everything under the sun, be it usefull or not
- Field lenghts are not well studied. For example: the lot number for production lots. It is usually no more than 10 characters, but some suppliers go up to 15. It is hard to find longer lengths. So give it 15, instead of 25-30 just because space is cheap ....

>You are right of course:) Mine was a ironical reply to whom that cares the "wasted" space using GUID vs integer:) GUID is not wasting a bit but using that space to the last byte - just in favor of preventing conversions at runtime:)
>
>BTW my 36 suggestion was solely based on experience. Logically (and physically) the 16 bytes format would do, but conversions needed at runtime, reading from/to backends like SQL server would need further code (is that bloat in code).
>
>And finally for a purist who wants integers as keys a "GUID" might exist (there is collision chance of less than 5 per 100000 as I have seen):
>
>
>Declare Integer UuidCreate In 'RPCRT4.dll' String @pguid
>Declare Integer StringFromGUID2 In 'Ole32.dll' ;
>	string rguid, String @lpsz, Integer cchMax
>
>CREATE CURSOR myIntGuids (guid i)
>LOCAL lnId
>FOR ix=1 TO 100000
>	lnId = val(sys(2007,guid(),1,1))
>	DO WHILE m.lnId > 0x7FFFFFFF
>		lnId = val(sys(2007,guid(),1,1))
>	enddo
>	INSERT into myIntGuids values(m.lnID)
>endfor
>SELECT guid FROM myIntGuids HAVING COUNT(*) > 1 group BY 1
>
>PROCEDURE guid
>	Local pguid,rguid
>	pguid=Replicate(Chr(0),16)
>	rguid=Replicate(Chr(0),80)
>
>	UuidCreate(@pguid)
>	StringFromGUID2(pguid,@rguid,40)
>	RETURN Strconv(Left(rguid,76),6)
>ENDPROC
>
>
>Integer fields cannot store integer values is another problem but majority seems to be unaware of it:)
>
>Cetin
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform