8

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?

7
  • Overhead vs Ensuring Data Validity - unforutnately a bit subjective, but will be interesting to see what answers you get. I would of thought its a more of a CW than a question though. Commented Jan 19, 2012 at 14:57
  • 2
    Many "large sites on the web" do not use relational databases at all. Commented Jan 19, 2012 at 14:57
  • @Magnus - Umm, yeah they do. Not all, probably not for HTML content, but for transactional data they often do. Commented Jan 19, 2012 at 14:59
  • 1
    Please don't close this! I really want to hear the answer. Commented Jan 19, 2012 at 14:59
  • 1
    I guess it depends on what do you mean with "large sites". Commented Jan 19, 2012 at 15:00

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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.

2 Comments

To clarify, my emphasis is on a hypothetical website that has a huge amount of data writing to and reading from a RDBMS. Citigroup would be a "large site" to the extent that these FK overhead costs would actually affect them. Maybe Twitter or Wordpress are better examples.
Twitter should not (and AFAIK does not) use a RDBMS and thus no foreign keys, Wordpress doesn't use foreign keys - exactly my argument: The business logic and legal framework do not require it. Citibank will use them, even if the overhead affects them, but the business logic and legal necessitate it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.