diff --git a/includes/common.inc b/includes/common.inc
index eb68850..7563942 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -1974,7 +1974,7 @@ function _format_date_callback(array $matches = NULL, $new_langcode = NULL) {
 /**
  * Format a username.
  *
- * By default, the passed-in object's 'name' property is used if it exists, or
+ * By default, the passed in object's 'name' property is used if it exists, or
  * else, the site-defined value for the 'anonymous' variable. However, a module
  * may override this by implementing hook_username_alter(&$name, $account).
  *
@@ -5229,7 +5229,7 @@ function drupal_set_page_content($content = NULL) {
  *     browsers, '#browsers' can be set to array('IE' => 'gte IE 8').
  *
  * @return
- *   The passed-in element with markup for conditional comments potentially
+ *   The passed in element with markup for conditional comments potentially
  *   added to '#prefix' and '#suffix'.
  */
 function drupal_pre_render_conditional_comments($elements) {
@@ -5291,7 +5291,7 @@ function drupal_pre_render_conditional_comments($elements) {
  *   - #options: (optional) An array of options to pass to l().
  *
  * @return
- *   The passed-in elements containing a rendered link in '#markup'.
+ *   The passed in elements containing a rendered link in '#markup'.
  */
 function drupal_pre_render_link($element) {
   // By default, link options to pass to l() are normally set in #options.
@@ -5438,7 +5438,7 @@ function drupal_pre_render_links($element) {
  *   A structured array using the #markup key.
  *
  * @return
- *   The passed-in elements, but #markup appended to #children.
+ *   The passed in elements, but #markup appended to #children.
  */
 function drupal_pre_render_markup($elements) {
   $elements['#children'] = $elements['#markup'];
@@ -5902,7 +5902,7 @@ function drupal_render_collect_attached($elements, $return = FALSE) {
  *
  * @return
  *   A renderable array with the following keys and values:
- *   - #query: The passed-in $query.
+ *   - #query: The passed in $query.
  *   - #pre_render: $function with a _pre_render suffix.
  *   - #cache: An associative array prepared for drupal_render_cache_set().
  */
@@ -6599,7 +6599,9 @@ function drupal_install_schema($module) {
   _drupal_schema_initialize($schema, $module, FALSE);
 
   foreach ($schema as $name => $table) {
-    db_create_table($name, $table);
+    Database::getConnection('default', $schema[$name]['database key'])
+      ->schema()
+      ->createTable($name, $table);
   }
 }
 
@@ -6621,9 +6623,10 @@ function drupal_uninstall_schema($module) {
   $schema = drupal_get_schema_unprocessed($module);
   _drupal_schema_initialize($schema, $module, FALSE);
 
-  foreach ($schema as $table) {
-    if (db_table_exists($table['name'])) {
-      db_drop_table($table['name']);
+  foreach ($schema as $name => $table) {
+    $connection = Database::getConnection('default', $schema[$name]['database key']);
+    if ($connection->schema()->tableExists($table['name'])) {
+      $connection->schema()->dropTable($table['name']);
     }
   }
 }
@@ -6688,6 +6691,9 @@ function _drupal_schema_initialize(&$schema, $module, $remove_descriptions = TRU
     if (!isset($table['name'])) {
       $table['name'] = $name;
     }
+    if (!isset($table['database key'])) {
+      $table['database key'] = 'default';
+    }
     if ($remove_descriptions) {
       unset($table['description']);
       foreach ($table['fields'] as &$field) {
@@ -6830,11 +6836,15 @@ function drupal_write_record($table, &$record, $primary_keys = array()) {
         unset($fields[$serial]);
       }
     }
-    $query = db_insert($table, $options)->fields($fields);
+    $query = Database::getConnection('default', $schema['database key'])
+      ->insert($table, $options)
+      ->fields($fields);
     $return = SAVED_NEW;
   }
   else {
-    $query = db_update($table)->fields($fields);
+    $query = Database::getConnection('default', $schema['database key'])
+      ->update($table)
+      ->fields($fields);
     foreach ($primary_keys as $key) {
       $query->condition($key, $object->$key);
     }
diff --git a/includes/database/schema.inc b/includes/database/schema.inc
index de1b2f5..6127808 100644
--- a/includes/database/schema.inc
+++ b/includes/database/schema.inc
@@ -31,6 +31,9 @@ require_once dirname(__FILE__) . '/query.inc';
  *     curly-brackets. For example, the node_revisions table
  *     description field might contain "Stores per-revision title and
  *     body data for each {node}."
+ *   - 'database key': A string containing the key of the database where this
+ *     table is stored. This key is specified in the $databases array in
+ *     settings.php. The default value equals 'default'.
  *   - 'fields': An associative array ('fieldname' => specification)
  *     that describes the table's database columns. The specification
  *     is also an array. The following specification parameters are defined:
