diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php
index e033bd5..59439c7 100644
--- a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php
+++ b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php
@@ -265,6 +265,13 @@ protected function createKeysSql($spec) {
     if (!empty($spec['primary key'])) {
       $keys[] = 'PRIMARY KEY (' . $this->createKeysSqlHelper($spec['primary key']) . ')';
     }
+    if (!empty($spec['foreign keys'])) {
+      foreach ($spec['foreign keys'] as $key => $fields) {
+        if (!empty($fields['create'])) {
+          $keys[] = 'CONSTRAINT `' . $key . '` FOREIGN KEY (`' . implode('`, `', array_keys($fields['columns'])) . '`) REFERENCES {' . $fields['table'] . '} (`' . implode('`, `', $fields['columns']) . '`) ON UPDATE CASCADE ON DELETE CASCADE';
+        }
+      }
+    }
     if (!empty($spec['unique keys'])) {
       foreach ($spec['unique keys'] as $key => $fields) {
         $keys[] = 'UNIQUE KEY `' . $key . '` (' . $this->createKeysSqlHelper($fields) . ')';
@@ -430,6 +437,26 @@ public function dropPrimaryKey($table) {
     return TRUE;
   }
 
+  public function addForeignKey($table, $name, $fields) {
+    if (!$this->tableExists($table)) {
+      throw new SchemaObjectDoesNotExistException(t("Cannot add foreign key @name to table @table: table doesn't exist.", array('@table' => $table, '@name' => $name)));
+    }
+    if ($this->indexExists($table, $name)) {
+      throw new SchemaObjectExistsException(t("Cannot add foreign key @name to table @table: foreign key already exists.", array('@table' => $table, '@name' => $name)));
+    }
+
+    $this->connection->query('ALTER TABLE {' . $table . '} ADD CONSTRAINT `' . $name . '` FOREIGN KEY (`' . implode('`, `', array_keys($fields['columns'])) . '`) REFERENCES {' . $fields['table'] . '} (`' . implode('`, `', $fields['columns']) . '`) ON UPDATE CASCADE ON DELETE CASCADE');
+  }
+
+  public function dropForeignKey($table, $name) {
+    if (!$this->indexExists($table, $name)) {
+      return FALSE;
+    }
+
+    $this->connection->query('ALTER TABLE {' . $table . '} DROP FOREIGN KEY `' . $name . '`');
+    return TRUE;
+  }
+
   public function addUniqueKey($table, $name, $fields) {
     if (!$this->tableExists($table)) {
       throw new SchemaObjectDoesNotExistException(t("Cannot add unique key @name to table @table: table doesn't exist.", array('@table' => $table, '@name' => $name)));
diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
index 63349ad..26ed67c 100644
--- a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
+++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
@@ -132,6 +132,11 @@ protected function createTableSql($name, $table) {
     if (isset($table['primary key']) && is_array($table['primary key'])) {
       $sql_keys[] = 'PRIMARY KEY (' . $this->createPrimaryKeySql($table['primary key']) . ')';
     }
+    if (isset($table['foreign keys']) && is_array($table['foreign keys']) && !empty($table['foreign keys']['create'])) {
+      foreach ($table['foreign keys'] as $key_name => $key) {
+        $sql_keys[] = 'CONSTRAINT "' . $this->prefixNonTable($name, $key_name, 'fk') . '" FOREIGN KEY (' . implode(', ', array_keys($key['columns'])) . ') REFERENCES {' . $key['table'] . '} (' . implode(', ', $key['columns']) . ') ON UPDATE CASCADE ON DELETE CASCADE';
+      }
+    }
     if (isset($table['unique keys']) && is_array($table['unique keys'])) {
       foreach ($table['unique keys'] as $key_name => $key) {
         $sql_keys[] = 'CONSTRAINT ' . $this->prefixNonTable($name, $key_name, 'key') . ' UNIQUE (' . implode(', ', $key) . ')';
@@ -489,6 +494,26 @@ public function dropPrimaryKey($table) {
     return TRUE;
   }
 
+  function addForeignKey($table, $name, $fields) {
+    if (!$this->tableExists($table)) {
+      throw new SchemaObjectDoesNotExistException(t("Cannot add foreign key @name to table @table: table doesn't exist.", array('@table' => $table, '@name' => $name)));
+    }
+    if ($this->constraintExists($table, $name . '_fk')) {
+      throw new SchemaObjectExistsException(t("Cannot add foreign key @name to table @table: foreign key already exists.", array('@table' => $table, '@name' => $name)));
+    }
+
+    $this->connection->query('ALTER TABLE {' . $table . '} ADD CONSTRAINT "' . $this->prefixNonTable($table, $name, 'fk') . '" FOREIGN KEY (' . implode(', ', array_keys($fields['columns'])) . ') REFERENCES {' . $fields['table'] . '} (' . implode(', ', $fields['columns']) . ') ON UPDATE CASCADE ON DELETE CASCADE');
+  }
+
+  public function dropForeignKey($table, $name) {
+    if (!$this->constraintExists($table, $name . '_fk')) {
+      return FALSE;
+    }
+
+    $this->connection->query('ALTER TABLE {' . $table . '} DROP CONSTRAINT "' . $this->prefixNonTable($table, $name, 'fk') . '"');
+    return TRUE;
+  }
+
   function addUniqueKey($table, $name, $fields) {
     if (!$this->tableExists($table)) {
       throw new SchemaObjectDoesNotExistException(t("Cannot add unique key @name to table @table: table doesn't exist.", array('@table' => $table, '@name' => $name)));
@@ -641,6 +666,13 @@ protected function _createKeys($table, $new_keys) {
     if (isset($new_keys['primary key'])) {
       $this->addPrimaryKey($table, $new_keys['primary key']);
     }
+    if (isset($new_keys['foreign keys'])) {
+      foreach ($new_keys['foreign keys'] as $name => $fields) {
+        if (!empty($fields['create'])) {
+          $this->addForeignKey($table, $name, $fields);
+        }
+      }
+    }
     if (isset($new_keys['unique keys'])) {
       foreach ($new_keys['unique keys'] as $name => $fields) {
         $this->addUniqueKey($table, $name, $fields);
