I’ve got a database which stores pings from various places in the following format:
| Date | Source | Language | OS | Version | more...
| 2011-10-30 | App1 | en | XP | 1.0 | ...
| 2011-10-30 | App2 | de | 10.7.1 | 1.3 | ...
It works just fine for extracting snapshot information. I would like to be able to store daily summaries generated from the above table so that I can get graphs of how the information changes over time.
Examples:
- Graph showing date against version usage
- Graph showing date against OS version
The problem is that several of the columns in the table above (language, os, version) can have a variable number of values. I’ve not had much of an education in database design and can’t get my head around how to store this information for easy retrieval.
Can anyone make any suggestions?
You can quite easily get those statistics from the current table structure. The SQL keyword
GROUP BYshould be your friend.To get version usage per date you type
(The
ORDER BY Date, Versionis just to get a nice sorted output)If you want to have statistics per each combination of Source and Version you modify the question to
If you want to get OS Version per date you type
If you don’t have huge amounts of data (like several million rows) you won’t have any performance problems with suitable indexes.