Oct 16, 2024
Customers and Transactions via Customer ID.Transactions table to include foreign key constraint.Add a Foreign Key:
ALTER TABLE Transactions
ADD FOREIGN KEY (CustomerID)
REFERENCES Customers(CustomerID);
Naming Foreign Key Constraints:
ADD CONSTRAINT to give a unique name.ALTER TABLE Transactions
ADD CONSTRAINT FK_CustomerID
FOREIGN KEY (CustomerID)
REFERENCES Customers(CustomerID);
ALTER TABLE Transactions
DROP FOREIGN KEY transactions_IBFK_1;
ALTER TABLE Transactions
AUTO_INCREMENT = 1000;
DELETE FROM Customers WHERE customerId = 3;