Created
September 10, 2012 17:35
-
-
Save Lysander/3692380 to your computer and use it in GitHub Desktop.
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
-- | |
-- Variante 1: | |
-- | |
CREATE TABLE if not exists Autos ( | |
CarID INTEGER PRIMARY KEY, | |
Marke TEXT | |
) | |
CREATE TABLE if not exists Fahrer ( | |
Name TEXT PRIMARY KEY, | |
Auto INTEGER, | |
FOREIGN KEY(Auto) references Autos(CarID) | |
) | |
-- | |
-- Variante 2: | |
-- (gleichzeitig Alternative zur Lösung von Variante 1) | |
CREATE TABLE if not exists Autos ( | |
CarID INTEGER PRIMARY KEY, | |
Marke TEXT, | |
Fahrer TEXT, | |
FOREIGN KEY(Fahrer) references Fahrer(Name) | |
) | |
CREATE TABLE if not exists Fahrer ( | |
Name TEXT PRIMARY KEY | |
) | |
-- | |
-- Variante 3: | |
-- | |
CREATE TABLE if not exists Autos ( | |
CarID INTEGER PRIMARY KEY, | |
Marke TEXT | |
) | |
CREATE TABLE if not exists Fahrer ( | |
Name TEXT PRIMARY KEY | |
) | |
CREATE TABLE if not exists FahrerAuto ( | |
Fahrer TEXT, | |
Auto INTEGER, | |
PRIMARY KEY(Fahrer, Auto), | |
FOREIGN KEY(Fahrer) references Fahrer(Name), | |
FOREIGN KEY(Auto) references Autos(CarID) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment