I have a table called teams and a table called games. teams have id, name, ..... games have id, hteam_id, vteam_id, loc, .... I want hteam_id and vteam_id to be a foreign key in the command table. How do you do this?
You can add two foreign keys using the following:
alter table game add foreign key game_hteam_id(hteam_id) references teams(id) , add foreign key game_vteam_id(vteam_id) references teams(id);
Read this first:
FOREIGN KEY LIMITATIONS
Example:
CREATE TABLE parent (id INT NOT NULL, PRIMARY KEY (id) ) ENGINE=INNODB; CREATE TABLE child (id INT, parent_id INT, INDEX par_ind (parent_id), FOREIGN KEY (parent_id) REFERENCES parent(id) ON DELETE CASCADE ) ENGINE=INNODB;
Source: https://habr.com/ru/post/1336610/More articles:WPF: Get the real "logical" position of the Child in your parent panel - c #JavaScript alert error message - javascriptError Qt Creator - qt@MappedSuperclass and @OneToMany - javaCan reflection find my collection type at runtime? - genericsThe constructor uses the layout of the object, how can I test the method in isolation? - c #Mocking TraceListener with Moq - c #Pdf Writer for Rails 3 - ruby-on-railsDrag and Drop in NSCollectionView Example - cocoaAndroid button or vertical alignment TextView - androidAll Articles