Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.14 KB | None | 0 0
  1. CREATE TABLE Studente
  2.     (`Matricola` INT PRIMARY KEY, `Nome` VARCHAR(15), `Cognome` VARCHAR(20), `AnnoIscrizione` INT)
  3.     ;
  4.   CREATE TABLE Insegnamento
  5.     (`Codice` INT PRIMARY KEY, `NomeIns` VARCHAR(15), `Docente` VARCHAR(20))
  6.   ;
  7.   CREATE TABLE Esame
  8.     (`Studente` INT, `Insegnamento` INT, `Data` INT, `Voto` INT,
  9.       PRIMARY KEY(`Studente`,`Insegnamento`,`Data`),
  10.       FOREIGN KEY(`Studente`) REFERENCES Studente(`Matricola`),
  11.       FOREIGN KEY(`Insegnamento`) REFERENCES Insegnamento(`Codice`))
  12.     ;
  13. INSERT INTO Studente
  14. (`Matricola`, `Nome`, `Cognome`,`AnnoIscrizione`)
  15. VALUES
  16. (1234,'Marco','Cauzzi',1993),
  17. (1323,'Marco','Cauzzi',1993),
  18. (1455,'Marco','Cauzzi',1993),
  19. (1312,'Marco','Cauzzi',1993)
  20. ;
  21. INSERT INTO Insegnamento
  22. (`Codice`, `NomeIns`, `Docente`)
  23. VALUES
  24. (123123,'Programma23','Bombi'),
  25. (123312,'Programma23','Bombi'),
  26. (123112,'Programma23','Bombi'),
  27. (544545,'Programma26','Bombi'),
  28. (123456,'Programma23','Bombi')
  29. ;
  30. INSERT INTO Esame
  31.  (`Studente`, `Insegnamento`, `Data`, `Voto`)
  32.  VALUES
  33.  (1323,123123,2013,19),
  34.  (1455,123123,2013,30),
  35.  (1323,123312,2013,15),
  36.  (1455,544545,2013,10),
  37.  (1312,123123,2014,27)
  38.   ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement