-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomework1.sql
More file actions
85 lines (75 loc) · 1.85 KB
/
Copy pathHomework1.sql
File metadata and controls
85 lines (75 loc) · 1.85 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
USE [master]
GO
DROP DATABASE IF EXISTS [SEDCACADEMYDB]
GO
CREATE DATABASE [SEDCACADEMYDB]
GO
USE [SEDCACADEMYDB]
GO
DROP TABLE IF EXISTS [dbo].[Students]
DROP TABLE IF EXISTS [dbo].[Teachers]
DROP TABLE IF EXISTS [dbo].[Grades]
DROP TABLE IF EXISTS [dbo].[Courses]
DROP TABLE IF EXISTS [dbo].[AchievementTypes]
DROP TABLE IF EXISTS [dbo].[GradeDetails]
GO
CREATE TABLE Students (
[Id] int IDENTITY(1,1) NOT NULL,
[FirstName] nvarchar(50) NOT NULL,
[LastName] nvarchar(50) NOT NULL,
[DateOfBirth] date NULL,
[EnrolledDate] date NOT NULL,
[Gender] nchar(1) NULL,
[NationalIDNumber] nvarchar(20) NOT NULL,
[StudentCardNumber] nvarchar(20) NOT NULL,
CONSTRAINT [PK_Students] PRIMARY KEY(Id)
)
GO
CREATE TABLE Teacher (
[Id] int IDENTITY(1,1) NOT NULL,
[FirstName] nvarchar(50) NOT NULL,
[LastName] nvarchar(50) NOT NULL,
[DateOfBirth] date NULL,
[AcademicRank] int NULL,
[HireDate] date NOT NULL
CONSTRAINT [PK_Teacher] PRIMARY KEY(Id)
)
GO
CREATE TABLE Grades (
[Id] int IDENTITY(1,1) NOT NULL,
[StudentID] int NULL,
[CourseID] int NULL,
[TeacherID] int NULL,
[Grade] int NOT NULL,
[Comment] nvarchar(50) NULL,
[CreatedDate] date NOT NULL
CONSTRAINT [PK_Grade] PRIMARY KEY(Id)
)
GO
CREATE TABLE Courses (
[Id] int IDENTITY(1,1) NOT NULL,
[Name] nvarchar(100) NOT NULL,
[Credit] nvarchar(20) NOT NULL,
[AcademicYear] date NOT NULL,
[Semester] nvarchar(50) NOT NULL
CONSTRAINT [PK_Course] PRIMARY KEY(Id)
)
GO
CREATE TABLE GradeDetails (
[Id] int IDENTITY(1,1) NOT NULL,
[GradeID] int NULL,
[AchievementTypeID] int NULL,
[AchievementPoints] int NOT NULL,
[AchievementMaxPoints] int NULL,
[AchievementDate] date NOT NULL
CONSTRAINT [PK_GradeDetails] PRIMARY KEY(Id)
)
GO
CREATE TABLE AchievementType (
[Id] int IDENTITY(1,1) NOT NULL,
[Name] nvarchar(100) NOT NULL,
[Description] nvarchar(100) NULL,
[ParticipationRate] nvarchar(50) NULL
CONSTRAINT [PK_AchievementType] PRIMARY KEY (Id)
)
GO