<commit_before>var deepCopy = require("./deepCopy"),
    getRequiredFields = require("./getRequiredFields"),
    tableFactory = require("./tableFactory"),
    validateDataType = require("./validateDataType"),
    getInheritanceChain = require("./getInheritanceChain"),
    fullModel;

// builds the relational JSON database
function buildDatabase(graph) {
    "use strict";
    var db = Object.create(null, {}),
        // store a copy of the model
        fullModel = deepCopy(graph);

    // create db tables
    Object.keys(graph).forEach(function(key) {
        if (!graph[key].primary || !graph[key].fields) {
            throw new Error("Graph table " + key + " has no fields or no primary key");
        } else {
            db[key] = tableFactory(key, fullModel, db);
        }
    });

    return Object.freeze(db);
}

module.exports = function(graph) {
    "use strict";
    return buildDatabase(graph);
};<commit_msg>removed unused requires and improved documentation<commit_after>var deepCopy = require("./deepCopy"),
    tableFactory = require("./tableFactory"),
    validateDataType = require("./validateDataType");

/**
 * Makes a copy of the model to avoid future tampering
 * Creates each table in the Graph
 *
 * @param {JSON} graph - JSON schema of the database to build
 * @returns {Object} - Tables from the schema
 */
function buildDatabase(graph) {
    "use strict";
    var db = Object.create(null, {}),
        // store a copy of the model
        fullModel = deepCopy(graph);

    // create db tables
    Object.keys(graph).forEach(function(key) {
        if (!graph[key].primary || !graph[key].fields) {
            throw new Error("Graph table " + key + " has no fields or no primary key");
        } else {
            db[key] = tableFactory(key, fullModel, db);
        }
    });

    return Object.freeze(db);
}

module.exports = function(graph) {
    "use strict";
    return buildDatabase(graph);
};
{'fraction_non_alphanumeric': 0.13405797101449277, 'fraction_numerical': 0.0, 'mean_word_length': 2.9129554655870447, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2841523', 'n_tokens_mistral': 541, 'n_tokens_neox': 535, 'n_words': 155}