From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,NO_DNS_FOR_FROM, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from [192.168.88.254] (unknown [125.160.108.65]) by gnuweeb.org (Postfix) with ESMTPSA id 681227FA01; Tue, 28 Jun 2022 07:27:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1656401250; bh=3WEWm9iD6NPGH82JwfDaku4rEo4gQDFnbxe2fhM5dUg=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=U0yb3XOiH9DDPZ9vxpEk8ax1b63L9aoGim8Zwpg3DJD5TeaIOvzvChdR3KohjuG8i JPYUmhf7VGc06rN1izRcLSv12n16SWdy4FhPTvGy3xNNhGTE5ewmwD7VPi4inhO/z3 5cvv/PnZPu7AuSBuSkbji/u2eSATBrm/W3zGa4tM9IBvTAJdhcrnce5o8SmVUXA4p9 I5ZP8w50PeaA0s3y1XSproqNQ7DLI1NySZrx6dHKfzzcSFzk8K2y/+7FGW1f1LXjxP Ajk9bsb6MprxtB73tTSUW87154xhjMV8DsL24RjqMHJQyGAE3X5YjKM9/FrxWjAqwA PiJMB6rr5/lTg== Message-ID: <197e0152-a743-840d-11bc-3dcf1a72acdb@gnuweeb.org> Date: Tue, 28 Jun 2022 14:27:18 +0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [RFC PATCH v1 1/1] db: Create starting DDL for saving transaction Content-Language: en-US To: Alviro Iskandar Setiawan Cc: GNU/Weeb Mailing List References: <20220628062139.262361-1-alviro.iskandar@gnuweeb.org> <20220628062139.262361-2-alviro.iskandar@gnuweeb.org> From: Ammar Faizi In-Reply-To: <20220628062139.262361-2-alviro.iskandar@gnuweeb.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: 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? > + `committer` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL, > + `amount` bigint unsigned NOT NULL, > + `notes` text COLLATE utf8mb4_unicode_520_ci NOT NULL, > + `created_at` datetime NOT NULL, > + PRIMARY KEY (`id`), > + KEY `committer` (`committer`), > + KEY `amount` (`amount`), > + KEY `created_at` (`created_at`), > + KEY `trx_id` (`trx_id`), > + KEY `parent_trx_id` (`parent_trx_id`), As per my comment above, this can be a foreign key to the same table, to the PK id. Yes? No? Comment? -- Ammar Faizi