Check out example codes for "how to add foreign key in mysql using alter". It will help you in understanding the concepts better.

Code Example 1

ALTER TABLE Orders
ADD FOREIGN KEY (PersonID) REFERENCES Persons(PersonID);

Code Example 2

ALTER TABLE tryholpz_demo07.core_modules 
ADD COLUMN belongs_to_role INT, 
ADD FOREIGN KEY core_modules(belongs_to_role) REFERENCES role_specific_modules_info(id) ON DELETE CASCADE

Code Example 3

ALTER TABLE Orders

ADD CONSTRAINT FK_PersonOrder

FOREIGN KEY (PersonID)
REFERENCES Persons(PersonID);

Learn ReactJs, React Native from akashmittal.com