FOREIGN KEY Constraint Failed: SQlite3 I have two tables, created as below,

sqlite&gt; CREATE TABLE Artists(
   ...&gt; ArtistId INTEGER PRIMARY KEY,
   ...&gt; ArtistName TEXT NOT NULL
   ...&gt; );
sqlite&gt; CREATE TABLE Albums(
   ...&gt; AlbumId INTEGER PRIMARY KEY,
   ...&gt; AlbumName TEXT NOT NULL,
   ...&gt; Year TEXT NOT NULL,
   ...&gt; ArtistId INTEGER NOT NULL,
   ...&gt; FOREIGN KEY(ArtistId) REFERENCES Artists(ArtistId)
   ...&gt; );


.table returns the following,

sqlite&gt; .table
Albums   Artists


foreign key pragma is set to ON

sqlite&gt; PRAGMA foreign_keys;
1


However, When I try to insert data as below results in FOREIGN KEY constraint failed.

sqlite&gt; INSERT INTO Albums VALUES (NULL, 'Killers', '1981', 7);
Error: FOREIGN KEY constraint failed
sqlite&gt;


I am a database learner. Could someone point out what is that I am doing wrong?
You try to insert Albums.ArtistId value (7) which is absent in Artisis.ArtistId values list now. So insertion fails. 

You cannot insert album of &lt;unknown&gt;, FK claims this is impossible, and server prevents this.

Insert artist with ArtistId=7 first, then insert his albums.