How can I create a download counter database? MySQL PHP

I would like to create a download counter for my files. Here are my current table fields:

download_counter table
_______________________
ID - int(6) - AutoInc,
Product - varchar(128),
Version - varchar(128),
Date - date,
IP - LONGTEXT

I am wondering if I should use the current table or use a more dynamic and flexible table, for example:

ID - int(11) - AutoInc,
Product - varchar(128),
Version - varchar(128),
Date - date,
IP - varchar(45)
+3
source share
2 answers

I would normalize your table correctly:

download_counter {
   did,
   prodid,
   dldstamp,
   ip
}

and follow the product table:

product_table {
   prodid,
   version,
   description,
   url,
   lastmodified,
   etc;
}

And you would just insert the download request in your download_counter, referencing prodid , from your product_table.

Simple and easy to normalize. Then you will manage your products / downloads in a separate table.

+3
source

, , SELECT .

: IP- MySQL, INET_NTOA INET_ATON. IP- 32- , 4 , 15 . .

+4

Source: https://habr.com/ru/post/1787985/


All Articles