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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.