由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - int or varchar?
相关主题
请教2个sql query 问题MySQL DBA 的前途
Urgent help needed, please请问最近几年比较火的数据库方面的topic是什么?
多对多relation?dba interview 都问些啥
how to get all numerical data?DBA会因为云计算,NoSql DB 而日渐下坡,前途昏暗吗?
About INSERT IGNORE新手请教:Java or .NET, DBA? (转载)
用SSIS传table从oracle到mssql,遇到一个奇怪的问题discussion: how to prepare test data?
error file或者exception file发不和谐文章--Oracle is #1 in the RDBMS Sector for 2011 (ZZ)
sql server 面试题 (5)Database Administrator needed (转载)
相关话题的讨论汇总
话题: familyid话题: varchar话题: numeric话题: do
进入Database版参与讨论
1 (共1页)
n********6
发帖数: 1511
1
Survey family and the members
family (id, familyid, familymemberid, familyaddress, ...)
social scientists argue to set familyid and familymemberid in int format because they like keep most variable numeric (e.g. weighting.)
DBAs argue to have familyid and familymemberid in varchar format because there it does not make any sense to do calculation on familyid and familymemberid.
What do you think about this?
Street Smart Answer:
Listen to the Boss. If the Boss is a social scientist, do the numeric. If
the Boss is the CTO/CIO/VP of Tech, do the varchar.:)
B*****g
发帖数: 34098
2
你这个是原创吗?

does

【在 n********6 的大作中提到】
: Survey family and the members
: family (id, familyid, familymemberid, familyaddress, ...)
: social scientists argue to set familyid and familymemberid in int format because they like keep most variable numeric (e.g. weighting.)
: DBAs argue to have familyid and familymemberid in varchar format because there it does not make any sense to do calculation on familyid and familymemberid.
: What do you think about this?
: Street Smart Answer:
: Listen to the Boss. If the Boss is a social scientist, do the numeric. If
: the Boss is the CTO/CIO/VP of Tech, do the varchar.:)

n********6
发帖数: 1511
3
原创!
身边发生的事情。
小事反应大道理。
和数据库有关。
给包子?

【在 B*****g 的大作中提到】
: 你这个是原创吗?
:
: does

B*****g
发帖数: 34098
4
不做calc ID就不能是number?

【在 n********6 的大作中提到】
: 原创!
: 身边发生的事情。
: 小事反应大道理。
: 和数据库有关。
: 给包子?

i****a
发帖数: 36252
5
int is better for performance.

because they like keep most variable numeric (e.g. weighting.)
there it does not make any sense to do calculation on familyid and
familymemberid.

【在 n********6 的大作中提到】
: Survey family and the members
: family (id, familyid, familymemberid, familyaddress, ...)
: social scientists argue to set familyid and familymemberid in int format because they like keep most variable numeric (e.g. weighting.)
: DBAs argue to have familyid and familymemberid in varchar format because there it does not make any sense to do calculation on familyid and familymemberid.
: What do you think about this?
: Street Smart Answer:
: Listen to the Boss. If the Boss is a social scientist, do the numeric. If
: the Boss is the CTO/CIO/VP of Tech, do the varchar.:)

p*********d
发帖数: 136
6
yes, number has better performance in this case for sorting and indexing
b****t
发帖数: 112
7
Prefer int, more escalatable.
Don't really know your data, but suppose, you group people by state / county
, it's easier to say 1~10000 belongs to California, 10001~2000 belongs to ...
Flexible to do grouping, potential for other future marks, e.g. -100 as some
thing, performance cost probably no difference

because they like keep most variable numeric (e.g. weighting.)
there it does not make any sense to do calculation on familyid and
familymemberid.

【在 n********6 的大作中提到】
: Survey family and the members
: family (id, familyid, familymemberid, familyaddress, ...)
: social scientists argue to set familyid and familymemberid in int format because they like keep most variable numeric (e.g. weighting.)
: DBAs argue to have familyid and familymemberid in varchar format because there it does not make any sense to do calculation on familyid and familymemberid.
: What do you think about this?
: Street Smart Answer:
: Listen to the Boss. If the Boss is a social scientist, do the numeric. If
: the Boss is the CTO/CIO/VP of Tech, do the varchar.:)

