|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Int vs tinyintIs there a good reason to use int over tinyint for my look up table primary
keys? I usually use int, but most of my look up table are 20 - 100 items max. I know one reason would be that you could not use a -1 as it is an unsigned byte ( I believe). Thanks, Tom The proper data type selection depends mostly on the domain of values you
need to store. A positive side affect is a smaller value range also takes up less space. It can be a bit of a pain to change later so it's usually better to err on the high side. -- Show quoteHope this helps. Dan Guzman SQL Server MVP "tshad" <tscheider***@ftsolutions.com> wrote in message news:%23DDn4TxEGHA.648@TK2MSFTNGP14.phx.gbl... > Is there a good reason to use int over tinyint for my look up table > primary keys? > > I usually use int, but most of my look up table are 20 - 100 items max. I > know one reason would be that you could not use a -1 as it is an unsigned > byte ( I believe). > > Thanks, > > Tom > tshad (tscheider***@ftsolutions.com) writes:
> Is there a good reason to use int over tinyint for my look up table I usually go for smallint in these cases. Not so much for the sign issue, > primary keys? > > I usually use int, but most of my look up table are 20 - 100 items max. I > know one reason would be that you could not use a -1 as it is an unsigned > byte ( I believe). but more as a matter of routines. Sometimes you can come scaringly close to 256. One aspect here is to make it easy to program. It's faily easy if you know that an id in look-up tables is usually smallint, where as ids in main entity tables are usually int. If you throw in tinyint into the mix, programmers can more easily get confused, and use tinyint for variables or temp-table columns that should be smallint. -- Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se Books Online for SQL Server 2005 at http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx |
|||||||||||||||||||||||