在将数据价值作为数字或特性时,需要考虑几个问题。 你们应当了解下列问题。
- What will you do if someone decides to enter non numeric characters in the zip or telephone number? dealing with the above example, you will need to remove all non numeric characters for a phone number like (222) 221-0019. The better solution would be to scrub the data before entering it into the database, but storing it as a character can still have its perks.
- Sorting. Please note that ordering characters vs numbers can produce some undesired results. note that the numbers 1, 11, and 2 are sorted differently alphabetically vs numerically. Sorted alpha, the correct order is 1, 11, 2. Numerically, they are sorted as 1, 2, 11. This is a consideration when deciding to store a data value as a number or a character field.
- Space. Storing these as an integer will take 4 bytes. If you store them as a character, this will take 5 bytes for a 5 digit zip, 10 if using unicode. You probably wont save an astronomical amount of space, all things considered, so 1 and 2 should be bigger considerations.
数据库是储存数据。 你们应当真正思考所储存的价值观的意图。 典型的情况是,如果是实际数字数值,则你只想把物品储存在数量上,如果这些数值是你预期会有数字操作的。 例如,货币、年龄、就业年数。
关于通常所有数字的识别资料,例如社会保障号码、街道号码、电话号码,这些真实数字完全是固定的。 它们是“理论”价值,只是使用数字。 你想把它们储存为特征的原因是,如果你预期主要从事基于特性的业务,那么,在将其从数据库中投放时,你将不得不从数字到特性价值中不断处理。
权衡利弊。 Good Luck!