4
vane
3y

saving and querying json in relational database

Comments
  • 1
    saving it sometimes is fine. like: when you _have_ hugely varying structures you have to store, and know you _never ever ever ever_ have to query any of the properties; if the data could just as well be stored as BLOB. but other than that? terrible.
  • 1
    Guilty, but that json isn't queried directly,

    -> that grinds my gears <-

    why normalise a chunk of data that doesn't serve a purpose being normalised?
  • 0
    @C0D4 it doesn’t make sense but if you start querying it’s like cancer
  • 1
    Saving serialized documents in a relational database isn't bad per se.

    You can additionally store parts of the document in other columns or tables to make them available to queries.

    The worst case is that your relational database becomes a key-value store supporting SQL...
  • 1
    @vane

    I have it for things like product dimensions as an example.
    Purely presentational and only used to calculate freight, this data has no need to be queries directly, no one's going to search for a 10cm2 box.

    So that data sits on a products record and is extracted as needed as there's only 2 places in the entire checkout that needs to know this, a product detail page and when we calculate freight with it.

    Setting up another table to
    Normalise it is just going to be a waste of a a data set and additional queries that no one needs or wants to bother with.

    There's very limited uses I would have json in a db though.
  • 1
    yeah I understood, I don’t deny that you can just store json inside json data type, on the other side I have to move json columns from postgres to mysql that someone decided to query and that’s pure hell
Add Comment