CREATE TABLE client ( clientid INT AUTO_INCREMENT PRIMARY KEY,
firstname VARCHAR(255),
lastname VARCHAR(255),
phone BIGINT, -- если исходный VARCHAR - поменять,
-- либо соотв. преобразование в INSERT
UNIQUE (firstname, lastname, phone) ); -- можно потом удалить
INSERT INTO client (firstname, lastname, phone)
SELECT DISTINCT firstname, lastname, phone
FROM orders_old;
CREATE TABLE order ( orderid INT AUTO_INCREMENT PRIMARY KEY,
ordernumber INT,
clientid INT,
FOREIGN KEY (clientid) REFERENCES client (clientid) );
INSERT INTO order (ordernumber, clientid)
SELECT orders_old.ordernumber, client.clientid
FROM orders_old
JOIN client USING (firstname, lastname, phone);
NOT NULL - по вкусу.