Created
April 1, 2024 05:03
-
-
Save DavideDunne/a095b0e1c67d10e706f3f426d3fd0ca2 to your computer and use it in GitHub Desktop.
T-SQL tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE [test]; | |
GO | |
IF OBJECT_ID (N'dbo.Enrollments', N'U') IS NOT NULL | |
DROP TABLE [dbo].[Enrollments] | |
GO | |
IF OBJECT_ID (N'dbo.Students', N'U') IS NOT NULL | |
DROP TABLE [dbo].[Students] | |
GO | |
IF OBJECT_ID (N'dbo.Courses', N'U') IS NOT NULL | |
DROP TABLE [dbo].[Courses] | |
GO | |
CREATE TABLE Students( | |
Id int PRIMARY KEY, | |
Full_Name nvarchar(255), | |
Age int | |
); | |
CREATE TABLE Courses( | |
Id int PRIMARY KEY, | |
Course_Name nvarchar(255) | |
); | |
CREATE TABLE Enrollments( | |
Id int PRIMARY KEY, | |
Id_Course int, | |
Id_Student int, | |
CONSTRAINT FK_Courses FOREIGN KEY (Id_Course) REFERENCES dbo.Courses(Id), | |
CONSTRAINT FK_Student FOREIGN KEY (Id_Student) REFERENCES dbo.Students(Id) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment