Steps in process
Take the entity class diagram in the design phase as the input, and then process through five following steps:
- Step 1: For each entity class, create a corresponding table. The table name should have the prefix “tbl” (table) + the name of the entity class. For example, from an entity class Room, the corresponding table should be tblRoom.
- Step 2: For each entity class, transfer all NON-OBJECT attributes to contribute as the columns of the corresponding table. For example, in the class Hotel, the attribute listRoom has a type of Room[] is a OBJECT attribute, so it will be removed, the remain attributes (id, name, starLevel, address, description) will play the columns of the tblHotel.
- Step 3: Consider the quantity relationships among entity classes. These relationships will be those among corresponding tables:
- If a relationship is 1-1 then the two related tables should be regrouped into one. However, in some particular situation, the two related tables could be skipped separated.
- If a relationship is 1-n then the two related tables should be separated.
- If a relationship is n-n then it should create some intermediate tables to break the n-n relationship into two or more relationships of type 1-n (It should back to analyze phase to correct this relationship).
- Step 4: Config the key columns for tables:
- Khóa chính (Primary key – PK): Bảng nào có thuộc tính id thì thiết lập thuộc tính đó làm khóa chính cho bảng.
- Khóa ngoại (Foreinger key – FK): Nếu hai bảng tblA và tblB có quan hệ 1-n (1 tblA có n tblB), thì trong bảng tblB phải có khóa ngoài tham chiếu đến khóa chính của bảng tblA. Khó ngoại có thể đặt tên là aId hoặc idA.
- Step 5: Loại bỏ các thuộc tính gây dư thừa dữ liệu. Có hai loại thuộc tính gây dư thừa dữ liệu:
- Thuộc tính bị trùng lặp: thường là thuộc tính của cùng một đối tượng, không phải thuộc tính khóa, nhưng xuất hiện ở hai bảng khác nhau.
- Thuộc tính dẫn xuất: là thuộc tính có thể tính toán cơ học từ các thuộc tính khác trong CSDL. Ví dụ một số thuộc tính xuất thân từ các lớp thực thể thống kê thì thường là thuộc tính dẫn xuất. Sau khi loại bỏ các thuộc tính dư thừa, nếu xuất hiện bảng nào không còn thuộc tính nào nữa ngoài 1 khóa ngoại thì có thể loại bỏ luôn bảng đấy.
Applying
Input is the entity class diagram from the design phase:

Step 1
Mỗi lớp thực thể đề xuất bảng tương ứng:
- Lớp Truong -> bảng tblTruong
- Lớp Khoa -> bảng tblKhoa
- Lớp Toanha -> bảng tblToanha
- ….
Step 2
Đưa thuộc tính không phải đối tượng của lớp thực thể thành thuộc tính của bảng tương ứng:
- tblTruong có các thuộc tính: id, tên, mô tả
- tblKhoa: id, tên, mô tả
- tblToanha: id, tên, mô tả
- ….
Step 3
Chuyến quan hệ số lượng giữa các lớp thực thể thành quan hệ số lượng giữa các bảng:
- 1 tblTruong – n tblKhoa
- 1 tblTruong – n tblToanha
- 1 tblToanha – n tblPhonghoc
- ….
Step 4
Bổ sung các thuộc tính khóa. Khóa chính được thiết lập với thuộc tính id của các bảng tương ứng: trừ các bảng tblTK, tblSinhvien, tblThanhvien, tblGiangvien, tblNVQuanli, tblNVKhaothi, tblGiaovu.
Khóa ngoại được thiết lập cho các bảng:
- 1 tblTruong – n tblKhoa -> bảng tblKhoa có khóa ngoại tblTruongid
- 1 tblTruong – n tblToanha -> bảng tblToanha có khóa ngoại tblTruongid
- 1 tblToanha – n tblPhonghoc -> bảng tblPhonghoc có khóa ngoại tblToanhaid
- ….
Step 5
Các thuộc tính dẫn xuất:
- điểm TBM, điểm TB chữ trong bảng tblDangkihoc
- Các thuộc tính của các lớp thống kê -> loại bỏ hết các bảng thống kê.
Kết quả thu được CSDL toàn hệ thống.
