<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://sqlzoo.net/w/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://sqlzoo.net/w/index.php?title=CREATE_TABLE_problems:_Foreign_key_references.&amp;feed=atom&amp;action=history</id>
		<title>CREATE TABLE problems: Foreign key references. - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://sqlzoo.net/w/index.php?title=CREATE_TABLE_problems:_Foreign_key_references.&amp;feed=atom&amp;action=history"/>
		<link rel="alternate" type="text/html" href="http://sqlzoo.net/w/index.php?title=CREATE_TABLE_problems:_Foreign_key_references.&amp;action=history"/>
		<updated>2013-05-21T12:39:10Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.20.4</generator>

	<entry>
		<id>http://sqlzoo.net/w/index.php?title=CREATE_TABLE_problems:_Foreign_key_references.&amp;diff=1439&amp;oldid=prev</id>
		<title>Marek: Created page with &quot;CREATE TABLE problems: Foreign key references. &lt;div class='ht'&gt; &lt;div class=params&gt;schema:scott&lt;/div&gt; &lt;div&gt; A foreign key should refer to a ''candidate key'' in some table. Thi...&quot;</title>
		<link rel="alternate" type="text/html" href="http://sqlzoo.net/w/index.php?title=CREATE_TABLE_problems:_Foreign_key_references.&amp;diff=1439&amp;oldid=prev"/>
				<updated>2012-07-17T09:53:45Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;CREATE TABLE problems: Foreign key references. &amp;lt;div class=&amp;#039;ht&amp;#039;&amp;gt; &amp;lt;div class=params&amp;gt;schema:scott&amp;lt;/div&amp;gt; &amp;lt;div&amp;gt; A foreign key should refer to a &amp;#039;&amp;#039;candidate key&amp;#039;&amp;#039; in some table. Thi...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;CREATE TABLE problems: Foreign key references.&lt;br /&gt;
&amp;lt;div class='ht'&amp;gt;&lt;br /&gt;
&amp;lt;div class=params&amp;gt;schema:scott&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
A foreign key should refer to a ''candidate key'' in some table. This is usually the primary key but may be a field (or list of fields) specified as UNIQUE.&lt;br /&gt;
&lt;br /&gt;
You must have REFERENCE permission on the table being referenced.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=sql class='tidy'&amp;gt;DROP TABLE t_stupid&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=sql class='setup'&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang='sql' class='def'&amp;gt;CREATE TABLE t_stupid (a INTEGER&lt;br /&gt;
   ,FOREIGN KEY(a)&lt;br /&gt;
       REFERENCES cia(population))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;ecomm e-mysql&amp;quot; style=&amp;quot;display: none&amp;quot;&amp;gt;It's an old tart - it will let you reference any old rubbish.&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;ecomm e-sqlite&amp;quot; style=&amp;quot;display: none&amp;quot;&amp;gt;Foreign key references are ignored. This problem does not arise.&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
{{CREATE and DROP ref}}&lt;/div&gt;</summary>
		<author><name>Marek</name></author>	</entry>

	</feed>