On the foreign key page (http://www.sqlite.org/foreignkeys.html) at the very 
end of section 3 is has:

CREATE TABLE artist(
  artistid    INTEGER PRIMARY KEY, 
  artistname  TEXT
);
CREATE TABLE track(
  trackid     INTEGER,
  trackname   TEXT, 
  trackartist INTEGER REFERENCES artist
);
CREATE INDEX trackindex ON track(trackartist);

The block above uses a shorthand form to create the foreign key constraint. 
Attaching a "REFERENCES <parent-table>" clause to a column definition creates a 
foreign key constraint that maps the column to the primary key of 
<parent-table>. Refer to the CREATE TABLE documentation for further details.



In the create table page if you expand column-def, then column-constraint, then 
foreign-key-clause, you can see there's a flow path that skips the column names 
of the parent table. Unfortunately I don't see any explainatory text on the 
page for what that actually signifys, so yeah, it's a little hidden.


-----Original Message-----
From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On 
Behalf Of James K. Lowden
Sent: Tuesday, January 10, 2017 1:14 PM
To: sqlite-users@mailinglists.sqlite.org
Subject: Re: [sqlite] Foreign key error...

On Sun, 08 Jan 2017 05:57:46 -0700
"Keith Medcalf" <kmedc...@dessus.com> wrote:

>  artistid integer references artists

Hmph.  Learn something new every day.  

Where is that abbreviated form documented?  I looked for "references"
on the Create Table page, and didn't find anything about its default
arguments.  

--jkl
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to