multi field combine key
Hi
I m thinking about combined key system. say i have mysql table having field
1. user_name
2. father_name
3. mother_name
4. Address
Now I can mark user_name field as key for unique value.
But I dont want that. I want that same user name is possible but same user name, father name and mother name combine is not possible. combined they must unique. mor easily
1. name01, father01,mother01
2. name01, father01,mother02
3. name01, father02,mother01
above data entry may be allow
But I want that
1. name01, father01,mother01
2. name01, father01,mother01
above data entry will not be allowed
arctushar
Junior Poster in Training
66 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
CREATE TABLE student(
name CHAR(100),
father CHAR(100),
mother CHAR(100),
address VARCHAR(255),
PRIMARY KEY (name,father,mother)
)
hielo
Veteran Poster
1,124 posts since Dec 2007
Reputation Points: 116
Solved Threads: 244
CREATE TABLE student(
name CHAR(100),
father CHAR(100),
mother CHAR(100),
address VARCHAR(255),
PRIMARY KEY (name,father,mother)
)
thanks it works for me. now how can edit primary key. another question field has been set unique wrongly. how can I ununique now.
arctushar
Junior Poster in Training
66 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
hielo
Veteran Poster
1,124 posts since Dec 2007
Reputation Points: 116
Solved Threads: 244