0% found this document useful (1 vote)
77 views

Muhammad Samhan Bin Azamain (01-060156) - BIT 13/02 Database System Class Activity 3

The document provides 11 SQL questions to create and populate database tables to store supplier and product data. It defines the structure of Suppliers and Products tables with primary and foreign keys. It then asks to write SQL statements to insert data into the tables, update column names and data types, rename a table, and write a query.

Uploaded by

Muhammad Samhan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
77 views

Muhammad Samhan Bin Azamain (01-060156) - BIT 13/02 Database System Class Activity 3

The document provides 11 SQL questions to create and populate database tables to store supplier and product data. It defines the structure of Suppliers and Products tables with primary and foreign keys. It then asks to write SQL statements to insert data into the tables, update column names and data types, rename a table, and write a query.

Uploaded by

Muhammad Samhan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

1|Page

Muhammad Samhan Bin Azamain (01-060156). BIT 13/02 Database System Class Activity 3.
QUESTIONS 1. Write the SQL code that will create a database Supplier_Details. 2. Create a Suppliers table that stores Supplier_Id, Supplier_Name and Contact_Person information. The Primary Key for the Suppliers table should be the supplier_Id. Suppliers Supplier_Id int PK Supplier_Name varchar(50) NOT NULL Contact_Person varchar(25) 3. Create a Products table that stores Product_Id, Product_Name, Supplier_Id and Price information. The primary key for the Products table should be the Product_Id. Create a Foreign Key on the Products table that references the Suppliers table based on the Supplier_Id field. Products Product_Id int PK Product_Name varchar(50) NOT NULL Supplier_Id int FK Price decimal(6,2) 4. Having created the table structure in Question 2, write the SQL code that will enter the rows into the table. Supplier_Id Supplier_Name Contact Person 1 Apple Mr. Chan Zhao Zhang 2 Hewlett-Packard Mr. Amru Abdul Bari 3 Philips NULL 5. Having created the table structure in Question 3, write the SQL code that will enter the rows into the table. Product_Id Product_Name Supplier_Id Price 1 LCD 14 inch 2 1325 2 LCD 32 inch 1 1789 3 CRT Monitor 2 2000 6. Write the SQL code that will change the column named Price in the table Products to a column named Product_Price. 7. Write the SQl code that will change the type of Product_Price column to integer. 8. Modify your table definition using the Alter command to rename the table Suppliers to Suppliers_Details. 9. Write the SQl code to change the Contact_Person to Mrs. Sao Yijia for the person whose Supplier_Id is 1.

2|Page 10. Write the SQl code to add Mr. Lesindamu Sihofu into Philips Contact_Person. 11. Write SQL statement to retrieve a list of Product_Name and Supplier_Name where product is LCD 14 inch.

You might also like