On Mon, Feb 16, 2009 at 3:45 PM, Mike Cook <m...@epubbooks.com> wrote:
>
> I want to track the number of file downloads and I'm wondering if any
> here have thoughts on how best to do this.
>
> At the moment I have a separate Files table for the details that
> stores information such as; filename, filesize, version,
> first_downloaded and downloads.
>
> Is incrementing the 'downloads' field here the best way to record it?

In a really basic, low-traffic setup, this might be ok.

> Should I use a completely separate table or perhaps even a flat file?

You've already got a database so a file would be needlessly
complicating things as well as slowing things down.

> I'm considering recording the date/time of each download, would this
> affect the decision?

The key here is "each download". So, you'll want to record them all,
individually, in their own table.

> Now, not only do I want to record file downloads but I also want to
> know how may total downloads a particular author has achieved. Should
> I increment a field in the author table at the time of the file
> download or, process the 'Files' table to calculate this number on the
> fly? - I guess that would mean adding an author_id to the Files table.

Create a downloads table to store the datetime and file_id. You can
total all downloads for files associated with a particular author by
getting the IDs for all files with a particular author_id, and the sum
for each in the downloads table.

> NOTE: there's a good chance I will provide an API in the future for
> third-parties to access the file database. Would this affect the
> design decisions now?

Do you mean the model/controller, or the actual table?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to