Jump to content

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
https://forums.phpfreaks.com/topic/198734-not-allowing-duplicate-records-in-table/
Share on other sites

Hi there,

In addition to the suggsted solution by gaza165, you need to make both Store_ID and Employee_ID as the primary key of the table. This will enfource that no duplicate can happen and even when you have no check the system will through an error messge.

 

Regards

 

 

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

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.