473,667 Members | 2,760 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GUIDs

Hi All,

I want to use GUIDs for object IDs in my application. This means that
they would be used for primary keys in PostgreSQL, and there would of
course be FKs pointing to them. A GUID is 128 bits, and can be in the
following possible formats:

* 16 byte binary (but then I'd have to convert it to hex in my app)
* 32 byte string (e.g., '4162F7121DD211 B2B17EC09EFE1DC 403')
* hex string (e.g., 0x3271839C163D1 1D891F785398CC7 932E)
* Base 64 string (e.g., 'MnIAdBY9EdiR94 U5jMeTLg==')

It looks like the hex option would be the best option, but there's no
native hex format in PostgreSQL. Anyone have suggestions on what the
best approach might be? I can't convert it to a number, really, because
128 bit numbers aren't too portable).

Please Cc any replies to me, as I'm not subscribed to the mail list.

Many TIA,

David

--
David Wheeler AIM: dwTheory
da***@kineticod e.com ICQ: 15726394
http://www.kineticode.com/ Yahoo!: dew7e
Jabber: Th****@jabber.o rg
Kineticode. Setting knowledge in motion.[sm]
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 12 '05 #1
14 2716
David Wheeler writes:
It looks like the hex option would be the best option, but there's no
native hex format in PostgreSQL. Anyone have suggestions on what the
best approach might be? I can't convert it to a number, really, because
128 bit numbers aren't too portable).


Use bytea. It stores bytes and allows the conversion into several output
formats.

--
Peter Eisentraut pe*****@gmx.net
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 12 '05 #2
On Thursday, November 13, 2003, at 08:04 PM, Peter Eisentraut wrote:
Use bytea. It stores bytes and allows the conversion into several
output
formats.


bytea with the binary or the hex? And isn't it a bit of a waste to add
the extra 4 bytes when I'll only ever need 16?

Thanks,

David

--
David Wheeler AIM: dwTheory
da***@kineticod e.com ICQ: 15726394
http://www.kineticode.com/ Yahoo!: dew7e
Jabber: Th****@jabber.o rg
Kineticode. Setting knowledge in motion.[sm]
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postg resql.org

Nov 12 '05 #3
David Wheeler writes:
bytea with the binary or the hex?
Binary or hex what?
And isn't it a bit of a waste to add the extra 4 bytes when I'll only
ever need 16?


Sure, but if you want to avoid that, you'll have to implement your own
data type. Actually, I think someone has already done that for GUID. If
you search the archives you might find out about it.

--
Peter Eisentraut pe*****@gmx.net
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 12 '05 #4
On Thursday, November 13, 2003, at 08:30 PM, Peter Eisentraut wrote:
Bbytea with the binary or the hex?

Binary or hex what?


Representation of the UUID.
And isn't it a bit of a waste to add the extra 4 bytes when I'll only
ever need 16?


Sure, but if you want to avoid that, you'll have to implement your own
data type. Actually, I think someone has already done that for GUID.
If
you search the archives you might find out about it.


Sure enough. Josh just mentioned this to me:

http://gborg.postgresql.org/project/...rojdisplay.php

Looks like 1.0.0 was released June 17, 2003. I wonder how robust it is?

Cheers,

David

--
David Wheeler AIM: dwTheory
da***@kineticod e.com ICQ: 15726394
http://www.kineticode.com/ Yahoo!: dew7e
Jabber: Th****@jabber.o rg
Kineticode. Setting knowledge in motion.[sm]
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #5
On Thu, Nov 13, 2003 at 19:57:33 -0500,
David Wheeler <da***@kinetico de.com> wrote:
Hi All,

I want to use GUIDs for object IDs in my application. This means that
they would be used for primary keys in PostgreSQL, and there would of
course be FKs pointing to them. A GUID is 128 bits, and can be in the
following possible formats:


Couldn't you use numeric? That should be fairly portable.

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)

Nov 12 '05 #6
On Friday, November 14, 2003, at 12:04 AM, Bruno Wolff III wrote:
Couldn't you use numeric? That should be fairly portable.


Not really. The GUID is 128 bits, which doesn't work so well on 32-bit
systems.

Regards,

David

--
David Wheeler AIM: dwTheory
da***@kineticod e.com ICQ: 15726394
http://www.kineticode.com/ Yahoo!: dew7e
Jabber: Th****@jabber.o rg
Kineticode. Setting knowledge in motion.[sm]
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 12 '05 #7
David Wheeler <da***@kinetico de.com> writes:
On Friday, November 14, 2003, at 12:04 AM, Bruno Wolff III wrote:
Couldn't you use numeric? That should be fairly portable.


