I have a page views table where every time a page is viewed, the user's ip and page id are put in a table. In this table, I only want one row for each ip/page id combination. If I set primary key to ip, then each ip can only be associated with one page. If I set primary key to page id, then only one ip will be associated with each page.
I need both of these to be keys because it's the combination of ip and page id that can not be repeated in the table. How can I do this?
$mysqli->query("INSERT INTO page_views (ip, page_id, view_key) VALUES ('$ip', '$page_id', '$view_key')
ON DUPLICATE KEY UPDATE page_key='$view_key'");
This is how I need the setup to work - so every time someone views the page, they are assigned a view_key, and it is put in the table. If there is already a record of that ip viewing that page, then the view_key field should be overwritten.