Bai Lien Ket
Bai Lien Ket
Bài 1)
1)
Customer(customer_ID,customer_name,customer_address,customer_phone
)
Car(car_ID, license_plate, model, year, customer_ID)
Accident(accident_ID, accident_date, accident_description, car_ID)
Insurance_Policy(policy_ID, policy_start_date, policy_end_date,
customer_ID)
Car_Policy(car_policy_ID, car_ID, policy_ID)
Payment(payment_ID, payment_due_date, payment_received_date, amount,
policy_ID)
2)
A) Quan hệ ba chiều
Student(student_ID, student_name, student_email, student_phone, ...)
Course(_course_ID_, course_name, course_description, ...)
Section(_section_ID_, _course_ID_, semester, year, ...)
Exam(_exam_ID_, exam_name, exam_date, ...)
Marks(_student_ID_, _section_ID_,_exam_ID_, marks)
3)
Team(_team_ID_, team_name, coach_name, ... )
Match(_match_ID_, match_date, location, opponent_team_ID, score)
Player(_player_ID_, player_name, position, team_ID, ...)
Participated_In(_player_ID_, _match_ID_, player_score, minutes_played)
Plays_For(_player_ID_, _team_ID_)
4)
Patient(_patient_ID_, patient_name, patient_age, patient_address,
patient_phone, ...)
Doctor(_doctor_ID_, doctor_name, specialty, phone, ...)
Patient_Test(_patient_ID_, _test_ID_)
Patient_Examination(_patient_ID_, _examination_ID_)
5)
Brand(_brand_ID_, brand_name, country, ...)
Model(_model_ID_, model_name, _brand_ID_, ...)
Option(_option_ID_, option_name, description, ...)
6)
Customer(_customer_ID_, customer_name, customer_address, customer_phone, ...)
Package(_package_ID_, package_weight, package_dimensions, shipping_date,
delivery_date, status)
Location(_location_ID_, location_type, location_name, location_address, ...)
2)
3)
Tên trong trường hợp này có thể sử dụng làm siêu khóa
4) Mỗi instructor đều liên kết với một môn bảng dept_name
VD về lỗi vi phạm ràng buộc khóa ngoại:
Nhìn trg bảng dept_name có môn ‘Physic’ liên kết với 2
instructor có ID 22222 và 33456
Nếu chúng ta xóa ‘Physic’ ra khỏi bảng dept_name mà k xử lí
các bản ghi liên quan sẽ gây ra lỗi ràng buộc khóa ngoại vì
các giảng viên có dept_name = 'Physics' trong bảng instructor
không còn phòng ban tham chiếu, gây ra vi phạm khóa ngoại.