public inbox for [email protected]
 help / color / mirror / Atom feed
From: Ammar Faizi <[email protected]>
To: Alviro Iskandar Setiawan <[email protected]>
Cc: GNU/Weeb Mailing List <[email protected]>
Subject: Re: [RFC PATCH v1 1/1] db: Create starting DDL for saving transaction
Date: Tue, 28 Jun 2022 14:47:00 +0700	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAOG64qNhqSTFQ8dDBN5whyjEOaXMV3He+vZC4kf_TVBmWvPo5Q@mail.gmail.com>

On 6/28/22 2:31 PM, Alviro Iskandar Setiawan wrote:
> On Tue, Jun 28, 2022 at 2:27 PM Ammar Faizi wrote:
>> Hi Al,
>>
>> On 6/28/22 1:21 PM, Alviro Iskandar Setiawan wrote:
>>> +CREATE TABLE `transactions` (
>>> +  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
>>> +  `trx_id` binary(20) NOT NULL,
>>> +  `parent_trx_id` binary(20) NOT NULL,
>>
>> My worry on this is: you reference a parent transaction ID with the
>> sha1 hash, there is no backup if that gets changed. What about using
>> the sequence ID to reference it?
> 
> That should never change, if it ever gets changed, something has gone
> very wrong.

That's not what I mean.

Yes, if we ever had a corruption, something has gone very wrong. But
my point is: if that gets corrupted, you can't no longer find the
parent ID because the SHA1 is not sequential, but our primary key is.

Plus we will be dealing with transaction, which makes the situation
better because the last transaction will never have a smaller seq ID
than the previous transaction, the PK generation is atomic, so the
increment too.

Also, considering space...

You can save more space using the sequence ID, because it's smaller
than SHA1. You can still get the parent SHA1 by doing a simple lookup
with that foreign key. At the end of the day, we get nothing to lose
using seq ID as a reference. We even save more space.

-- 
Ammar Faizi

  reply	other threads:[~2022-06-28  7:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-28  6:21 [RFC PATCH v1 0/1] GNU/Weeb Financial Transaction Record Design Alviro Iskandar Setiawan
2022-06-28  6:21 ` [RFC PATCH v1 1/1] db: Create starting DDL for saving transaction Alviro Iskandar Setiawan
2022-06-28  7:27   ` Ammar Faizi
2022-06-28  7:31     ` Alviro Iskandar Setiawan
2022-06-28  7:47       ` Ammar Faizi [this message]
2022-06-28  7:49         ` Ammar Faizi
2022-06-28  8:03         ` Alviro Iskandar Setiawan
2022-06-28  8:07           ` Ammar Faizi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox