Skip to content

260611#2

Merged
Tynab merged 1 commit into
mainfrom
develop
Jun 11, 2026
Merged

260611#2
Tynab merged 1 commit into
mainfrom
develop

Conversation

@Tynab

@Tynab Tynab commented Jun 11, 2026

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings June 11, 2026 16:50
@Tynab
Tynab merged commit 1acd639 into main Jun 11, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Cập nhật đồng loạt các bài tập SQL theo hướng “script chạy lại được” và chuẩn hóa mô hình quan hệ/kiểu dữ liệu cho các database bài tập (baitap1, baitap2, baitapcrm, baitaptonghop, qlbansach), đồng thời viết lại README hướng dẫn chạy theo thứ tự.

Changes:

  • Chuẩn hóa schema: đưa khóa ngoại vào CREATE TABLE, điều chỉnh lại một số quan hệ (vd: hóa đơn/đơn hàng → khách hàng; sách ↔ tác giả qua bảng trung gian; ghế → rạp/loại ghế).
  • Chuẩn hóa cách chạy script: thêm CREATE DATABASE IF NOT EXISTS + USE, seed data theo ON DUPLICATE KEY UPDATE, chuẩn hóa literal string dùng nháy đơn.
  • Cập nhật truy vấn tổng hợp và README (thứ tự SOURCE, alias rõ ràng, điều kiện lọc khớp dữ liệu mẫu).

Reviewed changes

Copilot reviewed 33 out of 33 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
README.md Mô tả repo, tổng hợp thay đổi, và thứ tự chạy SOURCE cho từng bài
exercise_1/student.sql Tạo DB/bảng students + seed idempotent bằng ON DUPLICATE KEY UPDATE
exercise_1/baitap1.sql Chuẩn hóa truy vấn (chọn cột tường minh, nháy đơn, IN, ORDER BY)
exercise_2/khachhang.sql Tạo DB/bảng khách hàng + seed idempotent
exercise_2/loaisanpham.sql Tạo danh mục loại sản phẩm + seed idempotent
exercise_2/sanpham.sql Chuẩn hóa sản phẩm tham chiếu loại sản phẩm + giá dùng DECIMAL
exercise_2/hoadon.sql Hóa đơn trỏ về khách hàng bằng FK + seed idempotent
exercise_2/chitiethoadon.sql Chi tiết hóa đơn có FK tới hóa đơn/sản phẩm + giá DECIMAL
exercise_2/baitap2.sql Sửa join theo FK mới, bổ sung alias/fields báo cáo
exercise_crm/baitapcrm.sql Khởi tạo DB baitapcrm + hướng dẫn thứ tự chạy
exercise_crm/groups.sql Tạo bảng nhóm CRM + seed idempotent
exercise_crm/accountscrm.sql Tạo bảng tài khoản CRM + seed idempotent
exercise_crm/status.sql Tạo bảng trạng thái task + seed idempotent
exercise_crm/tasks.sql Chuẩn hóa tasks: thêm FK tới group/account/status; end_date dùng DATE
exercise_summary/cumrap.sql Tạo cụm rạp + seed idempotent
exercise_summary/rap.sql Rạp trỏ về cụm rạp bằng FK + seed idempotent
exercise_summary/loaighe.sql Tạo loại ghế + seed idempotent
exercise_summary/ghe.sql Ghế trỏ về rạp/loại ghế bằng FK + seed idempotent
exercise_summary/phim.sql Tạo bảng phim + seed idempotent
exercise_summary/chitietphim.sql Lịch chiếu (rap, phim) + giá vé DECIMAL + seed idempotent
exercise_summary/loainguoidung.sql Danh mục loại người dùng + seed idempotent
exercise_summary/nguoidung.sql Người dùng trỏ về loại người dùng bằng FK + seed idempotent (MD5 minh họa)
exercise_summary/datve.sql Đặt vé với PK ghép + các FK + giá vé DECIMAL + seed idempotent
exercise_summary/baitaptonghop.sql Sửa truy vấn tổng hợp theo schema mới, alias rõ ràng, nháy đơn
bai_tap_nop/chude.sql Tạo chủ đề sách + seed idempotent
bai_tap_nop/nhaxuatban.sql Tạo nhà xuất bản + seed idempotent
bai_tap_nop/tacgia.sql Tạo tác giả + seed idempotent
bai_tap_nop/sach.sql Sách trỏ về NXB/chủ đề bằng FK; giá DECIMAL; bỏ tác giả trực tiếp
bai_tap_nop/khachhang.sql Khách hàng qlbansach + seed idempotent (MD5 minh họa)
bai_tap_nop/donhang.sql Đơn hàng trỏ về khách hàng bằng FK + seed idempotent
bai_tap_nop/chitiettacgia.sql Bảng trung gian sách–tác giả (N-N) + seed idempotent
bai_tap_nop/chitietdonhang.sql Chi tiết đơn hàng có FK tới sách/đơn hàng + giá DECIMAL
bai_tap_nop/qlbansach.sql Sửa truy vấn tổng hợp theo quan hệ mới (join qua chitiettacgia)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +18 to +21
CONSTRAINT fk_datve_rap
FOREIGN KEY (ma_rap) REFERENCES rap(ma),
CONSTRAINT fk_datve_phim
FOREIGN KEY (ma_phim) REFERENCES phim(ma),
Comment on lines 12 to +14
mo_ta NVARCHAR(255),
chiet_khau FLOAT,
PRIMARY KEY(ma)
PRIMARY KEY (ma)
ngay_dat DATE,
gia_ve INT,
gia_ve DECIMAL(12, 2),
chiet_khau FLOAT,
Comment thread README.md
- Chuẩn hóa một số quan hệ: hóa đơn/đơn hàng trỏ về khách hàng, sản phẩm trỏ về loại sản phẩm, ghế trỏ về rạp và loại ghế, sách nối tác giả qua bảng trung gian.
- Chuẩn hóa kiểu dữ liệu: cột tiền dùng `DECIMAL(12, 2)`, cột đúng/sai dùng `BOOLEAN`, khóa số tự tăng dùng `INT`.
- Đổi chuỗi SQL sang dấu nháy đơn để tránh phụ thuộc cấu hình `ANSI_QUOTES`.
- Dữ liệu mẫu dùng `ON DUPLICATE KEY UPDATE` để có thể chạy lại mà không nhân bản bản ghi.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants