Cong Minh CDROM 70 NCT F2 Q10
SQL Server 2000
Exercise 1: Advanced Query
-----Week 4-----
Please follow those steps to practise:
1. Create a new database called PracticeDB (using Enterprise Manager (EP)
or Query Analyser (QA))
2. Create 2 tables and insert data as follows (use EP or QA) :
Customers
CustomerID
(Int)
Name
(nVarChar(50))
1 John Nguyen
2 Bin Laden
3 Bill Clinton
4 Thomas Hardy
5 Ana Tran
6 Bob Carr
Orders
OrderID
(Int)
CustomerID
(Int)
ProductName
(nvarchar(50))
DateProcessed
(datetime)
1 2 Nuclear Bomb ‘2002-12-01’
2 3 Missile ‘2000-03-02’
3 2 Jet-1080 ‘2003-08-03’
b. Apply the Foreign Key Constraint in the Orders table.
c. Apply the Check Constraint to the DateProcessed column so that the
date is within ‘1970-01-01’ – ‘2005-01-01’ and try to insert invalid data to
see if SQL rejects.
d. Apply Unique Constraint to the CustomerName column of Customers
9. Back up database and Restore to somewhere else (on a different server or
on the same server but with different database name) (use EP or QA)
10. Truncate and Drop the ProcessedOrders table (use QA)
Cong Minh CDROM 70 NCT F2 Q10