<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.7.2" -->
<rss version="2.0">
    <channel>
        <title>Key[ Search for &quot;&quot;]</title>
        <description></description>
        <link>http://xataface.com/wiki/index.php?-action=single_record_search&amp;-table=wiki&amp;page_id=%3D83&amp;-cursor=0&amp;-skip=0&amp;-limit=30&amp;-mode=list&amp;--subsearch=</link>
        <lastBuildDate>Tue, 21 May 2013 23:38:46 +0100</lastBuildDate>
        <generator>FeedCreator 1.7.2</generator>
        <item>
            <title>Key</title>
            <link>http://www.xataface.com/wiki/Key</link>
            <description>&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Field&lt;/th&gt;&lt;th&gt;Value&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td valign=&quot;top&quot;&gt;Page name&lt;/td&gt;&lt;td valign=&quot;top&quot;&gt;Key&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign=&quot;top&quot;&gt;Page id&lt;/td&gt;&lt;td valign=&quot;top&quot;&gt;83&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign=&quot;top&quot;&gt;Page title&lt;/td&gt;&lt;td valign=&quot;top&quot;&gt;fields.ini Directive: Key&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign=&quot;top&quot;&gt;Content&lt;/td&gt;&lt;td valign=&quot;top&quot;&gt;&lt;p&gt;The &lt;strong&gt;Key&lt;/strong&gt; directive is used only when the table is a view and you need to explicitly define which columns are part of the primary key.  For example, if we created a view on the books table to only show books in a given year as follows: 
&lt;pre&gt;&lt;code&gt;create view books_2000 as
select * from books where year='2000'&lt;/code&gt;&lt;/pre&gt;

&lt;/p&gt;

&lt;p&gt;And we wanted to use this view as a table in our Xataface application we would need to tell it that the primary key of this view is the book_id field.  So in the fields.ini file we would add:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;[book_id]
    Key=PRI&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Note that this is case sensitive.  key=PRI will not work.&lt;/p&gt;


&lt;h3 id=&quot;toc0&quot;&gt;Compound Primary Keys&lt;/h3&gt;
&lt;p&gt;For primary keys comprising multiple columns we would add this directive for each field in the key.  E.g. if our books_2000 view had 2 fields in the primary key, say author_id and book_index, we would have in the books_2000 fields.ini file: 
&lt;pre&gt;&lt;code&gt;[author_id]
    Key=PRI

[book_index]
    Key=PRI&lt;/code&gt;&lt;/pre&gt;

&lt;/p&gt;

&lt;p&gt;Links: &lt;ul&gt;
    &lt;li&gt; &lt;a href=&quot;http://xataface.com/forum/viewtopic.php?f=4&amp;amp;t=6723&quot; onclick=&quot;window.open(this.href, '_blank'); return false;&quot;&gt;Lookup widget on view with compound primary key&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;/p&gt;

&lt;p&gt;Return to &lt;a href=&quot;/wiki/fields.ini_file&quot;&gt;fields.ini file&lt;/a&gt;&lt;/p&gt;

&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign=&quot;top&quot;&gt;Keywords&lt;/td&gt;&lt;td valign=&quot;top&quot;&gt;Key, Views, MySQL Views, Create View, PRI, Primary Keys&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign=&quot;top&quot;&gt;Language&lt;/td&gt;&lt;td valign=&quot;top&quot;&gt;en&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;</description>
            <author>Key</author>
        </item>
    </channel>
</rss>