n********6
发帖数: 1511
8
family is based on the random selection.
familyid is based on time serial.
if varchar, it would be easy for web development

county
...
some

【在 b****t 的大作中提到】
: Prefer int, more escalatable.
: Don't really know your data, but suppose, you group people by state / county
: , it's easier to say 1~10000 belongs to California, 10001~2000 belongs to ...
: Flexible to do grouping, potential for other future marks, e.g. -100 as some
: thing, performance cost probably no difference
:
: because they like keep most variable numeric (e.g. weighting.)
: there it does not make any sense to do calculation on familyid and
: familymemberid.

B*****g
发帖数: 34098
9
我小声说你们公司该换DBA了,闪。

to

【在 n********6 的大作中提到】
: family is based on the random selection.
: familyid is based on time serial.
: if varchar, it would be easy for web development
:
: county
: ...
: some

L*******r
发帖数: 8961
10
VARCHAR使用起来会方便一下,因为任何信息都可以储存。
如果将来你的公司接纳了其他的公司,你必须把这个公司的信息
存到你的数据库里,他们用的是VARCHAR,你就很方便。
INT理论上会有较好的PERFORMANCE,但实际中并
不明显。
另外IDENTITY只是在自动加1,但使用中会非常不方便。
IDENTITY不保证数字是连续的。如果一个INSERT
被ROLLBACK,IDENTITY就不再连续。如果你有
REPLICATION,你需要自己修复一些数据,有
IDENTITY会非常麻烦。
相关主题
用SSIS传table从oracle到mssql,遇到一个奇怪的问题MySQL DBA 的前途
error file或者exception file请问最近几年比较火的数据库方面的topic是什么?
sql server 面试题 (5)dba interview 都问些啥
进入Database版参与讨论
B*****g
发帖数: 34098
11
不用IDENTITY怎么unique

【在 L*******r 的大作中提到】
: VARCHAR使用起来会方便一下,因为任何信息都可以储存。
: 如果将来你的公司接纳了其他的公司,你必须把这个公司的信息
: 存到你的数据库里,他们用的是VARCHAR,你就很方便。
: INT理论上会有较好的PERFORMANCE,但实际中并
: 不明显。
: 另外IDENTITY只是在自动加1,但使用中会非常不方便。
: IDENTITY不保证数字是连续的。如果一个INSERT
: 被ROLLBACK,IDENTITY就不再连续。如果你有
: REPLICATION,你需要自己修复一些数据,有
: IDENTITY会非常麻烦。

g*****e
发帖数: 172
12
小声说,偶現在用的是varchar2.

【在 L*******r 的大作中提到】
: VARCHAR使用起来会方便一下,因为任何信息都可以储存。
: 如果将来你的公司接纳了其他的公司,你必须把这个公司的信息
: 存到你的数据库里,他们用的是VARCHAR,你就很方便。
: INT理论上会有较好的PERFORMANCE,但实际中并
: 不明显。
: 另外IDENTITY只是在自动加1,但使用中会非常不方便。
: IDENTITY不保证数字是连续的。如果一个INSERT
: 被ROLLBACK,IDENTITY就不再连续。如果你有
: REPLICATION,你需要自己修复一些数据,有
: IDENTITY会非常麻烦。

L*******r
发帖数: 8961
13
你说呢?有多少种办法不用Identity也能保证Uniqueness?

【在 B*****g 的大作中提到】
: 不用IDENTITY怎么unique
B*****g
发帖数: 34098
14
量大了performance都不行

【在 L*******r 的大作中提到】
: 你说呢?有多少种办法不用Identity也能保证Uniqueness?
w*r
发帖数: 2421
15
performance performance performance
numeric based id is always the choice. ID should not carry info like state/
county, it is simple violation of normal form 1 .
use id as id, use state as state. do not mix your id with other info, if you
do that, go back to use IMS.VMS.ISPF.COBOL
numeric value as long as its range is big enough to hold data volume is
always the choice, regardless of RDBMS. all implementation of RDBMS uses
storage better on numeric value comparing to its offspring character types.
storage is cheap, IO is not.
end of discussion.
L*******r
发帖数: 8961
16
理论上很正确。

