Which is the better option for data storage: JSON files or MySQL database?

I am currently developing a project that utilizes the vis.js JavaScript framework to showcase a visual network of various categories. There are approximately 2000 categories available for selection, each with a substantial amount of associated data.

I am contemplating whether it would be more efficient to store the data for each category in separate JSON files on the server or within a comprehensive MySQL database. Alternatively, I am open to any other suggestions you may have. My primary concerns are optimizing storage space and streamlining data retrieval.

Given that the front-end JavaScript will ultimately need to parse the data as JSON, I am inclined towards the JSON file approach, even though it may seem somewhat unconventional. I am eager to learn about the best practices for handling this type of scenario, even if there are multiple approaches.

Thank you!

Answer ā„–1

The size and loading time of a JSON file, as well as the potential security risks associated with anyone being able to extract all its data, should be taken into consideration when deciding between using a JSON file or a database for storing and accessing information.

Opting for a database allows for serving only requested data asynchronously through protocols like AJAX, potentially leading to better performance due to the use of indexes and reduced bandwidth usage.

Furthermore, databases offer the advantage of server-side functions that can be used to manipulate data before it is served.

In summary, while using a JSON file may be simple and portable, considering a database could be beneficial if you anticipate future growth in your project - even though it may involve added complexity.

Answer ā„–2

Have you considered using a no-SQL database?

Many of these databases are optimized for working with JSON and are relatively simple to understand.

While MongoDB is popular and user-friendly, there are also other options available like Cassandra, Redis, DynamoDB, HBase, and more.

Your choice will ultimately depend on your specific requirements, so I recommend exploring the various options further.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Parse JSON array into Go struct when the array is embedded within the JSON string

Iā€™m a beginner in Go and currently working with a weather API. I have encountered an issue with unmarshalling the JSON data. The problem seems to be related to having an array within the JSON string structure, which is causing difficulties in defining ...

What is the method used by Django to perform a check for the

Can you explain what happens with this query in Django using a MySQL backend? res = People.objects.all().exists() Is the process as follows: cursor.execute('SELECT * FROM people') results = cursor.fetchall() if results: res = True else: ...

Utilizing Python, Flask, and MySql functions smoothly in a local environment, however, encounters issues when transitioning to AWS Elastic Beanstalk

As a newcomer to Python, Flask, and the world of hosting public-facing websites, I am facing some challenges. My Flask/Python application works smoothly on my local Windows environment. However, when attempting to host it on Elastic Beanstalk with a MySQL ...

The method by which JavaScript identifies when a Promise has resolved or rejected

How does JavaScript determine when the state of myPromise has transitioned to "fulfilled" in the code provided below? In other words, what is the process that determines it's time to add the .then() handler to the microqueue for eventual execution? co ...

How can we ensure that pointer events return the same coordinates as touch events when the viewport is zoomed in?

I attempted to utilize pointer events (such as pointerdown) instead of using a combination of touch events (e.g. touchstart) and mouse events (e.g. mousedown) to determine the input event coordinates. var bodyElement = document.body; bodyElement.addEvent ...

Identifying activity on a handheld device

I am currently working on a website and I have noticed that it doesn't work as well on mobile devices as it does on desktop. There are performance issues that need to be addressed. I've seen other websites redirecting users to a different page wh ...

Determine the number of rows in an Ajax-fed datatable (including paginated rows) that have a specific value in a

I am struggling with counting rows in #datatableOne where the 'Status' column has a value of 'Unknown'. I have attempted a couple of solutions, but they are not giving me the desired results. The first solution only counts the rows on ...

The ajax function nestled within a nested forEach loop completes its execution once the inner callback function is triggered

I am encountering a problem with an ajax call that is nested within a forEach loop inside another function. The issue is that the callback of the outer function is being triggered before the inner loop completes, resulting in "staticItemList" not being p ...

After converting my HTML elements to JSX in Next.js, I am experiencing issues with my CSS files not being applied

Hey there, I'm currently working on a website using Next.js. I've converted the HTML elements of a page to JSX elements but for some reason, the CSS of the template isn't showing up. I've double-checked all the paths and even updated th ...

Outputting JSON in Django Rest Framework

I have created a basic JSON API with django-rest-framework and I need to download the 5 collections as a single zipfile that contains the collections saved as JSON files. (My application requires this offline data dump). My idea is to create a view, poss ...

A step-by-step guide on generating a dynamic JSON file with JavaScript

I am in need of generating a JSON structure that follows this specific format: {"content": { "properties": { "area_id": "20", "origin": "3", "axis": "1", "x_start": "00", "x_end": "99", "y_start": "00", ...

Remove every row except for the row containing the highest value

My database contains a table of transactions, and I am looking to delete all transactions (grouped by user_id) except for the one with the highest amount. Here is an example table: +----+---------+--------+ | id | user_id | amount | +----+---------+------ ...

Utilizing AngularJS for Converting Date Formats from JSON and HTML Elements

So I have this controller set up. function TestCtrl($scope) { var contentFromJson = 'Hi! this is <b>Bold</b> and <i>Italic</i>'; var dateFromJson = '/Date(1394526738123)/'; $scope.Date = dateFromJso ...

Appwrite error message: Unable to access properties of undefined (looking for 'endpoint')

I am currently working on a project using Appwrite and I have encountered an issue with SDKs. When I use a client-side SDK to interact with the functions of Appwrite Teams, everything works perfectly like this: import { Client, Teams } from "appwrite& ...

locating the truth value of the data in an array retrieved from MongoDB

When returning from the mongoose find() function, I need to ensure that is_reqestor = true is checked. However, when updating the document, I pass the id which needs to be updated. let filter = { is_reqestor: true } if (!is ...

Finding an encrypted value using Laravel Eloquent ORM: A step-by-step guide

In my Laravel project, I am working with encrypted records using the php-encryption library before storing them in a Mysql database. Currently, when searching for a record based on an encrypted value, I loop through all the records to find a match, but thi ...

Ways to widen the header to fit the entire page?

I'm having trouble stretching my header to fill the entire page. I've tried using margin-left and right, but it's not working as expected. My Header CSS: background: green; height: 70px; width: 100%; display: flex; just ...

How can we convert a mixed-case word into one or more words with initial capital letters?

Is there a way to convert caps and spaces to their normal form? For instance, can the word coreControllerC4a be transformed into Core Controller C4a automatically when a function is triggered? ...

Guide on creating uniform heights and widths for images with varying dimensions utilizing CSS (and percentage values)

Is there a way to ensure that all images maintain the same height and width using CSS percentages, rather than set pixel values? I'm working on displaying images in circles, where most are uniform in size but a few outliers distort the shape. The wide ...

Adjusting the color of a specific part of a text within a string using

I am trying to update the color of specific keywords within a post. For example: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam tempor lacinia urna eget gravida. Quisque magna nulla, fermentum fermentum od #keyword1 #keyword2 #keyword3 ...