Hello the forum,
My problem is rather involved, so I really appreciate any of you who manage to bear with me to the end.
To describe the problem, let me first present a hypothetical database, perhaps used to track students. This database consists of two tables.
The first table "students" has two attributes: a primary key called "ssn"(primary key unique not null) that tracks the student's SSN, and a second attribute "name" that tracks their name.
The second, "classes", also has two attributes, "fk_ssn"(not null references students(ssn)), and "class" (Varchar) which represents the classes they have taken. This essentially represents a one-to-many relationship.
The problem is this: I am doing updates to a similar database in php, inserting table by table. That is, I first insert into students, and then into classes. When using REPLACE syntax, MySQL will notice that the primary key in students exists already, and replace the existing record. However, since the classes.fk_ssn cannot be unique (recall: one to many), it cannot be a primary key, and thus, MySQL simply adds another duplicate record rather than replace the existing one.
My question is, does anyone know an elegant way to deal with this problem?
AT