Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Ex.

1
1. Create a table ‘Product’ with attributes and data type respectively.
Product (Id integer, Brand varchar(30), Model_Number varchar(20), Price integer);
2. Insert data into ‘Product’ table. The legal values for Brand must be as follow: (‘Samsung’, ‘Huawei’,
‘Vivo’, ‘Oppo’). Any other insertion into Brand is not allowed except these legal values.

Id Brand Model_Number Price

1 Samsung Grand2 250000

2 Samsung A3 350000

3 Huawei P8 350000

4 Vivo Y15 120000

5 Oppo Neo7 180000

3. Create another table ‘Product_Info’ with field names and data types respectively.
Product_Info (Model_Number varchar(20), Old_Price integer, New_Price integer);
4. Create trigger, ‘Product_Trigger’, on table ‘Product’. This trigger fired automatically AFTER
UPDATE operation is performed on table ‘Product’. Furthermore, the update record is inserted into
table ‘Product_Info’.
5. Change the price of Grand2 to 200000.
6. Get query to view Product_Info table.
7. Drop the trigger, ‘Product_Trigger’.

*************************
Ex.2

1. Create a table ‘Course’ with attributes and data type respectively.


Course (Cid varchar(5), Course_Name varchar(30), Department varchar(30));
2. Insert data into ‘Course’ table. The legal values for Department must be as follow: (‘Software’,
‘Hardware’, ‘Information Science’, ‘Application’, ‘Language’, ‘Natural Science’, ‘Computing’).
Any other insertion into Department is not allowed except these legal values.

Cid Course_Name Department

C1 Computer Fundamental Software

C2 Fundamental Network Hardware

C3 Fundamental Database Information Science

C4 Javascript Application

C5 Software Engineering Information Science

3. Create another table ‘Course_Info’ with field names and data types respectively.
Course_Info (Cid varchar(5), Old_Course_Name varchar(30), New_Course_Name varchar(30));
4. Create trigger, ‘Course_Trigger’, on table ‘Course’. This trigger fired automatically AFTER
UPDATE operation is performed on table ‘Course’. Furthermore, the update record is inserted into
table ‘Course_Info’.
5. Change the course name of C1 from Computer Fundamental to Data Structure.
6. Get query to view Course_Info table.
7. Drop the trigger, ‘Course_Trigger’.

You might also like