Mục Lục
Mục Lục
Kiến Thức Core SQL Server QUẢN LÝ KHÁCH SẠN - KHÓA HỌC SQL SERVER Video Hướng dẫn cách xác định kiểu dữ liệu, primary key, foreign key trong SQL - My SQL - SQL Server Bài tập - Thiết kế CSDL - Tạo bảng, thêm dữ liêu, hiển thị dữ liệu - Lập trình SQL Server Video Hướng dẫn thao tác nhiểu bảng - select - multi table - join, inner join trong SQL Server Thiết kế database - bãi đỗ xe - Lập trình SQL Server Video Hướng dẫn phân tích CSDL - phân tích bảng, column trong bản - Học lập trình SQL, SQL Server Video Hướng dẫn tìm hiểu create, alter , insert table và bản chất primary key, foreign key - SQL Server Video Hướng dẫn tìm hiểu select, and, in, like, not in,group by .. having, order by asc, desc - SQL Server Thiết kế hệ quản trị CSDL - Quản lý sinh viên (create, alter, update, insert, select) - Lập trình SQL Server Video Quản lý sinh viên (create, alter, update, insert, select) - Lập trình SQL Server Thiết kế CSDL quản lý sinh viên - lập trình sql server SQL - Thiết kế CSDL quản lý bán hàng - Lập trình SQL Server Thiết kế CSDL quản lý bán hàng - create - alter - insert - update - delete trong CSDL - Học lập trình SQL Server Quản lý khách sạn - nâng cao - Lập trình Sql Server QUẢN LÝ SINH VIÊN (CƠ BẢN) - KHOÁ HỌC SQL SERVER QUẢN LÝ KHÁCH SẠN - KHOÁ HỌC SQL SERVER Quản lý sách - Khóa học lập trình SQL Server QUẢN LÝ THƯ VIỆN - KHOÁ HỌC SQL SERVER View SQL Server Video Hướng dẫn tìm hiểu view trong SQL Server Bài Giảng: Hướng dẫn tìm hiểu view + proc trong SQL - Lập trình SQL Server Thiết kế CSDL quản lý sinh viên - nâng cao - phân 2 - lập trình sql server Bài tập - Thiết kế CSDL - sử dụng trong giải đấu bóng đá FIFA - champions league - world cup - Lập trình SQL Server QUẢN LÝ NGÂN HÀNG - KHOÁ HỌC LẬP TRÌNH SQL SERVER Store & Procedure Video Hướng dẫn tìm hiểu proc procedure trong SQL Server - Lập trình SQL Server, MySQL Bài tập - Quản lý bãi đỗ xe - Lập trình SQL Server Bài tập - Xây dự hệ thống đưa đón học sinh bằng xe bus của Trường Học - Lập trình SQL Server Bài Giảng: Xây dự hệ thống đưa đón học sinh bằng xe bus của Trường Học - Lập trình SQL Server Bài tập - Thiết kế CSDL quản lý sở thú - SQL Server Bài Giảng: Bài tập - Thiết kế CSDL quản lý sở thú - SQL Server Bài tập - Chương trình quản lý bán hàng - Lập trình SQL Server Xây dựng CSDL quản lý điểm danh Trường Học - Lập trình SQL Server/MySQL Video Xây dựng CSDL quản lý điểm danh aptech - Lập trình SQL Server/MySQL Bài tập - Quản lý quán cafe - Lập trình SQL Server - MySQL Video Bài tập - Quản lý quán cafe - Lập trình SQL Server - MySQL Trigger Video Học Trigger qua ví dụ - quản lý nhà trên phố - Lập trình SQL Server Video Hướng dẫn học trigger qua bài quản lý điểm danh Aptech - Lập trình SQL Server Video Bài tập - Quản lý nhân khẩu - Lập trình SQL Server - MySQL Examination & Ôn Tập SQL Server [Examination] Bài Thi Thực Hành SQL Server [Examination] Quản lý sản phẩm - Lập trình SQL Server [Examination] Hệ thống quản lý sinh viên - SQL Server Thiết kế CSDL & Nghiệp vụ quản lý tour du lịch - Khóa học SQL Server Phân tích thiết kế hệ thống quản lý sinh viên - Aptech Phân tích thiết kế database quản lý thư viện - Khóa học SQL Server Phân tích hệ thống CSDL Quản Lý Khách Sạn - Khóa học SQL Server Bài tập - Viết nghiệp vụ cho quản lý khách sạn - Khóa học SQL Server Thiết kế CSDL quản lý carteen - Khóa học SQL Server BÀI TẬP SQL – HỆ THỐNG QUẢN LÝ BÁN HÀNG Product Management System Hệ thống Quản lý Sản phẩm – Bài thực hành Quản Lý Rạp Chiếu Phim - Khoá Học SQL Server Ôn Tập Thi Lý Thuyết [Examination] Ly Thuyet SQL Server 01 [Examination] Ly Thuyet SQL Server 02 [Examination] Ly Thuyet SQL Server 03 [Examination] Ly Thuyet SQL Server 04 [Examination] Ly Thuyet SQL Server 05 [Examination] Ly Thuyet SQL Server 06 [Examination] Ly Thuyet SQL Server 07 Quiz [Trắc Nghiệm] Tìm hiểu về SQL Server - Phần 1 Trắc Nghiệm Khoá SQL Server - Phần 1 Trắc Nghiệm Khoá Học SQL Server Phân 2
SQL Server/MySQL

