CS403 Assignment No. 5 solution
Monday, July 04, 2011 Posted In CS and IT Edit ThisSolution:
1. Create a view to show all the supplier names along with their Supplier IDs
Answer: SELECT [supplier-name],[supplier-ID] FROM supplier
2. Create a view to show the supplier name and supplier ID, who provide the product “Mirrors”.
Answer:
SELECT [supplier-name],[supplier-ID] FROM product, category, supplier
WHERE supplier.[supplier-ID] = category.[supplier-ID] and
category.[category-ID] = product.[category.ID] and
product. product-name = “Mirrors”
3. Create a view to list down all the product names with their category names
Answer:
SELECT [product-name],[category-name] FROM product, category
WHERE product.[category-ID] = category.[category-ID]
4. Update view to change the Supplier name from “AB Hardwares” to “Uplink Hardwares”.
Answer:
UPDATE supplier SET supplier-name = “Uplink Hardwares”
WHERE supplier-name = “AB Hardwares”
::::::::::::::::::::::::::::::::::
Write SQL statements/queries for each of individual scenario given below from the given tables on the next page.
Solution:
1.Create a view to show all the supplier names along with their Supplier IDs
CREATE VIEW sup_view AS (SELECT supplier_name, supplier_id
FROM supplier)
2.Create a view to show the supplier name and supplier ID, who provide the product “Mirrors”.
CREATE VIEW sup_pro_cat_view AS (SELECT supplier_name, supplier_id
FROM supplier, category, product
WHERE supplier.supplier_id = category.supplier_id
AND category.category_id = product.category_id
AND product.product_name = “Mirrors”)
3.Create a view to list down all the product names with their category names.
CREATE VIEW pro_cat_view (SELECT product_name, caregory_name
FROM product, category
WHERE product.category_id = caregory.category_id)
4.Update view to change the Supplier name from “AB Hardwares” to “Uplink Hardwares”.
UPDATE pro_view set supplier_name = “Uplink Hardwares”
WHERE supplier_name = “AB Hardwares”