Skip to Content
Nov 01, 2019 at 04:52 PM

Nested HDB Sequences


Hey guys, I am pretty new to db sql hdb and stuff. So let's say that in my db I have 3 entities. Contract, Item, Bill. Each Contract has an Item and each Item has a Bill. For this situation, as far as I know, it is recommended to use a sequence in order to generate the id and make sure it won't be a duplicate. My problem is if I should really use that or find another way because with sequence I have only 2 options (for the moment): 1. 1 sequence for Contract. For each contract, 1 sequence to count each Contract's Item and for each Item one sequence to count the Item's Bill. 2. Keep three sequences and every time I add a row, let's say I add an Item, I count how many items area already in the database and start the sequence from that number and increment it, which in my opinion cuts out all the charm of sequence (although I am very new to HDB and SQL and everything) Any suggestion is welcome. Thank you!