diff --git a/.gitignore b/.gitignore
index 5c8d0e266fe94b21afb9c46267f1b0a94661e5fd..04ffe2e890226a8a275c027be5386de8679333c0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
 node_modules
 .parcel-cache
 build
+.vscode
diff --git a/datasets/datasets.php b/datasets/datasets.php
index 653951b1cd248662dc96b68d3674f91de1721337..70502aa22ad600eeb165af9faa4f1051fbb86ee1 100644
--- a/datasets/datasets.php
+++ b/datasets/datasets.php
@@ -1,43 +1,50 @@
 <?php
+require_once(__DIR__ . "/ks-datasets-database.php");
 
 $EMPTY_SPACE = '{"links":[],"nodes":[]}';
-$SPACES_DIR = __DIR__."/spaces/";
 
-add_action("wp_ajax_get_space", "kg_get_space"); // Fires only for logged-in-users
-add_action("wp_ajax_nopriv_get_space", 'kg_get_space' ); // Fires for everyone
-function kg_get_space() {
-    $file_path = kg_get_space_file_path($_POST["space"]);
+add_action("wp_ajax_get_space", "ks_get_space"); // Fires only for logged-in-users
+add_action("wp_ajax_nopriv_get_space", 'ks_get_space' ); // Fires for everyone
+function ks_get_space() {
+    $name = ks_escape_space_name($_POST["space"]);
+
+    $space = ks_select_space($name);
 
     // If it doesn't exist, create new empty space
-    if (!file_exists($file_path)) {
-        kg_create_empty_space($file_path);
+    if ($space == NULL) {
+        global $EMPTY_SPACE;
+        ks_insert_space($name, $EMPTY_SPACE);
+        $space = ks_select_space($name);
     }
 
-    $content = file_get_contents($file_path);
-    echo $content;
+    echo $space->graph;
 
     wp_die();
 }
 
-add_action("wp_ajax_list_spaces", "kg_list_spaces"); // Fires only for logged-in-users
-function kg_list_spaces() {
-    $spaces = kg_get_list_of_spaces();
+add_action("wp_ajax_list_spaces", "ks_list_spaces"); // Fires only for logged-in-users
+function ks_list_spaces() {
+    $spaces = array();
+    foreach (ks_select_all_spaces() as $space) {
+        $spaces[] = $space->name;
+    }
+    
     $payload = array("spaces" => $spaces);
-
     echo json_encode($payload);
 
     wp_die();
 }
 
-add_action("wp_ajax_update_space", "kg_update_space"); // Fires only for logged-in-users
+add_action("wp_ajax_update_space", "ks_update_space"); // Fires only for logged-in-users
 //add_action("wp_ajax_nopriv_update_space", 'update_space' ); // Fires for everyone
-function kg_update_space() {
+function ks_update_space() {
     // Check user capabilities
     if (current_user_can("edit_posts")) {
         // Use json encoding.
         $graph = stripslashes($_POST["graph"]);
+        $name = ks_escape_space_name($_POST["space"]);
 
-        kg_store_new_graph($graph, $_POST["space"]);
+        ks_insert_or_update_graph($name, $graph);
 
         wp_die();
     } else {
@@ -45,62 +52,10 @@ function kg_update_space() {
     }
 }
 
-function kg_store_new_graph($graph, $space_id) {
-    $file_path = kg_get_space_file_path($space_id);
-    $result = file_put_contents($file_path, $graph);
-
-    //echo print_r($_POST);
-    echo "Saved file at ";
-    echo $file_path;
-    echo " ";
-    echo $result;
-}
-
-function kg_get_space_file_path($space_id) {
+function ks_escape_space_name($space_name) {
     // Cleaning up the space id
-    $space_id = str_replace("/", "-", $space_id);
-    $space_id = str_replace("\\", "-", $space_id);
-    $space_id = str_replace(".", "-", $space_id);
-
-    global $SPACES_DIR;
-    return $SPACES_DIR.$space_id.".json";
-}
-
-function kg_get_list_of_spaces() {
-    global $SPACES_DIR;
-    $all_files = scandir($SPACES_DIR);
-
-    if ($all_files == false) {
-        return [];
-    }
-
-    $spaces = [];
-
-    foreach ($all_files as $file) {
-        if (endsWith($file, ".json")) {
-            $spaces[] = substr($file, 0, -strlen(".json"));
-        }
-    }
-
-    return $spaces;
-}
-
-function kg_create_empty_space($file_path) {
-    // Don't do anything, if it exists
-    if (file_exists($file_path)) {
-        return;
-    }
-
-    // Write empty space to file
-    global $EMPTY_SPACE;
-    file_put_contents($file_path, $EMPTY_SPACE);
-}
-
-function endsWith( $haystack, $needle ) {
-    # Source: https://stackoverflow.com/a/834355/7376120
-    $length = strlen( $needle );
-    if( !$length ) {
-        return true;
-    }
-    return substr( $haystack, -$length ) === $needle;
+    $space_name = str_replace("/", "-", $space_name);
+    $space_name = str_replace("\\", "-", $space_name);
+    $space_name = str_replace(".", "-", $space_name);
+    return $space_name;
 }
diff --git a/datasets/ks-datasets-database.php b/datasets/ks-datasets-database.php
new file mode 100644
index 0000000000000000000000000000000000000000..0a526beb88f24369b965e014587736ebcc2f3e16
--- /dev/null
+++ b/datasets/ks-datasets-database.php
@@ -0,0 +1,72 @@
+<?php
+require_once(__DIR__ . "/../knowledge-space-database.php");
+
+function ks_insert_or_update_graph($name, $graph)
+{
+    // Delete old graph and insert new
+    global $SPACES_TABLE;
+    global $wpdb;
+    $wpdb->delete($SPACES_TABLE, array("name" => $name), array("%s"));
+
+    return ks_insert_space($name, $graph);
+}
+
+function ks_select_all_spaces()
+{
+    global $SPACES_TABLE;
+    return ks_select("SELECT * FROM $SPACES_TABLE");
+}
+
+function ks_select_space($space_name)
+{
+    global $SPACES_TABLE;
+    return ks_select_single("SELECT * FROM $SPACES_TABLE WHERE name = %s", $space_name);
+}
+
+function ks_insert_space($name = null, $graph = "")
+{
+    // If no name given, set default name
+    if ($name == null) {
+        // Adding current time to make it somewhat unique
+        $now = new DateTime();
+        $name = "New space - " . $now->format('Y-m-d H:i:s');
+    }
+
+    $data = array(
+        "name" => $name,
+        "graph" => $graph
+    );
+    $format = array("%s", "%s");
+
+    global $SPACES_TABLE;
+    global $wpdb;
+    $wpdb->insert($SPACES_TABLE, $data, $format);
+
+    return $wpdb->insert_id;
+}
+
+function ks_select($query, $parameters = array())
+{
+    global $wpdb;
+    $sql = $wpdb->prepare($query, $parameters);
+    return $wpdb->get_results($sql);
+}
+
+function ks_select_single($query, $parameters = array())
+{
+    $result = ks_select($query, $parameters);
+
+    if ($result) {
+        return $result[0];
+    } else {
+        return null;
+    }
+}
+
+function ks_insert($table, $data)
+{
+    global $wpdb;
+    $wpdb->insert($table, $data);
+
+    return $wpdb->insert_id;
+}
diff --git a/editor/editor.php b/editor/editor.php
index d496d1f0caa09783338ec9f1287d9fc85c4216a3..cf25e164112e41f358fbbf4112f7a006dc3a1e13 100644
--- a/editor/editor.php
+++ b/editor/editor.php
@@ -93,6 +93,26 @@
             </br>
             <input type="number" onkeypress="return (event.charCode !=8 && event.charCode ==0 || (event.charCode >= 48 && event.charCode <= 57))" value="5" id="stop-physics-delay" name="stop-physics-delay" class="small-width">
             </input>
+            </br>
+            </br>
+
+
+            <h3>Import Space</h3>
+            <label for="import-space-area">Space JSON</label>
+            </br>
+            <textarea id="import-space-area" name="import-space-area" class="bottom-space">
+            </textarea>
+            </br>
+            <label for="import-space-name-text">Space Name</label>
+            </br>
+            <input type="text" id="import-space-name-text" name="import-space-name-text" class="bottom-space">
+            </input>
+            </br>
+            <button id="import-space-btn" name="import-space-btn" class="bottom-space">Import</button>
+
+            </br>
+            </br>
+
         </div>
     </section>
 </div>
\ No newline at end of file
diff --git a/editor/js/interactions.js b/editor/js/interactions.js
index d24fec2652d2f9940210fa5f13021cf0fe201f6e..f493e1c2e497df96cb09de3a2ae3bfd1c9f71cc6 100644
--- a/editor/js/interactions.js
+++ b/editor/js/interactions.js
@@ -1,6 +1,6 @@
 import jQuery from "jquery";
 import { state } from "./editor";
-import { listAllSpaces } from "../../datasets/datasets";
+import { listAllSpaces, saveGraphJson } from "../../datasets/datasets";
 import { SPACE } from "../../config";
 
 /**
@@ -11,18 +11,62 @@ export function initInteractions() {
         state.clearSelectedItems();
     });
 
-    // Fill space dropdown
+    jQuery("button#import-space-btn").on("click", () =>
+        importSpaceFromInterface()
+    );
+    loadSpacesList();
+}
+
+function loadSpacesList() {
     var selectContainer = jQuery("#space-id-select");
+    selectContainer.empty();
     listAllSpaces().then((spaces) => {
-        spaces.forEach(space => {
+        spaces.forEach((space) => {
             var selectedTxt = "";
             if (space === SPACE) {
                 selectedTxt = "selected ";
             }
 
-            var child = "<option " + selectedTxt + "value=\"" + space + "\">" + space + "</option>"
+            var child =
+                "<option " +
+                selectedTxt +
+                'value="' +
+                space +
+                '">' +
+                space +
+                "</option>";
             selectContainer.append(child);
         });
     });
     selectContainer.val(SPACE);
 }
+
+function importSpaceFromInterface() {
+    var json = undefined;
+    try {
+        console.log(jQuery("#import-space-area").val());
+        json = JSON.parse(jQuery("#import-space-area").val());
+    } catch (e) {
+        console.log(e);
+        alert('"Space JSON" not valid. Check console for details.');
+        return;
+    }
+
+    var spaceName = jQuery("#import-space-name-text").val();
+    if (spaceName.length == 0) {
+        alert('"Space Name" cannot be empty.');
+        return;
+    }
+
+    saveGraphJson(spaceName, json)
+        .then(() => {
+            loadSpacesList();
+            alert("Space imported!");
+        })
+        .catch((ex) => {
+            console.log(ex);
+            alert(
+                "Something went wrong, could not import space. Check console for further details."
+            );
+        });
+}
diff --git a/knowledge-space-database.php b/knowledge-space-database.php
new file mode 100644
index 0000000000000000000000000000000000000000..ee250886ba2beea52c3a93d5b86b07060b3f579c
--- /dev/null
+++ b/knowledge-space-database.php
@@ -0,0 +1,50 @@
+<?php
+
+
+$SPACES_TABLE = ks_get_table_name("spaces");
+
+
+global $ks_db_version;
+$ks_db_version = '0.1';
+
+function ks_get_table_name($table)
+{
+	global $wpdb;
+	return $wpdb->prefix . "ks_" . $table;
+}
+
+register_activation_hook(__FILE__, 'ks_install');
+function ks_install()
+{
+	global $wpdb;
+	global $ks_db_version;
+
+	$installed_ver = get_option("ks_db_version");
+	if ($installed_ver == $ks_db_version) {
+		return;
+	}
+
+	$charset_collate = $wpdb->get_charset_collate();
+	require_once(__DIR__ . '/../../../wp-admin/includes/upgrade.php');
+
+	global $SPACES_TABLE;
+	$sql = "CREATE TABLE $SPACES_TABLE (
+		space_id int(11) NOT NULL AUTO_INCREMENT,
+		name text NOT NULL,
+		graph text NOT NULL,
+		PRIMARY KEY  (space_id)
+	) $charset_collate;";
+	dbDelta($sql);	//! Has some weird restrictions for the SQL Query: https://codex.wordpress.org/Creating_Tables_with_Plugins
+
+	add_option('ks_db_version', $ks_db_version);
+}
+
+// Handling upgrade
+function ks_update_db_check()
+{
+	global $ks_db_version;
+	if (get_site_option('ks_db_version') != $ks_db_version) {
+		ks_install();
+	}
+}
+add_action('plugins_loaded', 'ks_update_db_check');
diff --git a/knowledge-space.php b/knowledge-space.php
index c9fc7b6b148f5f9fa684381f8f00fed5ad57cb50..88353ad3f01fbc0c9a54717886e3f7646c35baa5 100644
--- a/knowledge-space.php
+++ b/knowledge-space.php
@@ -123,6 +123,7 @@ function kg_editor_admin_add_page()
 }
 
 
+require_once(__DIR__ . "/knowledge-space-database.php");
 require_once(__DIR__ . '/datasets/datasets.php');
 
 //add_action('wp_enqueue_scripts', 'kg_load_css');