Re: How to represent a bi-directional list in db?
От | Francisco Olarte |
---|---|
Тема | Re: How to represent a bi-directional list in db? |
Дата | |
Msg-id | CA+bJJbxeEXYMOczyxF5Hv7Bf5byLSO7DcRaEM3aoN5inEBBYHQ@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: How to represent a bi-directional list in db? (Pankaj Jangid <pankaj.jangid@gmail.com>) |
Ответы |
Re: How to represent a bi-directional list in db?
|
Список | pgsql-general |
Pankaj: On Mon, Sep 23, 2019 at 4:07 PM Pankaj Jangid <pankaj.jangid@gmail.com> wrote: ... > My stages are stages of processes. So yes processes are also stored in a > table. I got the idea. I'll add another column in the processes table > which points to the first stage (first_stage_id). And quries > Forward pass: ... > Backward pass: .. > This is assuming I also create a circular list. I can also store > last_stage_id in the process table if we don't want to create circular > list in db. That's exactly the idea. A pointer in C becomes a pair of fields with corresponding value, and it can be traversed in any direction, slowly by table scan or fastly with indexes. In fact a pair of values becomes equivalent to two pointers, as it can be traversed either way ( but the indexing acceleration has to be applied to each direction ). That being said, linked lists are procedural data structures, SQL is declarative, so they are not a great match, that's one of the reasons why they are rarely seen. Things like master-detail have less impedance mismatch. Francisco Olarte.
В списке pgsql-general по дате отправления: