-
Notifications
You must be signed in to change notification settings - Fork 516
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added many-to-many relationship.
- Loading branch information
Frank Versnel
committed
Feb 4, 2018
1 parent
3005433
commit 3d251cd
Showing
4 changed files
with
163 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
DROP database IF EXISTS hyf_musicians2; | ||
CREATE database hyf_musicians2; | ||
USE hyf_musicians2; | ||
|
||
CREATE TABLE Musicians( | ||
Id INT NOT NULL, | ||
FirstName TEXT NOT NULL, | ||
LastName TEXT NOT NULL, | ||
Born INT NOT NULL, | ||
PRIMARY KEY (Id) | ||
); | ||
|
||
CREATE TABLE Instruments( | ||
Id INT NOT NULL, | ||
Name TEXT NOT NULL, | ||
Type TEXT NOT NULL, | ||
PRIMARY KEY (Id) | ||
); | ||
|
||
CREATE TABLE InstrumentsPlayed( | ||
Id INT NOT NULL, | ||
Musician INT NOT NULL, | ||
Instrument INT NOT NULL, | ||
PRIMARY KEY (Id), | ||
FOREIGN KEY (Musician) REFERENCES Musicians(Id), | ||
FOREIGN KEY (Instrument) REFERENCES Instruments(Id) | ||
); | ||
|
||
INSERT INTO Musicians (Id, FirstName, LastName, Born) VALUES (1, 'Thelonious', 'Monk', 1917); | ||
INSERT INTO Musicians (Id, FirstName, LastName, Born) VALUES (2, 'Sonny', 'Rollins', 1930); | ||
INSERT INTO Musicians (Id, FirstName, LastName, Born) VALUES (3, 'Steve', 'Lehman', 1978); | ||
|
||
INSERT INTO Instruments (Id, FirstName, LastName, Born) VALUES (1, 'Piano', 'Keys'); | ||
INSERT INTO Instruments (Id, FirstName, LastName, Born) VALUES (2, 'Tenor saxophone', 'Wind'); | ||
INSERT INTO Instruments (Id, FirstName, LastName, Born) VALUES (3, 'Soprano saxophone', 'Wind'); | ||
INSERT INTO Instruments (Id, FirstName, LastName, Born) VALUES (4, 'Alto saxophone', 'Wind'); | ||
INSERT INTO Instruments (Id, FirstName, LastName, Born) VALUES (5, 'Guitar', 'String'); | ||
|
||
INSERT INTO InstrumentsPlayed (Id, Musician, Instrument) VALUES (1, 1, 1); | ||
INSERT INTO InstrumentsPlayed (Id, Musician, Instrument) VALUES (2, 2, 2); | ||
INSERT INTO InstrumentsPlayed (Id, Musician, Instrument) VALUES (3, 2, 3); | ||
INSERT INTO InstrumentsPlayed (Id, Musician, Instrument) VALUES (3, 3, 4); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.