Jump to content

Not Allowing Duplicate Records in Table


gaza165

Recommended Posts

Hi Everyone,

 

I have a table structure as follows:

 

Store_ID            |  Employee_ID

-------------------------------------------

          1              |          2

          1              |          2                        <<<<<<<<<< cant have this!!

          2              |          2                        <<<<<<<<<< can have this!!

 

 

Basically, one of the criterias is that I cant have the same employee as part of the same store...

 

So i guess what im trying to achieve is that duplicate records cant appear in the table.

 

Can anyone offer any advice on how to enforce this in my table structure??

 

Thanks

 

Garry

 

 

Link to comment
Share on other sites

Well sure, you can set the field to unique, as in, no other record can have the same value, but then if you try and insert it, you're going to get a broken query, so you'll still have to do the query check first anyhow...

 

 

Link to comment
Share on other sites

Hi Guys,

 

Im keeping this context out of PHP...just concentrating on SQL.

 

What you have suggested is brilliant, the whole idea of this question is that I create a suitable database schema for the operations to be performed on the tables.

 

So, you are saying...if I set both ID's as primary keys i wont be able to have duplicate values in my table???

 

Garry

Link to comment
Share on other sites

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.