IT Learning HubIT Learning Hub
SHARED SCHEMA · IT004

Academic Affairs Management Database

8 relationsBTTH4

A schema for managing classes, teachers, courses, and exam results at a training center. Read the definitions and attribute tables carefully before starting - understanding what the data actually means makes writing accurate queries far easier than just memorizing column names.

OVERVIEW

The academic affairs management database consists of the following relations

HOCVIEN (MAHV, HO, TEN, NGSINH, GIOITINH, NOISINH, MALOP)

Definition: Each student is distinguished by a student ID, and has a recorded name, date of birth, gender, place of birth, and the class they belong to.

LOP (MALOP, TENLOP, TRGLOP, SISO, MAGVCN)

Definition: Each class has a class code, class name, the student who serves as class monitor, class size, and a homeroom teacher.

KHOA (MAKHOA, TENKHOA, NGTLAP, TRGKHOA)

Definition: Each department records a department code, department name, founding date, and department head (who is also a teacher belonging to the department).

MONHOC (MAMH, TENMH, TCLT, TCTH, MAKHOA)

Definition: Each course records a course name, number of theory credits, number of practical credits, and which department is responsible for it.

DIEUKIEN (MAMH, MAMH_TRUOC)

Definition: Some courses require students to already have knowledge from certain prerequisite courses.

GIAOVIEN (MAGV, HOTEN, HOCVI, HOCHAM, GIOITINH, NGSINH, NGVL, HESO, MUCLUONG, MAKHOA)

Definition: A teacher ID distinguishes between teachers; each record also stores name, degree, academic title, gender, date of birth, hire date, salary coefficient, salary amount, and the department they belong to.

GIANGDAY (MALOP, MAMH, MAGV, HOCKY, NAM, TUNGAY, DENNGAY)

Definition: Each semester of the academic year has teaching assignments: which class takes which course, taught by which teacher.

KETQUATHI (MAHV, MAMH, LANTHI, NGTHI, DIEM, KQUA)

Definition: Stores students' exam results: which student took which course exam, which attempt number, the exam date, the score, and whether the result was a pass or fail.

Relationship Diagram

KHOA LOP GIAOVIEN MONHOC HOCVIEN GIANGDAY DIEUKIEN KETQUATHI

Relationship Description

KHOA ➜ GIAOVIEN (via TRGKHOA): each department has 1 department head, who is a teacher.

GIAOVIEN ➜ KHOA (via MAKHOA): each teacher belongs to exactly 1 department.

MONHOC ➜ KHOA (via MAKHOA): each course is managed by 1 department.

DIEUKIEN ➜ MONHOC (via MAMH and MAMH_TRUOC): each prerequisite row links 2 courses together - the course and the one that must be taken first.

LOP ➜ HOCVIEN (via TRGLOP): each class has 1 class monitor, who is a student of that same class.

HOCVIEN ➜ LOP (via MALOP): each student belongs to exactly 1 class.

LOP ➜ GIAOVIEN (via MAGVCN): each class has 1 homeroom teacher.

GIANGDAY ➜ LOP, MONHOC, GIAOVIEN: each teaching assignment records which class takes which course, taught by which teacher.

KETQUATHI ➜ HOCVIEN, MONHOC: each exam result is tied to 1 specific student and 1 specific course.

Common mix-up: KHOA.TRGKHOA and GIAOVIEN.MAKHOA reference each other in both directions (a department has 1 department head, a teacher belongs to 1 department) - the same is true of LOP.TRGLOP and HOCVIEN.MALOP. In the sample data, department KTMT doesn't have a department head yet (TRGKHOA is NULL).

RELATION 1 · HOCVIEN

HOCVIEN

Each student is distinguished by a student ID, with a recorded name, date of birth, gender, place of birth, and which class they belong to.
AttributeData typeDescription
MAHVchar(5)Student ID - primary key
HOvarchar(40)Family name and middle name
TENvarchar(10)Given name
NGSINHsmalldatetimeDate of birth
GIOITINHvarchar(3)Gender
NOISINHvarchar(40)Place of birth
MALOPchar(3)Class code - foreign key to LOP

SAMPLE DATA (all 35 students)

