This question branches out of this question, What are the differences between algorithms using data structures and algorithms using databases?.
The General Question
Should a database table(s) structure match its intended data structure(s) in the logic?
Some Context
The simplest example (and it may be oversimplified) of what I am thinking about is a database table whose columns match the properties of a linked list data structure. So the properties I think of for a linked list are the following:
Linked List
- Node identity.
- Item/Content in node.
- Next node.
In regards to the general question, the database table columns that I think of getting mapped are the following:
Linked List > Database Table
- Node Identity > Primary Key Column(s).
- Item/Content in node > Column(s) containing data that is to be persisted.
- Next node > Column containing a reference to the record that is to follow it in the same table.
An application I can think of that represents the above is to say, keep track of a trail of points you have been to on a map. So I can imagine saving the coordinates of point A then putting in the mapped Next node column, the coordinates of point B. Letting my imagination run a little further, then retrieve this data and load it into a linked list, use its properties to do the traversal, and draw these points on a map again at a later point in time.
Questions
- I can see how creating a mapping like this simplifies thinking about the data, but I also feel it restricts you to thinking about the data in only this way. How conforming do you make your database tables to data structure(s), if at all?
- Should databases be viewed as realms of raw data that are to be shaped and molded (translated) to data structures selected dependent on the program's purpose?
I restate what I said in the last post. I know answers without a specific context are difficult. Food-for-thought, advice, or discussion points are mainly what I'm looking for and would be most appreciated! I did try to give a more specific context in this post.