Versioning rows in a table The 2019 Stack Overflow Developer Survey Results Are In ...

How to make Illustrator type tool selection automatically adapt with text length

How did passengers keep warm on sail ships?

How to substitute curly brackets with round brackets in a grid of list

Why are Marketing Cloud timestamps not stored in the same timezone as Sales Cloud?

Circular reasoning in L'Hopital's rule

Can the Right Ascension and Argument of Perigee of a spacecraft's orbit keep varying by themselves with time?

how can a perfect fourth interval be considered either consonant or dissonant?

Can a flute soloist sit?

What happens to a Warlock's expended Spell Slots when they gain a Level?

Deal with toxic manager when you can't quit

Can we generate random numbers using irrational numbers like π and e?

Why doesn't shell automatically fix "useless use of cat"?

Word for: a synonym with a positive connotation?

Student Loan from years ago pops up and is taking my salary

TDS update packages don't remove unneeded items

How do you keep chess fun when your opponent constantly beats you?

Button changing its text & action. Good or terrible?

Match Roman Numerals

Why doesn't a hydraulic lever violate conservation of energy?

Was credit for the black hole image misappropriated?

Accepted by European university, rejected by all American ones I applied to? Possible reasons?

Word to describe a time interval

What do I do when my TA workload is more than expected?

Why can't devices on different VLANs, but on the same subnet, communicate?



Versioning rows in a table



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Versioning a dataset in an RDBMS using initials and deltas (xpost from SO)How can I design a table for quick versioning of textual data?Record versioning and promotionHow do I add versioning to this CMS I'm designing?Building a branched versioning model for relational databasesCouchDB and document versioningImplementing versioning system with MySQLVersioning data in a databaseDesign database with versioning and without redundant informationTrack child records versioning and query performance





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















So I have this concept in my head of "immutable" records, which I am sure is not novel, but can't seem to find the right google keywords.



Basically, historical row values need to be preserved as 'obsolete', but remain referencable as FKs from older records. These types of modifications are infrequent. I'm using MySQL, which limits things a bit. The four approaches I see are:



Naive




  • PK is an auto-generated ID

  • obsolete_stamp is a timestamp indicating that the row values are
    obsolete


Drawback: historical data is preserved, but there is no way to track history of changes



Better:




  • PK same as above

  • old_id is the id of the row that this row modifies (if exists)

  • obsolete_stamp (null if row data is current)


consequence: new rows are modifications of old rows, but the new rows have to update the old_id (if there is one)



audit:




  • an on update trigger creates a new row in an audit table


drawback: queries will need to check audit table for obsoleted rows



compound key:




  • id + obsolete_stamp


drawback: id can't be generated anew, only if the row is 'novel' (no history); not clear how to do that automatically.



I'm one of those full-stack developers, so I know just enough about everything to be dangerous.









share































    0















    So I have this concept in my head of "immutable" records, which I am sure is not novel, but can't seem to find the right google keywords.



    Basically, historical row values need to be preserved as 'obsolete', but remain referencable as FKs from older records. These types of modifications are infrequent. I'm using MySQL, which limits things a bit. The four approaches I see are:



    Naive




    • PK is an auto-generated ID

    • obsolete_stamp is a timestamp indicating that the row values are
      obsolete


    Drawback: historical data is preserved, but there is no way to track history of changes



    Better:




    • PK same as above

    • old_id is the id of the row that this row modifies (if exists)

    • obsolete_stamp (null if row data is current)


    consequence: new rows are modifications of old rows, but the new rows have to update the old_id (if there is one)



    audit:




    • an on update trigger creates a new row in an audit table


    drawback: queries will need to check audit table for obsoleted rows



    compound key:




    • id + obsolete_stamp


    drawback: id can't be generated anew, only if the row is 'novel' (no history); not clear how to do that automatically.



    I'm one of those full-stack developers, so I know just enough about everything to be dangerous.









    share



























      0












      0








      0








      So I have this concept in my head of "immutable" records, which I am sure is not novel, but can't seem to find the right google keywords.



      Basically, historical row values need to be preserved as 'obsolete', but remain referencable as FKs from older records. These types of modifications are infrequent. I'm using MySQL, which limits things a bit. The four approaches I see are:



      Naive




      • PK is an auto-generated ID

      • obsolete_stamp is a timestamp indicating that the row values are
        obsolete


      Drawback: historical data is preserved, but there is no way to track history of changes



      Better:




      • PK same as above

      • old_id is the id of the row that this row modifies (if exists)

      • obsolete_stamp (null if row data is current)


      consequence: new rows are modifications of old rows, but the new rows have to update the old_id (if there is one)



      audit:




      • an on update trigger creates a new row in an audit table


      drawback: queries will need to check audit table for obsoleted rows



      compound key:




      • id + obsolete_stamp


      drawback: id can't be generated anew, only if the row is 'novel' (no history); not clear how to do that automatically.



      I'm one of those full-stack developers, so I know just enough about everything to be dangerous.









      share
















      So I have this concept in my head of "immutable" records, which I am sure is not novel, but can't seem to find the right google keywords.



      Basically, historical row values need to be preserved as 'obsolete', but remain referencable as FKs from older records. These types of modifications are infrequent. I'm using MySQL, which limits things a bit. The four approaches I see are:



      Naive




      • PK is an auto-generated ID

      • obsolete_stamp is a timestamp indicating that the row values are
        obsolete


      Drawback: historical data is preserved, but there is no way to track history of changes



      Better:




      • PK same as above

      • old_id is the id of the row that this row modifies (if exists)

      • obsolete_stamp (null if row data is current)


      consequence: new rows are modifications of old rows, but the new rows have to update the old_id (if there is one)



      audit:




      • an on update trigger creates a new row in an audit table


      drawback: queries will need to check audit table for obsoleted rows



      compound key:




      • id + obsolete_stamp


      drawback: id can't be generated anew, only if the row is 'novel' (no history); not clear how to do that automatically.



      I'm one of those full-stack developers, so I know just enough about everything to be dangerous.







      mysql database-design





      share














      share












      share



      share








      edited 1 min ago









      Mr.Brownstone

      9,89732343




      9,89732343










      asked 9 mins ago









      Jeff LoweryJeff Lowery

      1011




      1011






















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "182"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f234701%2fversioning-rows-in-a-table%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Database Administrators Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f234701%2fversioning-rows-in-a-table%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Parapolítica Índice Antecedentes El escándalo Proceso judicial Consecuencias Véase...

          How to remove border from elements in the last row?Targeting flex items on the last rowHow to vertically wrap...

          Tecnologías entrañables Índice Antecedentes Desarrollo Tecnologías Entrañables en la...