MAHVHOTENNGSINHGIOITINHNOISINHMALOP
K1101Nguyen VanA27/1/1986NamTpHCMK11
K1102Tran NgocHan14/3/1986NuKien GiangK11
K1103Ha DuyLap18/4/1986NamNghe AnK11
K1104Tran NgocLinh30/3/1986NuTay NinhK11
K1105Tran MinhLong27/2/1986NamTpHCMK11
K1106Le NhatMinh24/1/1986NamTpHCMK11
K1107Nguyen NhuNhut27/1/1986NamHa NoiK11
K1108Nguyen ManhTam27/2/1986NamKien GiangK11
K1109Phan Thi ThanhTam27/1/1986NuVinh LongK11
K1110Le HoaiThuong02/05/1986NuCan ThoK11
K1111Le HaVinh25/12/1986NamVinh LongK11
K1201Nguyen VanB02/11/1986NamTpHCMK12
K1202Nguyen Thi KimDuyen18/1/1986NuTpHCMK12
K1203Tran Thi KimDuyen17/9/1986NuTpHCMK12
K1204Truong MyHanh19/5/1986NuDong NaiK12
K1205Nguyen ThanhNam17/4/1986NamTpHCMK12
K1206Nguyen Thi TrucThanh03/04/1986NuKien GiangK12
K1207Tran Thi BichThuy02/08/1986NuNghe AnK12
MAHVHOTENNGSINHGIOITINHNOISINHMALOP
K1208Huynh Thi KimTrieu04/08/1986NuTay NinhK12
K1209Pham ThanhTrieu23/2/1986NamTpHCMK12
K1210Ngo ThanhTuan14/2/1986NamTpHCMK12
K1211Do ThiXuan03/09/1986NuHa NoiK12
K1212Le Thi PhiYen03/12/1986NuTpHCMK12
K1301Nguyen Thi KimCuc06/09/1986NuKien GiangK13
K1302Truong Thi MyHien18/3/1986NuNghe AnK13
K1303Le DucHien21/3/1986NamTay NinhK13
K1304Le QuangHien18/4/1986NamTpHCMK13
K1305Le ThiHuong27/3/1986NuTpHCMK13
K1306Nguyen ThaiHuu30/3/1986NamHa NoiK13
K1307Tran MinhMan28/5/1986NamTpHCMK13
K1308Nguyen HieuNghia04/08/1986NamKien GiangK13
K1309Nguyen TrungNghia18/1/1987NamNghe AnK13
K1310Tran Thi HongTham22/4/1986NuTay NinhK13
K1311Tran MinhThuc04/04/1986NamTpHCMK13
K1312Nguyen Thi KimYen09/07/1986NuTpHCMK13

RELATION 2 · LOP

LOP

Each class has a class code, class name, the student who serves as class monitor, class size, and a homeroom teacher.
AttributeData typeDescription
MALOPchar(3)Class code - primary key
TENLOPvarchar(40)Class name
TRGLOPchar(5)Class monitor - foreign key to HOCVIEN
SISOtinyintClass size
MAGVCNchar(4)Homeroom teacher - foreign key to GIAOVIEN

SAMPLE DATA (all 3 classes)

MALOPTENLOPTRGLOPSISOMAGVCN
K11Lop 1 khoa 1K110811GV07
K12Lop 2 khoa 1K120512GV09
K13Lop 3 khoa 1K130512GV14

RELATION 3 · KHOA

KHOA

Each department records a department code, department name, founding date, and department head (who is also a teacher belonging to the department).
AttributeData typeDescription
MAKHOAchar(4)Department code - primary key
TENKHOAvarchar(40)Department name
NGTLAPsmalldatetimeDepartment founding date
TRGKHOAchar(4)Department head - foreign key to GIAOVIEN, can be NULL

SAMPLE DATA (all 5 departments)

MAKHOATENKHOANGTLAPTRGKHOA
KHMTKhoa hoc may tinh06/07/2005GV01
HTTTHe thong thong tin06/07/2005GV02
CNPMCong nghe phan mem06/07/2005GV04
MTTMang va truyen thong20/10/2005GV03
KTMTKy thuat may tinh20/12/2005NULL

RELATION 4 · MONHOC

MONHOC

Each course records a course name, number of theory credits, number of practical credits, and which department is responsible for it.
AttributeData typeDescription
MAMHchar(10)Course code - primary key
TENMHvarchar(40)Course name
TCLTtinyintNumber of theory credits
TCTHtinyintNumber of practical credits
MAKHOAchar(4)Which department the course belongs to - foreign key to KHOA

SAMPLE DATA (all 13 courses)

MAMHTENMHTCLTTCTHMAKHOA
THDCTin hoc dai cuong41KHMT
CTRRCau truc roi rac50KHMT
CSDLCo so du lieu31HTTT
CTDLGTCau truc du lieu va giai thuat31KHMT
PTTKTTPhan tich thiet ke thuat toan30KHMT
DHMTDo hoa may tinh31KHMT
KTMTKien truc may tinh30KTMT
TKCSDLThiet ke co so du lieu31HTTT
PTTKHTTTPhan tich thiet ke he thong thong tin41HTTT
HDHHe dieu hanh40KTMT
NMCNPMNhap mon cong nghe phan mem30CNPM
LTCFWLap trinh C for win31CNPM
LTHDTLap trinh huong doi tuong31CNPM

