When to use integer keys?
From: Kramer <johnlkramer_at_gmail.com>
Date: 23 Jan 2007 12:17:15 -0800
Message-ID: <1169583435.364698.160190_at_v45g2000cwv.googlegroups.com>
Hi. I'd like to know when it is appropriate to use an integer and when to just use the text. For example, I have a database here which represents input to an application. One table Input stores many records each of which corresponds to a "block" (doesn't matter what that means). We now need to store the block type. Each block type is text that could be as much as 30 characters. There seem to be two ways to represent this.
Table Name: BlockTypes |
BlockTypeID : Integer<----/
BlockTypeName : VarChar(30)
Date: 23 Jan 2007 12:17:15 -0800
Message-ID: <1169583435.364698.160190_at_v45g2000cwv.googlegroups.com>
Hi. I'd like to know when it is appropriate to use an integer and when to just use the text. For example, I have a database here which represents input to an application. One table Input stores many records each of which corresponds to a "block" (doesn't matter what that means). We now need to store the block type. Each block type is text that could be as much as 30 characters. There seem to be two ways to represent this.
- Just store the name:
Table Name: Input
...
BlockType : Varchar(30)
2) Seperate Tables:
Table Name: Input
...
BlockTypeID : Integer -----
|
Table Name: BlockTypes |
BlockTypeID : Integer<----/
BlockTypeName : VarChar(30)
Now there will be many more entries in the table Input than in the table BlockTypes. Thus the two seperate table would seem to save some space, but I'm not sure if the space is critical. Are other advantages for using two separate tables? Are there advantages for using one table?
Thanks in advance for any help. Received on Tue Jan 23 2007 - 21:17:15 CET