ahamednishadh Posted February 27, 2010 Share Posted February 27, 2010 hello there.. need a small help regarding mysql databse. i have a table k.. nw this is a table for entering information of a time table like scene.. that is a user can enter a date and then enter the times he is free for that day.. i have the following fields in the table.. ID - userid - foreign key dates - the date - primary key slot1 -1st free slot slot2 -2nd free slot slot3 -3rd free slot slot4 -4th free slot slot5 -5th free slot slot6 -6th free slot slot7 -7th free slot slot8 -8th free slot all the slots are for the same day... so the user can input different times of the day that he is free... nw i did this and it worked and now i stumbled upon a problem.. that is i entered sum data for one user and now wen i try to enter data for another user for the same date... i cant coz it says already exists.. nw this is my problem.. how do i make it so that i can have the same user enter multiple dates and also another user enters the same date... BUT the same user cant enter the same date twice... hw can this be done?? thanks a million times in advance!!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/193555-make-one-field-unique-depending-on-another-field/ Share on other sites More sharing options...
jskywalker Posted February 27, 2010 Share Posted February 27, 2010 dates - the date - primary key if only the 'date' is in the primary key, than 2 users cannot do something on the same date Quote Link to comment https://forums.phpfreaks.com/topic/193555-make-one-field-unique-depending-on-another-field/#findComment-1018917 Share on other sites More sharing options...
ahamednishadh Posted February 27, 2010 Author Share Posted February 27, 2010 dates - the date - primary key if only the 'date' is in the primary key, than 2 users cannot do something on the same date well thats da problem.... i didnt realize this problem wud come up when designing the db.. so is there n e way that i can modify the db so that i can make my scenario work???? by changing the primary key or wat ever??? Quote Link to comment https://forums.phpfreaks.com/topic/193555-make-one-field-unique-depending-on-another-field/#findComment-1018939 Share on other sites More sharing options...
jskywalker Posted February 27, 2010 Share Posted February 27, 2010 http://dev.mysql.com/doc/refman/5.1/en/alter-table.html ALTER TABLE mytable DROP PRIMARY KEY, ADD PRIMARY KEY(col1,col2); Quote Link to comment https://forums.phpfreaks.com/topic/193555-make-one-field-unique-depending-on-another-field/#findComment-1018944 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.