RELATION 5 · DIEUKIEN

DIEUKIEN

Some courses require students to already have knowledge from certain prerequisite courses. The primary key is the pair (MAMH, MAMH_TRUOC).
AttributeData typeDescription
MAMHchar(10)Course code - primary key, foreign key to MONHOC
MAMH_TRUOCchar(10)Prerequisite course code - primary key, foreign key to MONHOC

SAMPLE DATA (all 8 rows)

MAMHMAMH_TRUOC
CSDLCTRR
CSDLCTDLGT
CTDLGTTHDC
PTTKTTTHDC
PTTKTTCTDLGT
DHMTTHDC
LTHDTTHDC
PTTKHTTTCSDL

RELATION 6 · GIAOVIEN

GIAOVIEN

A teacher ID distinguishes between teachers; each record also stores name, degree, academic title, gender, date of birth, hire date, salary coefficient, salary amount, and the department the teacher belongs to.
AttributeData typeDescription
MAGVchar(4)Teacher ID - primary key
HOTENvarchar(40)Full name
HOCVIvarchar(10)Degree (CN, KS, ThS, TS, PTS...)
HOCHAMvarchar(10)Academic title (GV, PGS, GS...), can be NULL
GIOITINHvarchar(3)Gender
NGSINHsmalldatetimeDate of birth
NGVLsmalldatetimeHire date
HESOnumeric(4,2)Salary coefficient
MUCLUONGmoneySalary amount
MAKHOAchar(4)Which department - foreign key to KHOA

SAMPLE DATA (all 15 teachers)

MAGVHOTENHOCVIHOCHAMGIOITINHNGSINHNGVLHESOMUCLUONGMAKHOA
GV01Ho Thanh SonPTSGSNam05/02/195001/11/200452.250.000KHMT
GV02Tran Tam ThanhTSPGSNam17/12/196520/4/20044.52.025.000HTTT
GV03Do Nghiem PhungTSGSNu08/01/195023/9/200441.800.000CNPM
GV04Tran Nam SonTSPGSNam22/2/196101/12/20054.52.025.000KTMT
GV05Mai Thanh DanhThSGVNam03/12/195801/12/200531.350.000HTTT
GV06Tran Doan HungTSGVNam03/11/195301/12/20054.52.025.000KHMT
GV07Nguyen Minh TienThSGVNam23/11/197103/01/200541.800.000KHMT
GV08Le Thi TranKSNULLNu26/3/197403/01/20051.69760.500KHMT
GV09Nguyen To LanThSGVNu31/12/196603/01/200541.800.000HTTT
GV10Le Tran Anh LoanKSNULLNu17/7/197203/01/20051.86837.000CNPM
GV11Ho Thanh TungCNGVNam01/12/198015/5/20052.671.201.500MTT
GV12Tran Van AnhCNNULLNu29/3/198115/5/20051.69760.500CNPM
GV13Nguyen Linh DanCNNULLNu23/5/198015/5/20051.69760.500KTMT
GV14Truong Minh ChauThSGVNu30/11/197615/5/200531.350.000MTT
GV15Le Ha ThanhThSGVNam05/04/197815/5/200531.350.000KHMT

RELATION 7 · GIANGDAY

GIANGDAY

Each semester of the academic year has teaching assignments: which class takes which course, taught by which teacher. The primary key is the pair (MALOP, MAMH).
AttributeData typeDescription
MALOPchar(3)Class code - primary key, foreign key to LOP
MAMHchar(10)Course code - primary key, foreign key to MONHOC
MAGVchar(4)Teacher in charge - foreign key to GIAOVIEN
HOCKYtinyintSemester
NAMsmallintAcademic year
TUNGAYsmalldatetimeCourse start date
DENNGAYsmalldatetimeCourse end date

SAMPLE DATA (all 16 rows)

MALOPMAMHMAGVHOCKYNAMTUNGAYDENNGAY
K11THDCGV071200601/02/200605/12/2006
K12THDCGV061200601/02/200605/12/2006
K13THDCGV151200601/02/200605/12/2006
K11CTRRGV021200609/01/200617/5/2006
K12CTRRGV021200609/01/200617/5/2006
K13CTRRGV081200609/01/200617/5/2006
K11CSDLGV052200606/01/200615/7/2006
K12CSDLGV092200606/01/200615/7/2006
K13CTDLGTGV152200606/01/200615/7/2006
K13CSDLGV053200608/01/200615/12/2006
K13DHMTGV073200608/01/200615/12/2006
K11CTDLGTGV153200608/01/200615/12/2006
K12CTDLGTGV153200608/01/200615/12/2006
K11HDHGV041200701/02/200718/2/2007
K12HDHGV041200701/02/200720/3/2007
K11DHMTGV071200718/2/200720/3/2007

