Database – How to design a database that stores large json objects

databasedatabase-design

I'm wondering the best approach to designing a database for storing crossword json data. As the website is at the moment, the frontend view just needs to be passed the whole object to render the crossword:

{
    grid: [15][15], // 2D array of letters
    clues: {
        across: { 
            clue_id: "here's an across clue" 
            ... 
        }, // Arbitrary number of clues
        down: {
            clue_id: "here's a down clue" 
            ... 
        } // Arbitrary number of clues
    }
}

What are the most sensible options when designing the database?

My instinct is to use MySQL or Postgres and just store the json data in a single column:

crossword _id | crossword_data

In the future users might be able to 'favorite' clues. In this case is it better practice to separate out all the grid and clues to different tables?

Crosswords Table [has many clues]
-----------------------------------
| crossword_id   | crossword_grid |
-----------------------------------


Clues Table [has one crossword]
----------------------------------------------------------
| clue_id   | clue_direction | clue_text  | crossword_id |
----------------------------------------------------------

Or would it be better to store the crossword data in a separate NoSql database?

Any direction on the matter would be much appreciated.

Best Answer

What you are doing is a good enough approach. I did something similar with doxdb which is a ID mapped to a blob. My blob is a BSON a binary representation of JSON for optimization then have separate tables that get created on updates of the record.

In a sense that’s how Apple mail does it except instead of BLOBs they used message files and built the database on top of it.

A nosql document database like elasticsearch and mongo can be used as your data store and have a MySQL to provide the tables that you can use to query.

Related Topic