I am creating a website for gaming website and there I have problem to set unique combination for two value. table_1 :
id (Primary)
game_name
table_2 :id (Primary)
game_id (INDEX) --- relation with table_1-id
result
create_on (timestamp)
I want to set constraint between game_id and created_on(date_only). because here i will update a result value for each game per day and here don't want to get double entry in same day. is this possible to set constraint in database?
Asked
Active
Viewed 21 times
0

Ricky Riccs
- 41
- 1
- 5
-
You need to tell us which database (e.g. MySQL, SQL Server, Oracle, etc.) you are using. – Tim Biegeleisen Mar 06 '20 at 15:34
-
I am using MySQL database @TimBiegeleisen – Ricky Riccs Mar 06 '20 at 15:51
-
https://stackoverflow.com/questions/635937/how-do-i-specify-unique-constraint-for-multiple-columns-in-mysql – Honeyboy Wilson Mar 06 '20 at 16:31
-
You did not get my point ! you may please read my question again to understand that I am talking about to make unique combination of game_id and partial timestamp (Y-m-d) instead of full timestamp (Y-m-d H:i:s). here I have full timestamp in my database all time. – Ricky Riccs Mar 06 '20 at 19:11
-
https://stackoverflow.com/questions/95183/how-does-one-create-an-index-on-the-date-part-of-datetime-field-in-mysql – Honeyboy Wilson Mar 06 '20 at 21:05