Not really. The GUID is 128 bits, which doesn't work so well on 32-bit
systems.


NUMERIC is an arbitrary-precision integer, not a machine word.

-Doug

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 12 '05 #8
On Friday, November 14, 2003, at 06:18 PM, Doug McNaught wrote:
NUMERIC is an arbitrary-precision integer, not a machine word


Yeah, but that doesn't help me in Perl.

Regards,

David

--
David Wheeler AIM: dwTheory
da***@kineticod e.com ICQ: 15726394
http://www.kineticode.com/ Yahoo!: dew7e
Jabber: Th****@jabber.o rg
Kineticode. Setting knowledge in motion.[sm]
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)

Nov 12 '05 #9
On Fri, Nov 14, 2003 at 17:52:41 -0500,
David Wheeler <da***@kinetico de.com> wrote:
On Friday, November 14, 2003, at 12:04 AM, Bruno Wolff III wrote:
Couldn't you use numeric? That should be fairly portable.


Not really. The GUID is 128 bits, which doesn't work so well on 32-bit
systems.


On postgres numeric isn't limited to what can be represented in 32 bits.
I am not sure about other systems, but I would expect it to not be limited
to just 32 bits on them either.

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 12 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3139
by: Jon Perez | last post by:
Is there a Python function that works on all platforms (not just Win32) to generate such in the DCE / Microsoft format? If not present, this looks like it would be a very Pythonic addition to the standard library.
0
1357
by: Shaun Clark | last post by:
Hello, I am trying to bring my entire organization from a Microsoft platform to a Linux one, starting with all of the servers we are currently running. Sun ONE ASP allows me to run ASP on Linux through Apache, Mono is working on .NET, but the one thing I can't migrate is SQL and it's because products like mySQL and Postgres have no built-in GUID support. We have 100 databases with GUIDs as primary keys across all of them. It works great...
8
1385
by: Roland Hall | last post by:
Would a GUID be a good idea to use for a random generated account code. The user will be given a link to pass the GUID and then be prompted for a password. Ex. http://domain.com?id=0D1CB84F-82C0-4097-BA84-8B22B41FA005 TIA... --
4
33923
by: J.Marsch | last post by:
I notice that when I generate various guids, they appear to have a mix of upper and lowercase letters. Is the uniqueness of a guid case-sensitive? In other words, if I generate a guid, and then store it in a database that is case insensitive (or if I convert the letters to upper), is it still statistically unique?
1
10898
by: vector | last post by:
I've got an application that generates GUIDs. A lot of GUIDs. Lots of GUIDs that end up in files on disk, taking up space. I'd like to continue using the Guid.NewGuid() function as my unique tag generator, but I'd also like to compress them to base 36 strings, which should retain their uniqueness but save me disk space. I've looked at various base conversion functions, and haven't found a suitable one. Further, I don't need an AnyBase...
1
1248
by: Andrew S. Giles | last post by:
Hello, I am writing a COM interface to one of my classes, so that the interface bmay be used to provide a means of sending data from a legacy code application to the new .NET user Interface. I have written the interface, and have included it in the inheritance of multiple classs as needed. I know the GUID/UUIDs are needed eventually, but half of the examples I see list them, and half do not.
11
7257
by: Jeff | last post by:
Hi - I'm experiencing a strange problem when comparing 2 guids. In my trial, they're not equal. When I step through the (VB.NET) code, they are evaluated as equal, and when I enter the comparison in the command window, they're not equal. I'm pretty stumped on this one. Please help. I've tried the following structures, all with the same result: guid1.equals(guid2)
2
1151
by: Howard Kaikow | last post by:
Being lazy, I sometimes copy a project to another directory, then tweak the code. A problem arises because then both projects have identical GUIDs in the .sln file, and in the assembly file. Is there any way to change the GUIDs, other than by overcoming my laziness and creating a New Project instead of copying the files? --
14
2700
by: Chris Dunaway | last post by:
I have used Guid's as a unique identifier in data applications. But in a recent project, the length of the Guid's string is proving to be too long. Is there a method for generating a unique string that is less than the length of a Guid? If I were to take the hash of a Guid string, what is the likelyhood that two different Guids would have the same hash? Can anyone offer any other suggestions?
1
2139
by: GHUM | last post by:
Hello, I created lots of guids via pywintypes.CreateGuid() on windows. Now I would like to run the same software on Linux / Solaris / FreeBSD. So I should produce "compatible" GUIDS on that systems. "compatible" having the meaining: "Providing similiar likelehood of collisions".
0
8458
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8790
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8565
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8650
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6206
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4202
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1779
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.