-
Notifications
You must be signed in to change notification settings - Fork 89
/
Copy path1_Database_initial.sql
65 lines (61 loc) · 1.99 KB
/
1_Database_initial.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
CREATE DATABASE [EFCoreDDD]
go
USE [EFCoreDDD]
GO
/****** Object: Table [dbo].[Course] Script Date: 11/19/2019 4:27:23 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Course](
[CourseID] [bigint] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](50) NOT NULL,
CONSTRAINT [PK_Course] PRIMARY KEY CLUSTERED
(
[CourseID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Student] Script Date: 11/19/2019 4:27:23 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Student](
[StudentID] [bigint] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](50) NOT NULL,
[Email] [nvarchar](50) NOT NULL,
[FavoriteCourseID] [bigint] NOT NULL,
CONSTRAINT [PK_Student] PRIMARY KEY CLUSTERED
(
[StudentID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET IDENTITY_INSERT [dbo].[Course] ON
GO
INSERT [dbo].[Course] ([CourseID], [Name]) VALUES (1, N'Calculus')
GO
INSERT [dbo].[Course] ([CourseID], [Name]) VALUES (2, N'Chemistry')
GO
INSERT [dbo].[Course] ([CourseID], [Name]) VALUES (3, N'Literature')
GO
INSERT [dbo].[Course] ([CourseID], [Name]) VALUES (4, N'Trigonometry')
GO
INSERT [dbo].[Course] ([CourseID], [Name]) VALUES (5, N'Microeconomics')
GO
SET IDENTITY_INSERT [dbo].[Course] OFF
GO
SET IDENTITY_INSERT [dbo].[Student] ON
GO
INSERT [dbo].[Student] ([StudentID], [Name], [Email], [FavoriteCourseID]) VALUES (1, N'Alice', N'[email protected]', 2)
GO
INSERT [dbo].[Student] ([StudentID], [Name], [Email], [FavoriteCourseID]) VALUES (2, N'Bob', N'[email protected]', 2)
GO
SET IDENTITY_INSERT [dbo].[Student] OFF
GO
ALTER TABLE [dbo].[Student] WITH CHECK ADD CONSTRAINT [FK_Student_Course] FOREIGN KEY([FavoriteCourseID])
REFERENCES [dbo].[Course] ([CourseID])
GO
ALTER TABLE [dbo].[Student] CHECK CONSTRAINT [FK_Student_Course]
GO