Khoá học lập trình SQL [Examination] Quản lý sản phẩm - Lập trình SQL Server
- 5.0/5.0
- 2k Đăng ký
- Học lập trình
- Tiếng việt
Thông tin khóa học
Part 1: Database Creation
Create a database named
ProductManagementSystem.Switch the current context to use the
ProductManagementSystemdatabase.
Part 2: Table Creation
Create the following four tables with the specified data types and constraints:
1. tblUser (Stores user information)
| Column | Datatype | Constraint |
| UserID | INT | NOT NULL |
| UserName | NVARCHAR(50) |
2. tblOrder (Stores order information)
| Column | Datatype | Constraint |
| OrderID | INT | NOT NULL |
| UserID | INT | NOT NULL |
| OrderDate | DATETIME |
3. tblProduct (Stores product information)
| Column | Datatype | Constraint |
| ProductID | INT | NOT NULL |
| ProductName | NVARCHAR(50) | |
| Quantity | INT | |
| Price | MONEY | |
| Description | NTEXT |
4. tblOrderDetail (Stores line items for orders)
| Column | Datatype | Constraint |
| OrderID | INT | NOT NULL |
| ProductID | INT | NOT NULL |
| Quantity | INT | |
| Price | MONEY |
Part 3: Indexing and Table Modification
Create Index: Create a Clustered Index named
CI_tblUser_UserIDon theUserIDcolumn of thetblUsertable.Drop Index: Remove the clustered index
CI_tblUser_UserIDthat you just created.Modify Table: Alter the
tblUsertable to add a new column namedBirthDatewith theDATETIMEdatatype.
Part 4: Constraints
Implement the following constraints to ensure data integrity:
Primary Keys:
PK_tblUser:UserIDintblUserPK_tblOrder:OrderIDintblOrderPK_tblProduct:ProductIDintblProductPK_tblOrderDetail: Composite key of (OrderID,ProductID) intblOrderDetail
Foreign Keys:
FK_tblOrder_tblUser:UserIDintblOrderreferencingUserIDintblUser.FK_tblOrderDetail_tblOrder:OrderIDintblOrderDetailreferencingOrderIDintblOrder.FK_tblOrderDetail_tblProduct:ProductIDintblOrderDetailreferencingProductIDintblProduct.
Default: Set a default value of
GETDATE()for theOrderDatecolumn intblOrder.Check: Ensure
OrderDateintblOrderis between'2000-01-01'and the current date.Unique: Ensure the
UserNameintblUseris unique.
Part 5: Data Insertion
Populate the tables with the records provided in the sample data tables (refer to original images for specific names and dates for Users, Orders, Products, and OrderDetails).
Part 6: Query Operations
Update: Apply a 10% discount to the
Priceof all records intblProductwhere theProductIDis 3.Select: Display records from all four tables joined together, including:
UserID,UserName,OrderID,OrderDate,Quantity,Price, andProductName.
Part 7: Views
Create a view named
view_Top2Productto display the top 2 best-selling products based on the total quantity sold. The view should show:ProductID,ProductName,Price, andTotalQuantity.
Part 8: Stored Procedures
Create a procedure named
sp_TimSanPhamwith the following parameters:@GiaMua(MONEY): The maximum price to filter products.@count(INT, OUTPUT): To return the total number of records found.
The procedure should return a list of products where
Price <= @GiaMuaand print the count of products found.Execute the procedure with
@GiaMua = 50.
Part 9: Triggers
Trigger 1: Create
TG_tblProduct_Updateon thetblProducttable forUPDATEevents. If the updatedPriceis less than 10, the update should fail, roll back, and print the message: "You don’t update price less than 10!"Drop Trigger: Drop the
TG_tblProduct_Updatetrigger.Trigger 2: Create
TG_tblUser_Updateon thetblUsertable forUPDATEevents. If a user attempts to modify theUserNamecolumn, the update should fail and print: "You don’t update this column UserName!"
Đăng nhập để làm bài kiểm tra
Chưa có kết quả nào trước đó
Chương trình
Nguyễn Văn An
Trần Thị Bích
Lê Hoàng Hải
Phạm Minh Tuấn
Đánh giá
B2. Đăng ký học
B3. Hoàn thành mua khoá học
B4. Thanh toán theo hướng dẫn
B5. Đợi chúng tôi kiểm tra thông tin và thêm bạn vào lớp học
Bước 1: Truy cập website https://gozic.vn/teacher/form
Bước 2: Điền thông tin theo yêu cầu. Để bản đăng ký được duyệt nhanh nhất, anh chị hãy điền đủ thông tin nhé.
Bước 3: Click vào "đăng ký ngay" để hoàn thành
Lưu ý:
Link video bài giảng mẫu: Video bài giảng mẫu là căn cứ để Trắc Nghiệm Việt duyệt về hình thức và chất lượng giảng dạy. Vì vậy anh chị hãy điền link này để đăng ký được duyệt nhanh nhất nhé.
Anh chị cũng nên mô tả kỹ về kinh nghiệm giảng dạy để Trắc Nghiệm Việt đánh giá nhé.
Chúc các anh chị và các bạn thành công, sớm gia nhập đội ngũ giảng viên Trắc Nghiệm Việt!
200,000 VNĐ
1,099,000 VNĐ
Tổng quan khóa học
- Bài học 35
- Thời gian Linh hoạt
- Mức độ Mới bắt đầu
- Ngôn ngữ Tiếng việt
- Chứng chỉ Không
Trần Văn Điệp
Founder tại QViet.vn