Advertisement
dragonbs

Untitled

Sep 22nd, 2023
1,097
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.58 KB | None | 0 0
  1. CREATE TABLE [Students](
  2.     [StudentID] INT IDENTITY PRIMARY KEY,
  3.     [Name] NVARCHAR(20)
  4. )
  5. CREATE TABLE [Exams](
  6.     [ExamID] INT IDENTITY(101,1) PRIMARY KEY,
  7.     [Name] NVARCHAR(50)
  8. )
  9. CREATE TABLE [StudentsExams](
  10.     [StudentID] INT REFERENCES [Students]([StudentID]),
  11.     [ExamID] INT REFERENCES [Exams]([ExamID]),
  12.     PRIMARY KEY([StudentID], [ExamID])
  13. )
  14. INSERT INTO [Students]
  15.     VALUES
  16. ('Mila'),
  17. ('Toni'),
  18. ('Ron')
  19. INSERT INTO [Exams]
  20.     VALUES
  21. ('SpringMVC'),
  22. ('Neo4j'),
  23. ('Oracle 11g')
  24. INSERT INTO [StudentsExams]
  25.     VALUES
  26. (1, 101),
  27. (1, 102),
  28. (2, 101),
  29. (3, 103),
  30. (2, 102),
  31. (2, 103)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement