You are on page 1of 2

Student Score Management

The test must be saved in the file ‘hoten - test2.sql’ in the unicode form. Where hoten is
the full name of the test taker, for example ‘Nguyen Van An - test2.sql’
The test file must be compressed into ‘hoten - test2.zip’ or ‘hoten - test2.rar’ before being
attached into Yahoo mail (for the reason of inline attachment).

Create tables and input data


1. Create the table MonHoc
MaMon TenMon SoTiet
int nvarchar(50) int
1 Word 30
2 Excel 60
3 Access 80
4 C programming 60
5 HTML 30
6 ASP programming 30

2. Create the table SinhVien


MaSV TenSV NamSinh ThuDienTu
int nvarchar(70) smallint char(100)
1 Nguyễn Hoàng Anh 1980 nhanh@yahoo.com
2 Trần Hạo Bình 1980 trhbinh@gmail.com
3 Trương Bảo Thu 1982 truongbaothu@hotmail.com
4 Hứa Quảng Hà 1990 huaquangha@gmail.com
5 Bành Ðại Kiện 1978 truongdaikien@hotmail.com
6 Quách Ðại Lộ 1980 quachdailo@yahoo.com
7 Trương Tiểu Hướng 1983 trtieuhuong@gmail.com
8 Sái Văn Cơ 1980 svc@gmail.com
9 Phạm Thời Bình 1980 phtb@gmail.com

3. Create the table Diem


MaSV MaMH NgayThi DiemThi
int int datetime int
1 1 '12/31/2005' 9
1 1 '11/20/2005' 3
1 3 '4/17/2005' 8
1 2 '4/13/2005' 8
2 3 '5/25/2005' 9
2 3 '5/25/2003' 9
9 5 '10/20/2003' 8
8 5 '4/25/2008' 6
5 3 '8/21/2005' 7

1
Apply constraints to tables
4. Apply the referential constraint from Diem(MaSV) to SinhVien(MaSV)
5. Apply the referential constraint from Diem(MaMH) to MonHoc(MaMon)
6. Apply the check constraint that DiemThi must be between 0 and 10

Create index
7. Create the index idxTheoTen for the table SinhVien on the field TenSV
8. Create the index idxTheoTenMon for the table MonHoc on the field TenMon

Create view
9. Create the view SinhVienChuaThi that displays all students that do not appear in the
table Diem
10. Create the view SinhVienChuaThiHTML that displays all students that do not take
the exam on the subject HTML

Create stored procedure


11. Create the stored procedure XemDiemCuaSV that displays all the scores of the
student @x. in which @x is an integer parameter of the procedure XemDiemCuaSV
12. Create the stored procedure CapNhatDiem @ten, @mon, @diem, @ngay that insert a
record into the table Diem.
For example, the call exec CapNhatDiem N'Nguyễn Hoàng Anh', 'Word', 8,
'12/31/2005'
is equivalent to the statement insert into Diem values(1, 1, '12/31/2005', 8)

Create trigger
13. Create the trigger KiemTraNgayThang that fires whenever the test date (NgayThi) of
the inserted record is greater than the current date

14. Create the trigger KiemTraHomThu that fires whenever the email (ThuDienTu) of the
inserted recored is not of the email format.

You might also like