you
.

【在 w*r 的大作中提到】
: performance performance performance
: numeric based id is always the choice. ID should not carry info like state/
: county, it is simple violation of normal form 1 .
: use id as id, use state as state. do not mix your id with other info, if you
: do that, go back to use IMS.VMS.ISPF.COBOL
: numeric value as long as its range is big enough to hold data volume is
: always the choice, regardless of RDBMS. all implementation of RDBMS uses
: storage better on numeric value comparing to its offspring character types.
: storage is cheap, IO is not.
: end of discussion.

i****a
发帖数: 36252
17
there are issue for lookup if you use varchar as ID
performance will be bad for large dataset, and you may run into lookup
errors

【在 L*******r 的大作中提到】
: VARCHAR使用起来会方便一下,因为任何信息都可以储存。
: 如果将来你的公司接纳了其他的公司,你必须把这个公司的信息
: 存到你的数据库里,他们用的是VARCHAR,你就很方便。
: INT理论上会有较好的PERFORMANCE,但实际中并
: 不明显。
: 另外IDENTITY只是在自动加1,但使用中会非常不方便。
: IDENTITY不保证数字是连续的。如果一个INSERT
: 被ROLLBACK,IDENTITY就不再连续。如果你有
: REPLICATION,你需要自己修复一些数据,有
: IDENTITY会非常麻烦。

p*********d
发帖数: 136
18
今天早上起来看,这个上了头条了。 This is rare.
Keep hardworking, guys and gals.
w*r
发帖数: 2421
19
大头,理论和实践上都证明了这是正确的,不要酸溜溜的

【在 L*******r 的大作中提到】
: 理论上很正确。
:
: you
: .

L*******r
发帖数: 8961
20
你在实践中看见区别了?你的数据量多大的时候看到的?

【在 w*r 的大作中提到】
: 大头,理论和实践上都证明了这是正确的,不要酸溜溜的
相关主题
DBA会因为云计算,NoSql DB 而日渐下坡,前途昏暗吗?发不和谐文章--Oracle is #1 in the RDBMS Sector for 2011 (ZZ)
新手请教:Java or .NET, DBA? (转载)Database Administrator needed (转载)
discussion: how to prepare test data?[提供内推] Senior DBA (SFO市区, MySQL)
进入Database版参与讨论
w*r
发帖数: 2421
21
the tables I deal with on daily basis regularily above 800M rows.
36 of them are 10s of billions.
3 of them are above 100B

【在 L*******r 的大作中提到】
: 你在实践中看见区别了?你的数据量多大的时候看到的?
L*******r
发帖数: 8961
22
是够大的。这么大的Table,应该很特殊了吧?干什么用的?

【在 w*r 的大作中提到】
: the tables I deal with on daily basis regularily above 800M rows.
: 36 of them are 10s of billions.
: 3 of them are above 100B

y****w
发帖数: 3747
23
DBAs argue to have familyid and familymemberid in varchar format because
there it does not make any sense to do calculation on familyid and
familymemberid
1 (共1页)
进入Database版参与讨论
相关主题
Database Administrator needed (转载)About INSERT IGNORE
[提供内推] Senior DBA (SFO市区, MySQL)用SSIS传table从oracle到mssql,遇到一个奇怪的问题
[提供内推] Senior DBA SFO, mysql, cassandra, redis, hadooperror file或者exception file
SQL SERVER背景, 考哪个认证好? sql server 面试题 (5)
请教2个sql query 问题MySQL DBA 的前途
Urgent help needed, please请问最近几年比较火的数据库方面的topic是什么?
多对多relation?dba interview 都问些啥
how to get all numerical data?DBA会因为云计算,NoSql DB 而日渐下坡,前途昏暗吗?
相关话题的讨论汇总
话题: familyid话题: varchar话题: numeric话题: do