Advertisement
Guest User

Untitled

a guest
Dec 15th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 2.21 KB | None | 0 0
  1. CREATE DATABASE artist_db;
  2. GO
  3.  
  4. USE artist_db;
  5. GO
  6.  
  7. CREATE TABLE artists
  8. (
  9. id int NOT NULL IDENTITY(1,1),
  10. firstName varchar(40) NOT NULL,
  11. lastName varchar(40) NOT NULL,
  12. db int NOT NULL,
  13. PRIMARY KEY (id)
  14. );
  15.  
  16. CREATE TABLE artMovements
  17. (
  18. id int NOT NULL IDENTITY(1,1),
  19. name varchar(40) NOT NULL,
  20. PRIMARY KEY (id),
  21. );
  22.  
  23. CREATE TABLE paintings
  24. (
  25. id int NOT NULL IDENTITY(1,1),
  26. authorID int  NOT NULL FOREIGN KEY REFERENCES artists(id),
  27. name varchar(40) NOT NULL,
  28. dt int NOT NULL,
  29. idMovArt int NOT NULL FOREIGN KEY REFERENCES artMovements(id),
  30. PRIMARY KEY (id)
  31.  
  32. );
  33.  
  34. CREATE TABLE exhibitions
  35. (
  36. exId int NOT NULL IDENTITY(1,1),
  37. name varchar(40) NOT NULL,
  38. MovId int  NOT NULL FOREIGN KEY REFERENCES artMovements(id),
  39. city varchar(20) NOT NULL,
  40. PRIMARY KEY (exId),
  41. );
  42.  
  43. INSERT INTO artMovements(name)
  44. VAlUES
  45. ('экспрессионизм'),
  46. ('импрессионизм'),
  47. ('абстракционизм'),
  48. ('супрематизм'),
  49. ('сюрреализм');
  50.  
  51. INSERT INTO artists(firstName,lastName, db) VALUES
  52. ('Алексей','Явленский', 1864),
  53. ('Август','Маке', 1853),
  54. ('Огюст','Ренуар', 1841),
  55. ('Эдгар','Дега', 1834),
  56. ('Василий','Кандинский', 1866),
  57. ('Казимир','Малевич', 1879),
  58. ('Сальвадор','Дали', 1931);
  59.  
  60. INSERT INTO paintings(authorID,name, dt, idMovArt) VALUES
  61. (1, 'Девочка с зелёным лицом', 1910, 1),
  62. (1,'Хелен', 1911,1),
  63. (2,'Индейцы', 1911,1),
  64. (2,'Прощание', 1914,1),
  65. (3,'Танец в Буживале', 1883,2),
  66. (3,'Весенний букет', 1866,2),
  67. (4,'Голубые танцовщицы', 1897,2),
  68. (5,'Синий круг', 1922,3),
  69. (5,'Смутное', 1917,3),
  70. (6,'Супрематизм', 1915,4),
  71. (6,'Спортсмены', 1932,3),
  72. (7,'Постоянство памяти', 1931,5),
  73. (7,'Предчувствие гражданской войны', 1936,5);
  74.  
  75.  
  76. SELECT artists.firstName, artists.lastName, paintings.name AS "Title", paintings.dt as "Date", artMovements.name AS "Art Movements"
  77. FROM
  78.   paintings
  79.   JOIN artMovements ON paintings.idMovArt = artMovements.id
  80.   JOIN artists ON paintings.authorID = artists.id
  81.   ORDER BY painting
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement