<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Are foreign keys really necessary in a database design?</title>
	<atom:link href="http://www.diovo.com/2008/08/are-foreign-keys-really-necessary-in-a-database-design/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.diovo.com/2008/08/are-foreign-keys-really-necessary-in-a-database-design/</link>
	<description></description>
	<lastBuildDate>Wed, 10 Mar 2010 16:08:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Tejaswi</title>
		<link>http://www.diovo.com/2008/08/are-foreign-keys-really-necessary-in-a-database-design/comment-page-1/#comment-1709</link>
		<dc:creator>Tejaswi</dc:creator>
		<pubDate>Fri, 12 Jun 2009 11:56:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.diovo.com/?p=213#comment-1709</guid>
		<description>This is ossem sight
Please sent me difference between Primery &amp; Secondry keys.</description>
		<content:encoded><![CDATA[<p>This is ossem sight<br />
Please sent me difference between Primery &amp; Secondry keys.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Randomised Ramblings &#187; Advise on Databases, Sleep and Tools</title>
		<link>http://www.diovo.com/2008/08/are-foreign-keys-really-necessary-in-a-database-design/comment-page-1/#comment-1693</link>
		<dc:creator>Randomised Ramblings &#187; Advise on Databases, Sleep and Tools</dc:creator>
		<pubDate>Wed, 03 Jun 2009 06:43:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.diovo.com/?p=213#comment-1693</guid>
		<description>[...] Are foreign keys really necessary in a database design? [...]</description>
		<content:encoded><![CDATA[<p>[...] Are foreign keys really necessary in a database design? [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mahesh Lavannis</title>
		<link>http://www.diovo.com/2008/08/are-foreign-keys-really-necessary-in-a-database-design/comment-page-1/#comment-1400</link>
		<dc:creator>Mahesh Lavannis</dc:creator>
		<pubDate>Thu, 12 Feb 2009 17:22:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.diovo.com/?p=213#comment-1400</guid>
		<description>Two things are being confused here:
1. Relationship between two tables
2. How to ensure the relationship

#2 is where the choice of Foreign Key comes in (#1 is an aspect of your data model). You can choose to define/enforce the relationship through your own code, OR you can use Foreign Key. 

Doing it yourself gives you some benefits like optimization/customization and non-benefits like someone less knowledgeable overriding your code. 

Using Foreign Key has the benefit of being automatically enforced/managed by the database. Disadvantage is that it might not be optimized, and can slow down database updates (since each update will be verified by the database).

Conclusion - If your database is constantly updated, maybe it is better to use custom code instead of foreign keys. Otherwise, maybe best to use foreign keys.</description>
		<content:encoded><![CDATA[<p>Two things are being confused here:<br />
1. Relationship between two tables<br />
2. How to ensure the relationship</p>
<p>#2 is where the choice of Foreign Key comes in (#1 is an aspect of your data model). You can choose to define/enforce the relationship through your own code, OR you can use Foreign Key. </p>
<p>Doing it yourself gives you some benefits like optimization/customization and non-benefits like someone less knowledgeable overriding your code. </p>
<p>Using Foreign Key has the benefit of being automatically enforced/managed by the database. Disadvantage is that it might not be optimized, and can slow down database updates (since each update will be verified by the database).</p>
<p>Conclusion &#8211; If your database is constantly updated, maybe it is better to use custom code instead of foreign keys. Otherwise, maybe best to use foreign keys.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: darnpunk</title>
		<link>http://www.diovo.com/2008/08/are-foreign-keys-really-necessary-in-a-database-design/comment-page-1/#comment-1270</link>
		<dc:creator>darnpunk</dc:creator>
		<pubDate>Sat, 31 Jan 2009 12:35:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.diovo.com/?p=213#comment-1270</guid>
		<description>Hi there,

I saw your post at StackOverFlow and replied there but no response yet. Anyway, I understand foreign keys may result in lockings and my question is, will this be a &quot;performance&quot; impact for an online game with high reads/writes?

Cheers,
darnpunk</description>
		<content:encoded><![CDATA[<p>Hi there,</p>
<p>I saw your post at StackOverFlow and replied there but no response yet. Anyway, I understand foreign keys may result in lockings and my question is, will this be a &#8220;performance&#8221; impact for an online game with high reads/writes?</p>
<p>Cheers,<br />
darnpunk</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee Johnson</title>
		<link>http://www.diovo.com/2008/08/are-foreign-keys-really-necessary-in-a-database-design/comment-page-1/#comment-1253</link>
		<dc:creator>Lee Johnson</dc:creator>
		<pubDate>Sun, 25 Jan 2009 18:03:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.diovo.com/?p=213#comment-1253</guid>
		<description>These are all great points.  Here&#039;s what I wonder; why was the latest and greatest, high-performance database engine (Falcon) created without fk support?

I don&#039;t understand it at all!

Thoughts?</description>
		<content:encoded><![CDATA[<p>These are all great points.  Here&#8217;s what I wonder; why was the latest and greatest, high-performance database engine (Falcon) created without fk support?</p>
<p>I don&#8217;t understand it at all!</p>
<p>Thoughts?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Niyaz PK</title>
		<link>http://www.diovo.com/2008/08/are-foreign-keys-really-necessary-in-a-database-design/comment-page-1/#comment-969</link>
		<dc:creator>Niyaz PK</dc:creator>
		<pubDate>Mon, 25 Aug 2008 13:59:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.diovo.com/?p=213#comment-969</guid>
		<description>A different Bob,
True. Thanks for writing.</description>
		<content:encoded><![CDATA[<p>A different Bob,<br />
True. Thanks for writing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: A different Bob</title>
		<link>http://www.diovo.com/2008/08/are-foreign-keys-really-necessary-in-a-database-design/comment-page-1/#comment-968</link>
		<dc:creator>A different Bob</dc:creator>
		<pubDate>Mon, 25 Aug 2008 13:44:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.diovo.com/?p=213#comment-968</guid>
		<description>I design databases on small projects.  I am typically the sole designer for a team of about 15-20 developers and systems typically have 150-300 tables.

Unless I am the only person who is going to write code against a database, I will not design a database without foreign keys (or some equivalent enforcement).  

The reason:
When you design the database (or sections of an existing database) in advance of the application developers use of it, foreign keys give guidance to the developers.  Just in case they don&#039;t completely understand the structure (common), foreign keys kick out errors as they do things incorrectly.  Then they change what they are doing or they come and ask me questions and I explain it to them.

To develop a system without FKs (or some enforcement), every person who develops against the system has to have a perfect understanding of the relationships - way too much to ask.

Two other notes:
1.  ORMs often use the database FK metadata them to create the correct XML that includes relationships.

2.  Even if your developers have perfect understanding of the system - what about the next contract that will attach to the database?  I see problems without FK constraints.</description>
		<content:encoded><![CDATA[<p>I design databases on small projects.  I am typically the sole designer for a team of about 15-20 developers and systems typically have 150-300 tables.</p>
<p>Unless I am the only person who is going to write code against a database, I will not design a database without foreign keys (or some equivalent enforcement).  </p>
<p>The reason:<br />
When you design the database (or sections of an existing database) in advance of the application developers use of it, foreign keys give guidance to the developers.  Just in case they don&#8217;t completely understand the structure (common), foreign keys kick out errors as they do things incorrectly.  Then they change what they are doing or they come and ask me questions and I explain it to them.</p>
<p>To develop a system without FKs (or some enforcement), every person who develops against the system has to have a perfect understanding of the relationships &#8211; way too much to ask.</p>
<p>Two other notes:<br />
1.  ORMs often use the database FK metadata them to create the correct XML that includes relationships.</p>
<p>2.  Even if your developers have perfect understanding of the system &#8211; what about the next contract that will attach to the database?  I see problems without FK constraints.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Niyaz PK</title>
		<link>http://www.diovo.com/2008/08/are-foreign-keys-really-necessary-in-a-database-design/comment-page-1/#comment-966</link>
		<dc:creator>Niyaz PK</dc:creator>
		<pubDate>Mon, 25 Aug 2008 10:07:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.diovo.com/?p=213#comment-966</guid>
		<description>Dhananjay, Antelio, Arthur,
Thanks for reading and taking time to provide detailed opinions.</description>
		<content:encoded><![CDATA[<p>Dhananjay, Antelio, Arthur,<br />
Thanks for reading and taking time to provide detailed opinions.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: web design company</title>
		<link>http://www.diovo.com/2008/08/are-foreign-keys-really-necessary-in-a-database-design/comment-page-1/#comment-954</link>
		<dc:creator>web design company</dc:creator>
		<pubDate>Sun, 24 Aug 2008 14:16:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.diovo.com/?p=213#comment-954</guid>
		<description>If you want the RDBMS to handle cascade delete and other referential integrity, yes.</description>
		<content:encoded><![CDATA[<p>If you want the RDBMS to handle cascade delete and other referential integrity, yes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arthur</title>
		<link>http://www.diovo.com/2008/08/are-foreign-keys-really-necessary-in-a-database-design/comment-page-1/#comment-952</link>
		<dc:creator>Arthur</dc:creator>
		<pubDate>Sun, 24 Aug 2008 11:09:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.diovo.com/?p=213#comment-952</guid>
		<description>I still remember the days when I learned database design in school, we first did it theoretically and later on did practical examples with Access and MySQL. We didn&#039;t set up a InnoDB database for MySQL and always used the default MyISAM engine, so that the default installation didn&#039;t have foreign key checks.

There&#039;s basically one thing you need to make sure of when not using foreign key&#039;s: the fk id must be a valid id e.g. it must exist in the database and not point to a non-existing record. It&#039;s also very easy to delete an record where a foreign key points to, so you need to check beforehand if there are any foreign keys that point to the record you want to delete, otherwise there will be a lot of inconsistencies.

I now use InnoDB (when using MySQL) or PostgreSQL most of the time and it definitely helps to ease the development.

Cascading updates/deletes are also a nice thing, but you need make sure you understand the whole impact. Deleting a user record might also delete some entries, which might delete some comments, which in turn deletes some other stuff.

One thing I noticed with MyISAM is that it&#039;s a really fast database engine because it&#039;s pretty feature-less.</description>
		<content:encoded><![CDATA[<p>I still remember the days when I learned database design in school, we first did it theoretically and later on did practical examples with Access and MySQL. We didn&#8217;t set up a InnoDB database for MySQL and always used the default MyISAM engine, so that the default installation didn&#8217;t have foreign key checks.</p>
<p>There&#8217;s basically one thing you need to make sure of when not using foreign key&#8217;s: the fk id must be a valid id e.g. it must exist in the database and not point to a non-existing record. It&#8217;s also very easy to delete an record where a foreign key points to, so you need to check beforehand if there are any foreign keys that point to the record you want to delete, otherwise there will be a lot of inconsistencies.</p>
<p>I now use InnoDB (when using MySQL) or PostgreSQL most of the time and it definitely helps to ease the development.</p>
<p>Cascading updates/deletes are also a nice thing, but you need make sure you understand the whole impact. Deleting a user record might also delete some entries, which might delete some comments, which in turn deletes some other stuff.</p>
<p>One thing I noticed with MyISAM is that it&#8217;s a really fast database engine because it&#8217;s pretty feature-less.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
