Assignment

CLICK HERE TO DOWNLOAD THIS TUTORIAL INSTANTLY $38 Only

Part 1
1. You are asked to create a new table called “part2” which has the same column definitions as the table “part” you created in assignment2. However, you should not copy the data contained in the course. How do you create a copy of the “part” table without copying its data contents (4 marks)?
2. What is the length of values defined for city column. Modify the length of “city” in the table “suppliers” (4 marks).
3. Are there any constraints defined for the above tables (table suppliers (S), supplier-part (SP), parts? (P) In order to find out, try to search through the USER_CONSTRAINTS table. ( 4 marks)
4. Add the following constraints for the tables (each 3 marks, total 18 marks):
– s# is the primary key for table “S”
– s#, p# is the primary key for the table “SP”
-p# in table “P” should be unique
– the primary key of the “S” table is posted as foreign key in the tables “SP”
– SNAME in table “S” may not be NULL
– the columns “qty” in table “SP”, “weight” in table “P” should be larger than 0.
For part 1, turn in a copy of all of your SQL commands

Part 2
Write appropriate SQL for the following English queries. Use the SPJ datasheet for reference (each carries 5 marks, total 70 marks)
1. Get the names of parts whose weight is between 10 and 15
2 Which supplier supplied what parts to the ‘Sorter’ job?
3. Which jobs require red parts?
4. Get the names of the suppliers who never supplied anything in 1999
5. Which supplier supplied the most parts ever?
6. What is the total quantity of parts ordered for the ‘Sorter’ job?
7. What are the parts that ‘Adam’ ever supplied?
8. What is the most recently shipped job?
9. What is the total weight of a ‘Terminal’?
10. Which supplier has the lowest status?
11. What is the total weight of all the parts?
12. Which of the jobs had all the parts from the same city?
13. Get the names of the parts required to finish the ‘Tape’ job
14. Which city had the maximum number of parts originating from it?
For part 2, you only need to type in your SQL statements