Keyvalues in the Database

For any problems with Dawn of Light website or game server, please direct questions and problems here.

Moderator: Support Team

Keyvalues in the Database

Postby SyLuS » Mon Oct 08, 2012 8:04 am

Hey guys,

i want to add sone stuff to the database. By doing so ive seen, that the primary keys in the tables always filled with xxxxx-xxxx-xxxxx. Is there any reason for doing this? And how do you create these code? Is it just random or some kind of hash?

LG

SyLuS
SyLuS
DOL Initiate
 
Posts: 16
Joined: Thu Oct 04, 2012 6:08 am

Re: Keyvalues in the Database

Postby Dunnerholl » Mon Oct 08, 2012 8:51 am

its a uniqueidentifier (GUID) created by c# code and "necessary" for the currently used databaselayer (nhibernate in some version)
Dunnerholl
Developer
 
Posts: 1229
Joined: Mon Sep 08, 2008 8:39 pm

Re: Keyvalues in the Database

Postby SyLuS » Mon Oct 08, 2012 8:55 am

Okay.

Can you please tell me how it is create or where i can found the code which creates it?

Im currently write a little off server tool to administer merchants (specially changing item list).
SyLuS
DOL Initiate
 
Posts: 16
Joined: Thu Oct 04, 2012 6:08 am

Re: Keyvalues in the Database

Postby Graveen » Mon Oct 08, 2012 9:08 am

just take an unique string.

can be sylus-001, sylus-002, etc....

i tell it once again: it must be unique !
Image
* pm me to contribute in Dawn of Light: code, database *
User avatar
Graveen
Project Leader
 
Posts: 12661
Joined: Fri Oct 19, 2007 9:22 pm
Location: France

Re: Keyvalues in the Database

Postby SyLuS » Mon Oct 08, 2012 9:32 am

You dont have to tell me, that it have to be unique.

I just wanted to know, how do you create this unique value. Is there any hash function for doing that?

My solution were to take a random number, convert them to binary. Foreach 0 create an random number and foreach 1 create an random character so i will get an random string with characters and numbers.

So i use this 3 Times ( XXXXX - XXXX - XXXXX ) and use this as unique key.

But if there is a function already i dont have to code it ^^

Dont invent the wheel every time new.
SyLuS
DOL Initiate
 
Posts: 16
Joined: Thu Oct 04, 2012 6:08 am

Re: Keyvalues in the Database

Postby Dunnerholl » Mon Oct 08, 2012 12:16 pm

as i said before: System.Guid

System.Guid.NewGuid();
Dunnerholl
Developer
 
Posts: 1229
Joined: Mon Sep 08, 2008 8:39 pm

Re: Keyvalues in the Database

Postby SyLuS » Mon Oct 08, 2012 2:04 pm

Thanks
SyLuS
DOL Initiate
 
Posts: 16
Joined: Thu Oct 04, 2012 6:08 am

Re: Keyvalues in the Database

Postby Blue » Mon Oct 08, 2012 6:42 pm

Any key you think of which is unique will do. So its completely legit to do names like "toaspell1". The autogeneration always uses GUID to prevent collisions. The advantage is you can easily merge in data from others which won't be easily possible with lets say integer keys.
ex DOL Lead Developer
Blue
Uthgard Admin
 
Posts: 961
Joined: Wed Jan 21, 2004 11:07 pm
ICQ: 63977313


Return to “%s” Support

Who is online

Users browsing this forum: No registered users and 0 guests