理性检查:浮动为主键? [英] Sanity Check: Floats as primary keys?

查看:114
本文介绍了理性检查:浮动为主键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个旧的sql server 2000数据库,将其中的一些信息与我正在构建的新应用程序进行混合。我注意到几个表中的一些主键是浮动,而不是任何类型的int。他们不是外键,都是独一无二的。我不能想到任何人会想要使其唯一的主键ID浮动的任何原因,但我不是任何方式的SQL专家。所以我想我问的是谁设计这个相当广泛的数据库知道我不知道的东西?

I'm working with an old sql server 2000 database, mixing some of it's information with a new app I'm building. I noticed some of the primary keys in several of the tables are floats rather than any type of ints. They aren't foreign keys and are all unique. I can't think of any reason that anyone would want to make their unique primary key IDs floats, but I'm not a SQL expert by any means. So I guess what I'm asking is does whoever designed this fairly extensive database know something I don't?

推荐答案

m目前正在使用一个相当大的会计软件包,其中每个350多个表具有FLOAT的主键(53)。所有实际值都是整数,系统会严格检查它们是否确实是(有特殊功能可以执行所有增量工作)。

I'm currently working with a rather big accountant package where EACH of 350+ tables has a primary key of FLOAT(53). All actual values are integers and the system strictly checks that they indeed are (there are special functions that do all the incrementing work).

我在这个设计中想到了我可以理解为什么选择它并给它一些积分。
一方面,系统足够大,可以在一些表中记录十亿条记录。另一方面,这些主键必须易于从外部应用程序(如Excel或VB6)中读取,在这种情况下,您不希望使其成为BIGINT。

I did wonder at this design, yet I can understand why it was chosen and give it some credits. On the one hand, the system is big enough to have billion records in some tables. On the other hand, those primary keys must be easily readable from external applications like Excel or VB6, in which case you don't really want to make them BIGINT.

因此,float是罚款。

Hence, float is fine.

这篇关于理性检查:浮动为主键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