Sample Header Ad - 728x90

Best approach for a one-to-many list - how to store/acces some related count info?

0 votes
2 answers
251 views
I have a table with persons, and other with interactions, notes and tasks, all related to person(s). I need to have quick access to: - last interaction date. - number of interactions in the past 1,6, 12 months. - number of notes (Total) - number of tasks All this info are used for sorting highlighting in a list/table. When user select a person, all related info can be requested from DB, question is how to get this data for all persons from db? **Version 1**: Sub-query and add the info for each person in table. Could be intensive when tables grows. **Version 2**: store this info in person table, update them when new info is created/modified. This violates the 'single source of true' principle and could be prone to errors. Any ideas?
Asked by SharpBCD (103 rep)
Mar 20, 2021, 06:53 PM
Last activity: May 24, 2025, 03:04 AM