The General Question
What are the differences between algorithms using data structures and algorithms using databases?
This is a question that has been bugging me for some time, and I have not been able to come up with a convincing answer for it.
Currently, I am working on strengthening my understanding of algorithms that, of course, heavily involve data structures. These are basic structures such as Bag, Queue, Stack, Priority Queue, and Heap.
I also use databases on a daily basis to store the data that has been processed and submitted by the end-user or processed by the program. I retrieve and submit the data through a DAL, which has data structures of its own that are generated based on the tables in the database.
My questions come when I have the option to sort the data using the database to send it back to me ordered in either an ascending/descending fashion or retrieve and load the data into my logic, process this data in a priority queue, and heap sort all of it. Or another one would be to search for records using the database rather than loading a subset of the records and using something like binary search to find the record or records I am interested in.
In my mind, I would try to have as many operations take place on the database-end before sending it over because communication is expensive. This also makes me wonder when do you use algorithms and data structures strictly defined within your own logic rather to process data than that of the database's?
So here are the questions...
- What are the differences between data structures and databases?
- When do we use algorithms that use data structures defined solely within your own logic and not that of the database's?
- @Harvey post: When do the methods in the database become less efficient to use than methods in your own logic?
- @mirculixx post: What makes a method efficient?
- @Harvey post: How is processing data with data structures faster than doing it in the database?
- @Grant post: The databases I normally work with are relational, and these questions are coming out of working with them. However, I do think these questions are applicable to any persistence framework (when I say framework, I mean it in the most general sense).
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!