Saturday, February 25, 2012

database design question

Hi. I have a new OLTP database requirement, and was wondering what columns
do some of you use in your db design for primary keys, since identity
columns can't really be used for this? I was thinking of using the select
convert(int, convert(varbinary, newid())) to insert. Any drawbacks to this?
Other suggestions would be appreciated. Thanks.
Alex IvascuIn article <8I0lb.2146$f86.1093@.newssvr25.news.prodigy.com>,
alexdivascu@.sbcglobalNO.SPAMnet said...
> Hi. I have a new OLTP database requirement, and was wondering what columns
> do some of you use in your db design for primary keys, since identity
> columns can't really be used for this? I was thinking of using the select
> convert(int, convert(varbinary, newid())) to insert. Any drawbacks to this?
> Other suggestions would be appreciated. Thanks.
Why not just use a GUID?|||I was thinking about storing it as an int... But, I guess a varchar would
do just fine.
"Brad" <me@.privacy.net> wrote in message
news:MPG.19fe630a4934c2ea98b876@.news...
> In article <8I0lb.2146$f86.1093@.newssvr25.news.prodigy.com>,
> alexdivascu@.sbcglobalNO.SPAMnet said...
> > Hi. I have a new OLTP database requirement, and was wondering what
columns
> > do some of you use in your db design for primary keys, since identity
> > columns can't really be used for this? I was thinking of using the
select
> > convert(int, convert(varbinary, newid())) to insert. Any drawbacks to
this?
> > Other suggestions would be appreciated. Thanks.
> Why not just use a GUID?|||In article <G11lb.2155$%a6.1679@.newssvr25.news.prodigy.com>,
alexdivascu@.sbcglobalNO.SPAMnet said...
> "Brad" <me@.privacy.net> wrote in message
> news:MPG.19fe630a4934c2ea98b876@.news...
> > In article <8I0lb.2146$f86.1093@.newssvr25.news.prodigy.com>,
> > alexdivascu@.sbcglobalNO.SPAMnet said...
> > > Hi. I have a new OLTP database requirement, and was wondering what
> columns
> > > do some of you use in your db design for primary keys, since identity
> > > columns can't really be used for this? I was thinking of using the
> select
> > > convert(int, convert(varbinary, newid())) to insert. Any drawbacks to
> this?
> > > Other suggestions would be appreciated. Thanks.
> >
> > Why not just use a GUID?
> I was thinking about storing it as an int... But, I guess a varchar would
> do just fine.
Don't store it as a VarChar, store it as a UniqueIdentifier. It will save
space and index more efficiently.

No comments:

Post a Comment