Sample Header Ad - 728x90

What is the best way to check if a value in a table has changed when writing to a database?

0 votes
1 answer
289 views
Let me provide you with an example. Let's say I have an html_tag with two columns, tag_type and tag_value For example, let's say I have a record with the value "link" under thetag_type field and "https://dba.stackexchange.com " under the tag_value field. Now, how would I approach this for auditing purposes? I want to only INSERT into this table when one of the tag_value fields corresponding to a tag_type has changed, because it would not make sense to add redundant records to this table. Is this a database design problem I'm having, or is there advanced SQL I'm unaware of that would accomplish this? Or, rather, would the Java I am getting these values from initially be the place to handle such a thing? Example of how I would do this in Java (psuedo code): var newTag = extract the tag's value from my webpage; var tag_value = SELECT tag_value from html_tag WHERE tag_type = 'link' if (new_tag != tag_value) then (INSERT INTO html_tag)... Should I handle this at the database level, or java level, like directly above?
Asked by brennvo (91 rep)
Nov 6, 2018, 03:04 PM
Last activity: May 16, 2025, 12:07 AM