Jump to content

make one field unique depending on another field!!!


Recommended Posts

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!!!!!!

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???

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.