forked from vkhorikov/EFCoreEncapsulation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2_Sports.sql
50 lines (50 loc) · 1.9 KB
/
2_Sports.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
USE [EFCoreEncapsulation]
GO
/****** Object: Table [dbo].[Sports] Script Date: 1/27/2022 6:26:31 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Sports](
[SportsID] [bigint] NOT NULL,
[Name] [nvarchar](50) NOT NULL,
CONSTRAINT [PK_Sports] PRIMARY KEY CLUSTERED
(
[SportsID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[SportsEnrollment] Script Date: 1/27/2022 6:26:31 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[SportsEnrollment](
[SportsEnrollmentID] [bigint] NOT NULL,
[SportsID] [bigint] NOT NULL,
[StudentID] [bigint] NOT NULL,
[Grade] [int] NOT NULL,
CONSTRAINT [PK_SportsEnrollment] PRIMARY KEY CLUSTERED
(
[SportsEnrollmentID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
INSERT [dbo].[Sports] ([SportsID], [Name]) VALUES (1, N'Tennis')
GO
INSERT [dbo].[Sports] ([SportsID], [Name]) VALUES (2, N'Football')
GO
INSERT [dbo].[SportsEnrollment] ([SportsEnrollmentID], [SportsID], [StudentID], [Grade]) VALUES (1, 1, 1, 1)
GO
INSERT [dbo].[SportsEnrollment] ([SportsEnrollmentID], [SportsID], [StudentID], [Grade]) VALUES (2, 2, 1, 2)
GO
ALTER TABLE [dbo].[SportsEnrollment] WITH CHECK ADD CONSTRAINT [FK_SportsEnrollment_Sports] FOREIGN KEY([SportsID])
REFERENCES [dbo].[Sports] ([SportsID])
GO
ALTER TABLE [dbo].[SportsEnrollment] CHECK CONSTRAINT [FK_SportsEnrollment_Sports]
GO
ALTER TABLE [dbo].[SportsEnrollment] WITH CHECK ADD CONSTRAINT [FK_SportsEnrollment_Student] FOREIGN KEY([StudentID])
REFERENCES [dbo].[Student] ([StudentID])
GO
ALTER TABLE [dbo].[SportsEnrollment] CHECK CONSTRAINT [FK_SportsEnrollment_Student]
GO