I have the following table:
my_contacts
which contains the following columns:
contact_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
frist_name VARCHAR(20),
interest VARCHAR(20)
-----------+-----------+----------
contact_id | fisrt_name | interest +
----------------------------------
1 | smith | swim +
2 | mark | dance +
----------------------------------
I need to move the interests column and make it into a CHILD table:
Here's the code to do that:
CREATE TABLE interests
(
int_id INT NOT NULL AUTO_INCREMENT PRIMARY_KEY,
interest VARCHAR(20) NOT NULL,
contact_id INT NOT NULL,
CONSTRAINT my_contacts_contact_id_fk
FOREIGN KEY (contact_id)
REFERENCES my_contacts (contact_id)
);
Since I can't add information to the child table because of CONSTRAINT how am I goona move the interests from my_contacts to my new table interests so they have a one-to-many relationship ???