0% found this document useful (0 votes)
6 views

week10

Lab #10 for CS246 focuses on advanced SQL concepts, requiring students to create and populate various database tables and implement triggers using MySQL. The lab consists of multiple tasks, including creating tables for student data, courses, grades, and developing triggers for insert, update, and delete actions. Students must submit their SQL statements in a specified format by the deadline, adhering to independent effort guidelines.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

week10

Lab #10 for CS246 focuses on advanced SQL concepts, requiring students to create and populate various database tables and implement triggers using MySQL. The lab consists of multiple tasks, including creating tables for student data, courses, grades, and developing triggers for insert, update, and delete actions. Students must submit their SQL statements in a specified format by the deadline, adhering to independent effort guidelines.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

CS246: Database Management Systems Lab

Lab # 10 (1 Questions, 142 Points)


Held on 27-Mar-2023
Lab Timings: 14:00 to 18:00 Hours Pages: 4
Submission: 18:00 Hrs, 27-Mar-2023
Instructors Dr. V. Vijaya saradhi & Prof. Jatindra Kumar Deka
Head TAs Adithya Moorthy & Laxita Agrawal
Department of CSE, IIT Guwahati

a. This lab assignment is based on the concepts covered in chapter 5 Advanced SQL in
the CS245 theory class.
b. You can refer to the text book for SQL syntax.
Question 1: (142 points)
triggers Using MySQL perform the following tasks:
Task 01 (1 mark) Create a database named week10
Task 02 (8 marks) Create tables
a. (1 mark) A table student18 containing the following
1st column name string of characters of fixed size 100
nd
2 column roll number string of characters of fixed size 10
3rd column cpi float
with roll number as primary key. Default value of cpi to be 0.0.
b. (1 mark) A table course18 containing the following
1st column semester integer
2nd column cid string of characters of fixed size 7
3rd column name string of characters of fixed size 100
th
4 column l integer
5th column t integer
th
6 column p integer
th
7 column c integer
with cid as primary key.
c. (1 mark) A table grade18 containing the following
1st column roll number string of characters of fixed size 10
nd
2 column cid string of characters of fixed size 7
3rd column letter grade string of characters of fixed size 2
with roll number and cid together form primary key
d. (1 mark) A table curriculum containing the following
1st column dept string of characters of fixed size 4
2nd column number integer
3rd column cid string of characters of fixed size 7
e. (1 mark) A table grade point containing the following
1st column letter grade string of characters of fixed size 2
2nd column value integer
With the constraint that letter grade to be primary key.
f. (1 mark) A table trigger log containing the following
1st column my action string of characters of fixed size 10
nd
2 column roll number string of characters of fixed size 10
3rd column semester integer
th
4 column SPI decimal with precision 2
th
5 column CPI decimal with precision 2
i. my action must take values from the set {’INSERT’, ’UPDATE’, ’DELETE’}.
ii. semester a foreign key pointing to course18(semester).
g. (1 mark) A table transcript containing the following
1st column roll number string of characters of fixed size 10
2nd column semester integer
3rd column SPI decimal with precision 2
th
4 column CPI decimal with precision 2
h. (1 mark) A table u grade18 whose description is identical to grade18 table.
Task 03 (6 marks) populate data
a. (1 mark) Populate data from file student18.csv into table student18
b. (1 mark) Populate data from file course18.csv into table course18
c. (1 mark) populate data from the file curriculum.csv into table curriculum
d. (1 mark) populate data from the file u grade18.csv into table u grade18 table.
e. (1 mark) populate grade point table with the following values:

letter grade AS AA AB BB BC CC CD DD FP FA I X PP NP
value 10 10 9 8 7 6 5 4 0 0 0 0 0 0
f. (1 mark) populate data from the file transcript.csv into table transcript
table.
Task 04 (120 marks) Develop the following triggers on table grade18 with the follow-
ing specifications:
a. (40 marks) Insert triggers
i. (5 marks) before insert Before a new row is inserted into grade18 table,
perform the following: If the letter grade is not in the set of allowable
grades {AS, AA, AB, BB, BC, CC, CD, DD, FP, FA, PP, NP, I, X} then,
the new insertion should not take place. That is generate SIGNAL STATE
with number 50001 with appropriate message.
ii. (35 marks) after insert After the new row is inserted into grade18 table,
perform the following:
i. (30 marks) Perform update in the transcript table for INSERT action
on grade18 table.

Page 2
ii. (5 marks) Perform insertion in the trigger log table with my action
as ’INSERT’ and rest of the columns as appropriate. Example
A. After insertion into grade18 table
insertion into grade18
180101002 MA101 AA
B. Output in trigger log table
trigger log entry on insertion into grade18
my action roll number semester SPI CPI
INSERT 180101002 1 10.00 10.00
C. Output in transcript table
transcript update on insertion into grade18
roll number semester SPI CPI
180101002 1 10.00 10.00
b. (40 marks) Update triggers
i. (5 marks) before update Before a row is updated in the grade18 table,
perform the following: If the updated letter grade is not in the set of
allowable grades {AS, AA, AB, BB, BC, CC, CD, DD, FP, FA, PP, NP, I,
X} then, the new updation should not take place. That is generate SIGNAL
STATE with number 50001 with appropriate message.
ii. (35 marks) after update: After updating the grade18 table, perform the
following:
i. (30 marks) Perform update in the transcript table for the UPDATE
action on grade18 table.
ii. (5 marks) Perform insertion in the trigger log table with my action
as ’UPDATE’ and rest of the columns as appropriate.
c. (40 marks) Delete trigger
i. (40 marks) after deletion After a row is deleted from the grade18 table,
perform the following
i. (35 marks) Perform update in the transcript table for the DELETE
action on grade18 table.
ii. (5 marks) Perform insertion in the trigger log table with my action
as ’DELETE’ and rest of the columns as appropriate.
Task 05 (1 mark) Only after installing the above three triggers, populate data from
file grade18.csv into table grade18
Task 06 (5 marks) update grade18 records table as per u grade18 records.
Task 07 (1 mark) delete all the records from grade18 table.
Instructions Adhere to the following
SQL statements Write the SQL statements corresponding to each task in a text.
File naming text file name should be [Your roll number].sql
Independent efforts You should make an honest and independent effort in ob-
taining the solution to the above problem.

Page 3
Mobile phones are not allowed inside the lab
Submission Procedure You should upload all the SQL files and python script files in
MS assignments site.
Marking Scheme Mentioned against each task/sub task

Page 4

You might also like