RELATION 8 · KETQUATHI

KETQUATHI

Stores students' exam results: which student took which course exam, which attempt number, the exam date, the score, and whether the result was a pass or fail. The primary key is the triple (MAHV, MAMH, LANTHI).
AttributeData typeDescription
MAHVchar(5)Student ID - primary key, foreign key to HOCVIEN
MAMHchar(10)Course code - primary key, foreign key to MONHOC
LANTHItinyintAttempt number - primary key
NGTHIsmalldatetimeExam date
DIEMnumeric(4,2)Score
KQUAvarchar(10)Result (Dat / Khong Dat)

SAMPLE DATA (all 66 rows)

MAHVMAMHLANTHINGTHIDIEMKQUA
K1101CSDL120/7/200610Dat
K1101CTDLGT128/12/20069Dat
K1101THDC120/5/20069Dat
K1101CTRR113/5/20069.5Dat
K1102CSDL120/7/20064Khong Dat
K1102CSDL227/7/20064.25Khong Dat
K1102CSDL308/10/20064.5Khong Dat
K1102CTDLGT128/12/20064.5Khong Dat
K1102CTDLGT201/05/20074Khong Dat
K1102CTDLGT315/1/20076Dat
K1102THDC120/5/20065Dat
K1102CTRR113/5/20067Dat
K1103CSDL120/7/20063.5Khong Dat
K1103CSDL227/7/20068.25Dat
K1103CTDLGT128/12/20067Dat
K1103THDC120/5/20068Dat
K1103CTRR113/5/20066.5Dat
K1104CSDL120/7/20063.75Khong Dat
K1104CTDLGT128/12/20064Khong Dat
K1104THDC120/5/20064Khong Dat
K1104CTRR113/5/20064Khong Dat
K1104CTRR220/5/20063.5Khong Dat
MAHVMAMHLANTHINGTHIDIEMKQUA
K1104CTRR330/6/20064Khong Dat
K1201CSDL120/7/20066Dat
K1201CTDLGT128/12/20065Dat
K1201THDC120/5/20068.5Dat
K1201CTRR113/5/20069Dat
K1202CSDL120/7/20068Dat
K1202CTDLGT128/12/20064Khong Dat
K1202CTDLGT201/05/20075Dat
K1202THDC120/5/20064Khong Dat
K1202THDC227/5/20064Khong Dat
K1202CTRR113/5/20063Khong Dat
K1202CTRR220/5/20064Khong Dat
K1202CTRR330/6/20066.25Dat
K1203CSDL120/7/20069.25Dat
K1203CTDLGT128/12/20069.5Dat
K1203THDC120/5/200610Dat
K1203CTRR113/5/200610Dat
K1204CSDL120/7/20068.5Dat
K1204CTDLGT128/12/20066.75Dat
K1204THDC120/5/20064Khong Dat
K1204CTRR113/5/20066Dat
K1301CSDL120/12/20064.25Khong Dat
MAHVMAMHLANTHINGTHIDIEMKQUA
K1301CTDLGT125/7/20068Dat
K1301THDC120/5/20067.75Dat
K1301CTRR113/5/20068Dat
K1302CSDL120/12/20066.75Dat
K1302CTDLGT125/7/20065Dat
K1302THDC120/5/20068Dat
K1302CTRR113/5/20068.5Dat
K1303CSDL120/12/20064Khong Dat
K1303CTDLGT125/7/20064.5Khong Dat
K1303CTDLGT208/07/20064Khong Dat
K1303CTDLGT315/8/20064.25Khong Dat
K1303THDC120/5/20064.5Khong Dat
K1303CTRR113/5/20063.25Khong Dat
K1303CTRR220/5/20065Dat
K1304CSDL120/12/20067.75Dat
K1304CTDLGT125/7/20069.75Dat
K1304THDC120/5/20065.5Dat
K1304CTRR113/5/20065Dat
K1305CSDL120/12/20069.25Dat
K1305CTDLGT125/7/200610Dat
K1305THDC120/5/20068Dat
K1305CTRR113/5/200610Dat

FULL SCRIPT

Create the database and load sample data

A script that creates the QUANLIGIAOVU_2026 database, creates 8 tables with primary/foreign keys, and loads the full set of sample data (5 departments, 3 classes, 13 courses, 8 prerequisites, 15 teachers, 35 students, 16 teaching assignments, 66 exam results). Run it directly in SSMS before starting the exercises.

Academic Affairs Database Script (QUANLIGIAOVU_2026) .sql file · creates tables, constraints, and the full sample data
Download ↓
Applies to: BTTH4 (Week 4) - Part I questions 1, 3-8, 11-14 · Part II questions 1-4 · Part III questions 1-24 all share this schema; you only need to run the script once.