Bài Giảng: Hệ thống quản lý sinh viên - Lập trình SQL Server

Tạo database & bảng (tables)


-- 1) Database
---- Tao database
create database StudentManagementSystem

---- Kich hoat database
use StudentManagementSystem

-- 2) Tables
---- Table Class
create table Class (
	ClassId int not null,
	ClassCode nvarchar(50)
)

create table Student (
	StudentId int not null,
	StudentName nvarchar(50),
	birthdate datetime,
	ClassId int
)

create table Subject (
	SubjectId int not null,
	SubjectName nvarchar(50),
	SessionCount int
)

create table Result (
	StudentId int not null,
	SubjectId int not null,
	Mark int
)



-- 3) Index Creation and Table Alternation
create nonclustered index NCI_Student_StudentName on Student (StudentName)

alter table Result
alter column Mark float



-- 4) Constraint
---- Primary Key
alter table Class
add constraint PK_Class primary key (ClassId)

alter table Student
add constraint PK_Student primary key (StudentId)

alter table Subject
add constraint PK_Subject primary key (SubjectId)

alter table Result
add constraint PK_Result primary key (StudentId, SubjectId)

---- Foreign Key
alter table Student
add constraint FK_Student_Class foreign key(ClassId) references Class(ClassId)

alter table Result
add constraint FK_Result_Student foreign key(StudentId) references Student(StudentId)

alter table Result
add constraint FK_Result_Subject foreign key(SubjectId) references Subject(SubjectId)

---- CHECK
alter table Subject
add constraint CK_Subject_SessionCount check (SessionCount >= 0)


-- 5) Insert Data
insert into Class(ClassId, ClassCode)
values
(1 ,'C1106KV'),
(2 ,'C1108GV'),
(3 ,'C1108IV'),
(4 ,'C1108HV'),
(5 ,'C1109GV')



insert into Student(StudentId, StudentName, BirthDate, ClassId)
values
(1 ,'Pham Tuan Anh', '1993-08-05', 1),
(2 ,'Phan Van Huy', '1992-06-10', 1),
(3 ,'Nguyen Hoang Minh', '1992-09-07', 2),
(4 ,'Tran Tuan Tu', '1993-10-10', 2),
(5 ,'Do Anh Tai', '1992-06-06', 3)


insert into Subject(SubjectId, SubjectName, SessionCount)
values
(1 ,'C Programming', 22),
(2 ,'Web Design', 18),
(3 ,'Database Management', 23)


insert into Result(StudentId, SubjectId, Mark)
values
(1, 1, 8),
(1, 2, 7),
(2, 3, 5),
(3, 2, 6),
(4, 3, 9),
(5, 2, 8)


-- 6) Query
---- Search students whose BirthDate is between from ‘1992-10-10’ and ‘1993-10-10’. Display info
------ of StudentId, StudentName, DateOfBirth.
select StudentId, StudentName, BirthDate 'DateOfBirth'
from Student
where BirthDate between '1992-10-10' and '1993-10-10'



---- Count students in each class with information of ClassId, ClassCode, TotalStudent
select Class.ClassId, Class.ClassCode, count(Student.StudentId) 'TotalStudent'
from Class left join Student on Class.ClassId = Student.ClassId
group by Class.ClassId, Class.ClassCode


---- Sum up mark of all subjects for each student, then display only students whose sum of mark is
------ greater than 10. Display info of: StudentId, StudentName, TotalMark
select Student.StudentId, Student.StudentName, sum(Result.Mark) 'TotalMark'
from Student left join Result on Student.StudentId = Result.StudentId
group by Student.StudentId, Student.StudentName
having sum(Result.Mark) > 10



-- 7) Views
---- Create a view named view_StudentSubjectMark which should show result of each student by
------ each subject, with information of: StudentId, StudentName, SubjectName, Mark.
create view view_StudentSubjectMark
as
select top(3) Student.StudentId, Student.StudentName, Subject.SubjectName, Result.Mark
from Student left join Result on Student.StudentId = Result.StudentId
	left join Subject on Result.SubjectId = Subject.SubjectId
order by Result.Mark desc

select * from view_StudentSubjectMark




-- 8) Proc
---- Create a procedure named up_IncreaseMark, with input parameters:
create proc up_IncreaseMark
	@subjectId int
as
begin
	update Result set Mark = Mark + 1 where SubjectId = @subjectId
end

select * from Result
exec up_IncreaseMark 2
select * from Result









Đăng nhập để làm bài kiểm tra

Chưa có kết quả nào trước đó

×