Click to See Complete Forum and Search --> : MySQL: keeping track of IPs
SolarFlare
February 16th, 2004, 10:37 PM
I would like to keep track of the IP addresses of people who click on a link (so I can tell if the same IP has clicked it twice). What is the best way to store this in a MySQL table? I don't want a table where each row is an IP because there are a large number of links (and continually increasing) to keep track of. On the other hand, I don't know if it is possible to fit an unlimited number of IP's into one row (or row-column position) of a table. Will I need a table for each link (where each IP is a row), or can I store an unknown number of IP's in one row?
Thanks!
Kheun
February 16th, 2004, 11:34 PM
If I am not wrong, each field within the database has a limited length. I don't think you can store all IP addresses into a row.
In addition, if you store each IP address into a separate row and the field is being indexed, you can achieve better search performance.
SolarFlare
February 17th, 2004, 09:31 PM
So... you couldn't have anything conceptually like the attached image in terms of data storage?
A table can store data in two dimensions... having n tables gives you three dimensions. You can't have a table of tables... does this mean that SQL storage is limited to 3 dimensions?
Kheun
February 17th, 2004, 10:24 PM
I haven't been touching databases for over a year. I am not sure if my previous knowledge is still relevent. Anyway, here it goes.
I have never seen database capable of storing things in 3D. I believe that all data can only be stored in 2D. Based on the 2D restriction, the other fields other than E has to be repeated. In other words, this is very inefficient as common data is repeated in the field A to D for each different E entry. You can optimize your table by splitting it into two tables. In this way, the first table consists of A, B, C and D while the second table consists of E and another fields to an indexed field or key in the first table. I can't remember exactly which norms or rules but it tells us how to avoid repeatition in database. FYI, the indexed field should be assigned by you where it improve your database query speed.
Hope it helps.
SolarFlare
February 18th, 2004, 04:34 PM
Originally posted by Kheun
I haven't been touching databases for over a year. I am not sure if my previous knowledge is still relevent. Anyway, here it goes.
I have never seen database capable of storing things in 3D. I believe that all data can only be stored in 2D. Based on the 2D restriction, the other fields other than E has to be repeated. In other words, this is very inefficient as common data is repeated in the field A to D for each different E entry. You can optimize your table by splitting it into two tables. In this way, the first table consists of A, B, C and D while the second table consists of E and another fields to an indexed field or key in the first table. I can't remember exactly which norms or rules but it tells us how to avoid repeatition in database. FYI, the indexed field should be assigned by you where it improve your database query speed.
Hope it helps.
Thanks for your help, Kheun. I suppose if I have to conform, then I can name the tables "data[i][j]" or "data[i][j][k]" and at least pretend like I have a multidimensional capacity ;).
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.