I have a table which gets new data every few seconds. Consider my table PRODUCT:
+----+-------------+--------+--------------------------------+-------+--------+---------------------+
| id | business_id | name | description | link | status | created_at |
+----+-------------+--------+--------------------------------+-------+--------+---------------------+
| 1 | 12 | qwerty | Description for product qwerty | zxcvb | 1 | 2015-12-07 23:49:33 |
+----+-------------+--------+--------------------------------+-------+--------+---------------------+
| 2 | 12 | abcde | Description for product abcde | mnopq | 0 | 2015-12-07 23:49:33 |
+----+-------------+--------+--------------------------------+-------+--------+---------------------+
Values in columns name and description are unique (I am not sure this is right).
The condition I want: if new data is the same as last inserted data but time stamp is greater than 5 min then perform update or else insert new row in table. Even though name and description are unique.
Query I have tried:
INSERT INTO product(business_id, name, description, link)
VALUES ('$business_id' ,'$product_name','$product_description', '$short')
ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id)
Which condition should I change? Should I remove unique keys?