• Toll-free  888-665-8637
  • International  +1 717-220-0012
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

pbeaul
#1 Posted : Friday, June 15, 2007 7:07:18 PM(UTC)
pbeaul

Rank: Member

Joined: 8/10/2004(UTC)
Posts: 23

I've been looking over the database schema and I couldn't help but notice that all PK/FK's are all varchar(36) fields. Can anyone help me understand why you would store GUID's into a varchar(36) field instead of using the purpose built uniqueidentifier datatype?


I've been racking my brain for a few hours trying to think of a good reason why you would want to incur the added overhead and double the storage requirements of using the varchar datatype over a uniqueidentifier... Hopefully I'm overlooking something.



Any insight would be much appreciated.
Kman
#2 Posted : Saturday, June 16, 2007 9:30:45 AM(UTC)
Kman

Rank: Member

Joined: 11/25/2003(UTC)
Posts: 370

Think about importing and exporting data to and from your database and related tables. It is much better to id each row by the guid rather than an identifier. The guid never changes.
Regards,
Kim(Kman) Rossey
www.toocoolwebs.com
BVSoftware - MerchantTribe Programming/Design, Database Programming and Business Applications
[email protected]
bvuser
#3 Posted : Saturday, June 16, 2007 11:23:13 PM(UTC)
bvuser

Rank: Member

Joined: 4/10/2006(UTC)
Posts: 462

Kim,

pbeaul is referring to the new sql 2005 datatype, "uniqueindentifier", which basically acts like and indentity in the sense that it is autogenerated, but instead of generating an int it generates a Guid for you.

pbeaul,

Based on what I have seen, the reason for this may be do to the way they designed the BVC2004 to BVC5 migration tool. While I don't agree with their choice on the way the tool was designed, it did/does simplify the migration code. Essentially, if you create a new product in bvc5, it assigns it a guid and stores the "sku" in a seperate field. The migration tool, for whatever reasons, imports a bvc2004 product by the sku and stores that sku in both the sku field and the field where the current guid for the product is stored. Why they did it this way, I don't know.

Apart from that, the only other reasoning I can think of for their design choice, is there is a chance that at the beginning of development they were contemplating support for additional dbs other than sql 2005 (2000 maybe??) and by designing putting the generation of the guid in the .net code, the software would not be dependent on sql 2005.

Most likely the reason is option #2.
Netriplex Corporation<br />
pbeaul
#4 Posted : Saturday, June 16, 2007 11:23:18 PM(UTC)
pbeaul

Rank: Member

Joined: 8/10/2004(UTC)
Posts: 23

Yes, I'm well aware of what a GUID (Globally Unique Identifier) is... Not sure if you're familiar with MSSQL 7.0 -&gt; MSSQL 2005 but a native GUID datatype exists and it's called UniqueIdentifier ( http://msdn2.microsoft.com/en-us/library/ms187942(SQL.90).aspx ). Not to be confused with Integer based Identity fields. Using the native GUID datatype makes it even easier to import/export/replicate tables between databases.


I'm mainly having a hard time understand why you would choose the added overhead and more than double the storage requirements of varchar(36) when a native type exists. I don't have any performance figures but I have had real hard time believing that 36 byte varchar's outperform uniqueidentifier fields.
pbeaul
#5 Posted : Sunday, June 17, 2007 9:22:59 AM(UTC)
pbeaul

Rank: Member

Joined: 8/10/2004(UTC)
Posts: 23

[quote="bvuser"]
Kim,

pbeaul is referring to the new sql 2005 datatype, "uniqueindentifier", which basically acts like and indentity in the sense that it is autogenerated, but instead of generating an int it generates a Guid for you.
Actually, UniqueIdentifier have been around since MS SQL 7.0, they did add a few new GUID functions/features to MS SQL 2005 but the datatype itself is not new.

[quote="bvuser"]

pbeaul,


Based on what I have seen, the reason for this may be do to the way they designed the BVC2004 to BVC5 migration tool. While I don't agree with their choice on the way the tool was designed, it did/does simplify the migration code. Essentially, if you create a new product in bvc5, it assigns it a guid and stores the "sku" in a seperate field. The migration tool, for whatever reasons, imports a bvc2004 product by the sku and stores that sku in both the sku field and the field where the current guid for the product is stored. Why they did it this way, I don't know.

Apart from that, the only other reasoning I can think of for their design choice, is there is a chance that at the beginning of development they were contemplating support for additional dbs other than sql 2005 (2000 maybe??) and by designing putting the generation of the guid in the .net code, the software would not be dependent on sql 2005.

Most likely the reason is option #2.



UniqueIdentifier fields by default do not automatically assign themselves a GUID value (like Identity int fields would). So the developer must still generate a GUID and pass it to the DB... instead of passing SomeGuid.ToString() you pass the GUID object itself.



I remember reading about a test repository somewhere on this site and I was wondering if anyone could point me to it. I've looked around my local files but I wasn't able to find it... I'm fairly certain this would cause a moderate performance hit, specially on where clauses and join's...



I was all but sold on BVC5 until I started digging in the DB, it leaves a little to be desired... Hopefully my performance assumtions are all wrong because I could live with inefficient key storage.
pbeaul
#6 Posted : Tuesday, June 19, 2007 5:28:35 PM(UTC)
pbeaul

Rank: Member

Joined: 8/10/2004(UTC)
Posts: 23

Does anyone know where I can find that sample store data for BVC5?
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

©2025 Develisys. All rights reserved.
  • Toll-free  888-665-8637
  • International  +1 717-220-0012