CREATE TABLE L
(
  lnr VARCHAR(10) PRIMARY KEY,
  lname VARCHAR(40) NOT NULL,
  sitz VARCHAR(40),
  status INT
);
 
 
CREATE TABLE T
(
  tnr VARCHAR(10) PRIMARY KEY,
  tname VARCHAR(40) NOT NULL,
  farbe VARCHAR(40),
  gewicht INT,
  preis VARCHAR(40),
  CHECK (gewicht > 0)
);
 
CREATE TABLE P
(
  pnr VARCHAR(10) PRIMARY KEY,
  pname VARCHAR(40) NOT NULL,
  ort VARCHAR(40)
);
 
CREATE TABLE LTP
(
  lnr VARCHAR(10),
  tnr VARCHAR(10),
  pnr VARCHAR(10),
  menge INT,
  PRIMARY KEY (lnr, tnr, pnr),
  FOREIGN KEY (lnr) REFERENCES L (lnr),
  FOREIGN KEY (tnr) REFERENCES T (tnr),
  FOREIGN KEY (pnr) REFERENCES P (pnr),
  CHECK (menge > 0)
);
 
 
INSERT INTO L (LNR, LNAME, STATUS, SITZ) VALUES ('L1', 'MEIER', 20, 'WETTER');
INSERT INTO L (LNR, LNAME, STATUS, SITZ) VALUES ('L2', 'MULLER', 10, 'BERLIN');
INSERT INTO L (LNR, LNAME, STATUS, SITZ) VALUES ('L3', 'SCHMIDT', 50, 'BERLIN');
INSERT INTO L (LNR, LNAME, STATUS, SITZ) VALUES ('L4', 'SCHULZ', 30, 'WETTER');
INSERT INTO L (LNR, LNAME, STATUS, SITZ) VALUES ('L5', 'KRAUSE', 40, 'MESCHEDE');
 
 
INSERT INTO T (TNR, TNAME, FARBE, GEWICHT) VALUES ('T1', 'STECKER', 'ROT', 15);
INSERT INTO T (TNR, TNAME, FARBE, GEWICHT) VALUES ('T2', 'KABEL', 'BLAU', 27);
INSERT INTO T (TNR, TNAME, FARBE, GEWICHT) VALUES ('T3', 'SCHALTER', 'WEISS', 05);
INSERT INTO T (TNR, TNAME, FARBE, GEWICHT) VALUES ('T4', '8080', 'ROT', 02);
INSERT INTO T (TNR, TNAME, FARBE, GEWICHT) VALUES ('T5', 'DISKETTE', 'BLAU', 12);
INSERT INTO T (TNR, TNAME, FARBE, GEWICHT) VALUES ('T6', 'SCHRAUBE', 'ROT', 03);
 
 
INSERT INTO P (PNR, PNAME, ORT) VALUES ('P1', 'UFO', 'BERLIN');
INSERT INTO P (PNR, PNAME, ORT) VALUES ('P2', 'PLEITE', 'BONN');
INSERT INTO P (PNR, PNAME, ORT) VALUES ('P3', 'CPU', 'MESCHEDE');
INSERT INTO P (PNR, PNAME, ORT) VALUES ('P4', 'KAESE', 'MESCHEDE');
INSERT INTO P (PNR, PNAME, ORT) VALUES ('P5', 'POST', 'WETTER');
INSERT INTO P (PNR, PNAME, ORT) VALUES ('P6', 'SOFTWARE', 'ESSEN');
INSERT INTO P (PNR, PNAME, ORT) VALUES ('P7', 'KNALL', 'WETTER');
INSERT INTO P (PNR, PNAME, ORT) VALUES ('P8', 'UMZUG', 'BERLIN');
 
 
INSERT INTO LTP (LNR, TNR, PNR, MENGE) VALUES ('L1', 'T1', 'P8', 1200);
INSERT INTO LTP (LNR, TNR, PNR, MENGE) VALUES ('L1', 'T1', 'P1', 200);
INSERT INTO LTP (LNR, TNR, PNR, MENGE) VALUES ('L1', 'T1', 'P4', 700);
INSERT INTO LTP (LNR, TNR, PNR, MENGE) VALUES ('L1', 'T4', 'P1', 300);
INSERT INTO LTP (LNR, TNR, PNR, MENGE) VALUES ('L1', 'T6', 'P1', 200);
INSERT INTO LTP (LNR, TNR, PNR, MENGE) VALUES ('L2', 'T3', 'P1', 400);
INSERT INTO LTP (LNR, TNR, PNR, MENGE) VALUES ('L2', 'T3', 'P2', 200);
INSERT INTO LTP (LNR, TNR, PNR, MENGE) VALUES ('L2', 'T3', 'P3', 200);
INSERT INTO LTP (LNR, TNR, PNR, MENGE) VALUES ('L2', 'T3', 'P4', 500);
INSERT INTO LTP (LNR, TNR, PNR, MENGE) VALUES ('L2', 'T3', 'P5', 600);
INSERT INTO LTP (LNR, TNR, PNR, MENGE) VALUES ('L2', 'T3', 'P6', 400);
INSERT INTO LTP (LNR, TNR, PNR, MENGE) VALUES ('L2', 'T3', 'P7', 800);
INSERT INTO LTP (LNR, TNR, PNR, MENGE) VALUES ('L2', 'T3', 'P8', 300);
INSERT INTO LTP (LNR, TNR, PNR, MENGE) VALUES ('L2', 'T5', 'P2', 100);
INSERT INTO LTP (LNR, TNR, PNR, MENGE) VALUES ('L3', 'T3', 'P1', 200);
INSERT INTO LTP (LNR, TNR, PNR, MENGE) VALUES ('L3', 'T4', 'P2', 500);
INSERT INTO LTP (LNR, TNR, PNR, MENGE) VALUES ('L4', 'T6', 'P3', 300);
INSERT INTO LTP (LNR, TNR, PNR, MENGE) VALUES ('L4', 'T6', 'P7', 300);
INSERT INTO LTP (LNR, TNR, PNR, MENGE) VALUES ('L5', 'T2', 'P2', 200);
INSERT INTO LTP (LNR, TNR, PNR, MENGE) VALUES ('L5', 'T2', 'P4', 100);
INSERT INTO LTP (LNR, TNR, PNR, MENGE) VALUES ('L5', 'T5', 'P5', 500);
INSERT INTO LTP (LNR, TNR, PNR, MENGE) VALUES ('L5', 'T5', 'P7', 100);
INSERT INTO LTP (LNR, TNR, PNR, MENGE) VALUES ('L5', 'T6', 'P2', 200);
INSERT INTO LTP (LNR, TNR, PNR, MENGE) VALUES ('L5', 'T1', 'P4', 1000);
INSERT INTO LTP (LNR, TNR, PNR, MENGE) VALUES ('L5', 'T3', 'P4', 1200);
INSERT INTO LTP (LNR, TNR, PNR, MENGE) VALUES ('L5', 'T4', 'P4', 800);
INSERT INTO LTP (LNR, TNR, PNR, MENGE) VALUES ('L5', 'T5', 'P4', 400);
INSERT INTO LTP (LNR, TNR, PNR, MENGE) VALUES ('L5', 'T6', 'P4', 500);
