title: Why are foreign keys more used in theory than in practice?
body: <p>When you study relational theory foreign keys are, of course, mandatory. But in practice, in every place I worked, table products and joins are always done by specifying the keys explicitly in the query, instead of relying on foreign keys in the DBMS.  </p>
  
  <p>This way, you could of course join two tables by fields that are not meant to be foreign keys, having unexpected results.  </p>
  
  <p>Why do you think that is? Shouldn't DBMSs enforce that Joins and Products be made only by foreign keys?</p>
  
  <p>EDIT: Thanks for all the answers. It's clear to me now that the main reason for FKs is reference integrity. But if you design a DB, all relationships in the model (I.E. arrows in the ERD) become Foreign keys, at least in theory, whether or not you define them as such in your DBMS, they're semantically FKs. I can't imagine the need to join tables by fields that aren't FKs. <strong>Can someone give an example that makes sense?</strong></p>
  
  <p>PS: I'm aware about the fact that N:M relationships become separate tables and not foreign keys, just omitted it for simplicity's sake.</p>