Keith Roberts <ke...@karsites.net> wrote:
> I have the following table to keep a count of the number of
> times files are downloaded from my website:
> 
> CREATE TABLE "file_downloads"
>  (
>  "record_id" INTEGER PRIMARY KEY,
>  "filename" char(60),
>  "dl_count" INTEGER
>   /* PRIMARY KEY  ("record_id") */
> );
> 
> The select statement to get the current download count for a
> file is:
> 
> SELECT *
> from file_downloads
> where filename = "$dl_file";
> 
> And the update statement to update the dl_count column is:
> 
> UPDATE file_downloads set
> dl_count = "$new_count"
> where filename = "$dl_file";
> 
> Would this be an efficient way of doing things?
> 
> I don't expect to be keeping track of more than 200 files
> for downloading.

Not really efficient, but with 200 records, you won't notice.

> I was wondering if it is possible to setup the filename
> column as a UNIQUE PRIMARY KEY on a TEXT column.

It's UNIQUE or PRIMARY KEY: they don't go together. Yes, you could do either. 
There could be only one PRIMARY KEY in a table, and you already have one, so 
you'll have to choose which one you want. On the other hand, you could have an 
unlimited number of UNIQUE constraints.
-- 
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to