Are foreign keys really necessary in a database design?

前端 未结 24 2322
执笔经年
执笔经年 2020-11-28 18:08

As far as I know, foreign keys (FK) are used to aid the programmer to manipulate data in the correct way. Suppose a programmer is actually doing this in the right manner alr

24条回答
  •  时光取名叫无心
    2020-11-28 18:45

    We don't currently use foreign keys. And for the most part we don't regret it.

    That said - we're likely to start using them a lot more in the near future for several reasons, both of them for similar reasons:

    1. Diagramming. It's so much easier to produce a diagram of a database if there are foreign key relationships correctly used.

    2. Tool support. It's a lot easier to build data models using Visual Studio 2008 that can be used for LINQ to SQL if there are proper foreign key relationships.

    So I guess my point is that we've found that if we're doing a lot of manual SQL work (construct query, run query, blahblahblah) foreign keys aren't necessarily essential. Once you start getting into using tools, though, they become a lot more useful.

提交回复
热议问题