大型系统是否在其数据库中使用外键?

时间:2022-09-20 19:24:15

One of the disadvantages people point to with using foreign keys in a relational database is the overhead of making sure the parent table exists before doing any insert operation. (Example). As your database and operation grows, this effect is amplified. Does anyone know if large sites on the web use them then? If so, how do they get around that extra overhead? If not, as your development team gets bigger, it seems that that could cause a lot of potential bugs/conflicts/miscommunication/orphan-rows.

人们在关系数据库中使用外键指出的缺点之一是在执行任何插入操作之前确保父表存在的开销。 (例)。随着数据库和操作的增长,这种影响会被放大。有谁知道网络上的大型网站是否使用它们呢?如果是这样,他们如何解决额外的开销?如果没有,随着您的开发团队变得更大,似乎可能会导致很多潜在的错误/冲突/错误传达/孤立行。

Any insight?

2 个解决方案

#1


1  

I work for a telecom, yes they do, often the cost of FK is too small compared to severity one major incidents (hours of time lost investigating, patching ...) that can be caused by accidents due to lack of FK checking.

我为电信公司工作,是的,通常FK的成本太小,而严重的一次重大事故(小时的调查,修补......)可能是由于缺乏FK检查导致的事故造成的。

#2


0  

This depends on your definition of "large site": If for example Citigroup online bank is a "large site", I guess they do.

这取决于您对“大型网站”的定义:例如,如果花旗集团网上银行是一个“大型网站”,我猜他们会这样做。

What I mean by this example is, that the use (or not use) of foreign keys, access by stored-procedures-only etc, depends on the requirements of the business logic (and maybe its legal framework) more than on technicalities only.

这个例子的意思是,外键的使用(或不使用),仅存储过程的访问等,取决于业务逻辑(可能是其法律框架)的要求,而不仅仅取决于技术性。

#1


1  

I work for a telecom, yes they do, often the cost of FK is too small compared to severity one major incidents (hours of time lost investigating, patching ...) that can be caused by accidents due to lack of FK checking.

我为电信公司工作,是的,通常FK的成本太小,而严重的一次重大事故(小时的调查,修补......)可能是由于缺乏FK检查导致的事故造成的。

#2


0  

This depends on your definition of "large site": If for example Citigroup online bank is a "large site", I guess they do.

这取决于您对“大型网站”的定义:例如,如果花旗集团网上银行是一个“大型网站”,我猜他们会这样做。

What I mean by this example is, that the use (or not use) of foreign keys, access by stored-procedures-only etc, depends on the requirements of the business logic (and maybe its legal framework) more than on technicalities only.

这个例子的意思是,外键的使用(或不使用),仅存储过程的访问等,取决于业务逻辑(可能是其法律框架)的要求,而不仅仅取决于技术性。