title: How to enable Foreign Key constraint in SQLITE with Objective C
body: <p>Today I noticed that Foreign key constraint on my SQLite table does not work. After reading on Stack Overflow, I found out that this should be enabled. So, I was looking for code snippet for doing that. So far, I could only find this:</p>
  
  <pre><code>[self.db executeUpdate:@"PRAGMA foreign_keys=ON"];
  </code></pre>
  
  <p>But this does not seem to work for me, as compiler always complains. I saw people use this line for <code>FMDatabase</code> type (I don't even know what is it).
   So, how do I enable foreign key constraint, if I open database connection like this:</p>
  
  <pre><code>- (void) openDatabase
  {
      const char* databaseFile = [[self pathToDatabaseFile:@"readlater.sql"] UTF8String];
      sqlite3 *connection;
      if (sqlite3_open(databaseFile, &amp;connection) != SQLITE_OK) {
          return;
      }
      self.db = connection;
  }
  </code></pre>
  
  <p>Or should it be done while creating tables?
  Thank you.</p>