I have a table which need to persist some user actions in sequence. I can either save it by using a self reference table which will be like a linked list or not using the self reference at all and just use the times tamp to keep the sequence.
This table has reference to other tables such as user and files associated with an action.
The operations will need support CRUD. The frequency of operations are in this order: Retrieve > Insert > Update > Delete
What is your design preference and why?
Thanks!
i would avoid “linked lists” like the plague. about the only thing they are good for is retrieving the “next” item. the problem is that every extra “hop” requires a join, so if you want to parameterise over that (eg to provide a function that retrieves
Nitems following a given item) then you need one of (1) machine-generated joins (2) multiple selects (3) SQL that’s unlikely to be portable and/or supported by your ORM.this is the same problem that makes trees notoriously nasty in sql. it’s “fixed” by recursive joins, but that’s (3) above (maybe i am old-fashioned and someone will say that these are well supported now – if so i guess i will learn…).