I have a table with billions of rows in SQL Server. I want to ensure that the data is read-only (immutable) and always will not changed after being inserted into the database.
My current thought is to use SHA3 hash algorithm to make a hash chain.
HASH(current_row) = HASH(HASH(previous_row) + current_row) # as the hash content of the current row
The solution above has the following shortcomings:
It may take too long if there are billions of rows as every record hash is related to the hash of the previous record.
It does not allow compute in parallel.
Considering the performance, what is the most practical way to make sure data integrity?