I'm developing a record management application using php. I've designed a table named records with fields id
, recordname
, recordvalue
, recordid
. For example if a record consists of 3 data firstname
, lastname
, gender
. 3 data (John Doe Male, Jane Doe Female and Sherlcok Holmes Male) is inserted in the table as below-
----+-------------+--------------+-----------
id | recordname | recordvalue | recordid
----+-------------+--------------+-----------
1 | firstname | John | 001
2 | lastname | Doe | 001
3 | gender | Male | 001
4 | firstname | Jane | 002
5 | lastname | Doe | 002
6 | gender | Female | 002
7 | firstname | Sherlock | 003
8 | lastname | Holmes | 003
9 | gender | Male | 003
----+-------------+--------------+-----------
my question is when i'm going to insert a new record in the table i need to check if there is any duplication of the record. That means any field for different records can be duplicated anytime but all the fields having same values for a record can't be duplicated. From previous example records having value John Doe Female, Jane Doe Male, Sherlock Doe Male etc are OK but again inserting John Doe Male is not expected and it'll give an error.
How can i achieve this easily with PHP?
Thanks in advance.