Advertisement
any15015

Act1.Labo3

Aug 14th, 2024 (edited)
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.82 KB | None | 0 0
  1. CREATE DATABASE AcademiaDeMusica
  2. GO
  3. USE AcademiaDeMusica
  4. GO
  5.  
  6. CREATE TABLE musicos(
  7. dni INT NOT NULL PRIMARY KEY,
  8. nombre VARCHAR(30) NOT NULL,
  9. apellido VARCHAR(30) NOT NULL,
  10. fechaIngreso DATE NOT  NULL,
  11. fechaNacimiento DATE NOT NULL
  12. );
  13.  
  14. CREATE TABLE tiposDeInstrumentos(
  15. ID_tipoInstrumento SMALLINT NOT NULL PRIMARY KEY IDENTITY(1,1),
  16. descripcion VARCHAR(30) NOT NULL UNIQUE
  17. );
  18. GO
  19. CREATE TABLE instrumentos(
  20. ID_instrumento VARCHAR(10) NOT NULL UNIQUE,
  21. ID_tipoInstrumento SMALLINT NOT NULL FOREIGN KEY REFERENCES tiposDeInstrumentos(ID_tipoInstrumento),
  22. descripcion VARCHAR(30) NOT NULL UNIQUE
  23. );
  24. GO
  25. CREATE TABLE instrumentosXmusicos(
  26. dni INT NOT NULL FOREIGN KEY REFERENCES musicos(dni),
  27. ID_instrumento VARCHAR(10) NOT NULL FOREIGN KEY REFERENCES instrumentos(ID_instrumento),
  28. PRIMARY KEY(dni, ID_instrumento)
  29. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement