Author Topic: Generate new GUID  (Read 5042 times)

Cisore

  • EA User
  • **
  • Posts: 67
  • Karma: +0/-0
    • View Profile
Generate new GUID
« on: July 19, 2012, 05:50:08 pm »
Hi,

I would like to add a row into the t_xref table.
But I don't know how generate new GUID for the column XRefID

Someone can help me ?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Generate new GUID
« Reply #1 on: July 19, 2012, 05:57:57 pm »

Cisore

  • EA User
  • **
  • Posts: 67
  • Karma: +0/-0
    • View Profile
Re: Generate new GUID
« Reply #2 on: July 19, 2012, 07:24:30 pm »
given that a the goal of a forum is to help people.

I make a report of my recherche. (like this people how look answer on google will can find other answer that "look on Google" ) :

GUID it's not a ID specific at EA. (but at windows)
For generate it they are a library (in C# but certainly with other language to) : Guid

It's possible to generate new GUID with this code :
Code: [Select]
Guid g1 = Guid.NewGuid();
g1.ToString();


The guid generate looks like this :
02cdf22d-4f04-4e9a-9f3f-0a76234ee360

but the GUID in EA looks like this:
{9EB55AB6-7E25-4711-8F03-FA3E982652E1}

I think it's not important (but may be it's wrong)

For people how have the same question like me :
They have not method in EA for check if the GUID doesn't already exist in the Model.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Generate new GUID
« Reply #3 on: July 19, 2012, 10:11:01 pm »
A GUID is unique per se. You don't need to check. It's like betting that a butterfly's wing flap will start a hurricane that lifts a car and drops it on your house.

If you want to use GUIDs in EA you should enclose them in braces. I've never tested to supply something else, but just to be sure. I've also noticed that EA uses capital/lower case letters in a certain way in their GUIDs. I have also no idea how that will influence EA if this convention is broken.

q.

Cisore

  • EA User
  • **
  • Posts: 67
  • Karma: +0/-0
    • View Profile
Re: Generate new GUID
« Reply #4 on: July 20, 2012, 12:20:29 am »
Quote
A GUID is unique per se. You don't need to check. It's like betting that a butterfly's wing flap will start a hurricane that lifts a car and drops it on your house.

I know that, but it's not real write !

128-bits is big enough and the generation algorithm is unique enough that if 1,000,000,000 GUIDs per second were generated for 1 year the probability of a duplicate would be only 50%.

It's a probability extremely low but not non-existent ! (I'm I favor the theory of many! <- don't know if it's name in english)

there was a time when it was thought that a IP on 32bits was sufficient ...

Paulus

  • EA User
  • **
  • Posts: 152
  • Karma: +0/-0
    • View Profile
Re: Generate new GUID
« Reply #5 on: July 20, 2012, 04:34:00 am »
I'm curious: is it safe to generate the guid for an xref and include it in the table?

I mean, after all, you're by-passing the EA GUI.

Has anyone had experience with this?

regards,

Paulus

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Generate new GUID
« Reply #6 on: July 20, 2012, 06:54:38 am »
You can do that. But you should test extensively. Doing such things is always the last resort. Eat or die.

q.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Generate new GUID
« Reply #7 on: July 20, 2012, 10:18:33 am »
Quote
if 1,000,000,000 GUIDs per second were generated for 1 year the probability of a duplicate would be only 50%.
I'm not very good in probability maths. But after that time you created 3*10^16 numbers out of 3*10^38. Seems unlikely that this results in 50% probability. It's more like 10^-22. Or you go on calculating a couple of universe life times...

But of course: the algorithm is human made. And the one from M$ will likely produce only 10^17 different numbers. So there you are with one year. What did Bill say? Never ever will a computer need more the 600 kB. So why produce more GUIDs than needed?

q.