Uploaded by syedaliasad644

SP21-BCS-036

advertisement
DATA WAREHOUSE AND DATA MINING
Spring 2023
Assignment 1
Submitted By:
Syed Ali Asad
SP21-BCS-036
Class & Section:
BCS-5D
Supervisor:
“Dr. Amjad Usman”
Department of Computer Science
COMSATS University Islamabad
Wah Campus
COMSATS University Islamabad, Wah Campus
Department of Computer Science, Spring 2023 Semester
CSC496 Data Warehousing & Data Mining
Assignment No.1
Due date: 19th March 2023
Student Result Management System (SRMS)
Create SRMS Database:
Connect to MySQL DBMS.
Write SQL command to create database dbSRMS.
CREATE DATABASE dbSRMS;
Create a new table to store the information of each course. The schema of course table is given below.
Table No.1
Course
Fields
Description
crCode
text datatype, size 6 characters, make it primary key
crTitle
text datatype, size 30 characters, title of each course must be provided
crCreditHour
integer datatype, one digit value that can be 3,4,or 6.
Complete the SQL query to create course table.
CREATE TABLE Course (
crCode
crTitle
crCreditHour
);
Create a new table to store the information of each teacher. The schema of Teacher table is given below.
Table No.2
Teacher
Field
Description
trCode
Text datatype, size 6 characters, set as primary key
trName
Text datatype, size 30 characters, name must be stored
trGender
Text datatype, size single character either M or F, Set Male as default
trDesignation
Text datatype, size 20 characters
trDept
Text data type, size 20 characters
Complete the SQL query to create teacher table.
CREATE TABLE Teacher (
trCode
trName
trGender
trDesignation
trDept
);
Create a new table to store the information of each student. The schema of student table is given below.
Table No.3
Student
Field
Description
stRegNo
Text datatype, size 12 characters
stName
Text datatype, size 30 characters
stGender
Text datatype, size single character either M or F, Set Male as default
stProgram
Text datatype, size 03 characters
stCity
Text datatype, size 30 characters
Complete the SQL query to create student table.
CREATE TABLE Student (
stRegNo
stName
stGender
stProgram
stCity
);
Create a new table to store the information of each student. The schema of student table is given below.
Table No.4
Result
Field
Description
semester
Text datatype, size 4 characters, required field
crClass
Text datatype, size 6 characters like BCS-5D
crCode
Text datatype, size 6 characters, mandatory field
trCode
Text datatype, size 6 characters, must not accept null
stRegNo
Text datatype, size 12 characters, must be provided
marks
Integer values ranging between 0 and 100
grade
Text datatype, size 2 characters maximum
Complete the SQL query to create student table.
CREATE TABLE Result (
semester
crClass
crCode
trCode
stRegNo
marks
grade
);
The primary key for result tabl e will be composite including semester, crCode and stRegNo.
Complete the given SQL statement to add primary constraint on the result table.
ALTER TABLE Result
ADD CONSTRAINT ………………………………
The result table has relationship with course, student, and teacher tables. Let’s link these tables one by one.
1. Create relationship between result and course tables using course code. Insert foreign key constraint on CrCode
column in result table. Complete the given SQL command to do so.
ALTER TABLE Result
ADD CONSTRAINT …….. FOREIGN KEY ……………..
ON UPDATE CASCADE;
2. Create relationship between result and teacher tables using teacher code. Insert foreign key constraint on trCode
column in result table. Complete the given SQL command to do so.
ALTER TABLE Result
ADD CONSTRAINT …….. FOREIGN KEY ……………..
ON UPDATE CASCADE;
3. Create relationship between result and student tables using teacher code. Insert foreign key constraint on stRegNo
column in result table. Complete the given SQL command to do so.
ALTER TABLE Result
ADD CONSTRAINT …….. FOREIGN KEY ……………..
ON UPDATE CASCADE;
Now the SRMS database is ready to store data about courses, course instructors, enrolled students, and their results.
Data Loading in the database:
Insert data of at least 5 courses.
INSERT INTO Course
VALUES (…………………………..),
VALUES (…………………………..),
VALUES (…………………………..),
VALUES (…………………………..),
VALUES (…………………………..);
Insert data of at least 5 teaches.
INSERT INTO Teacher
VALUES (…………………………..),
VALUES (…………………………..),
VALUES (…………………………..),
VALUES (…………………………..),
VALUES (…………………………..);
Insert data of at least 15 students. You may consider the students of your own class.
INSERT INTO Student
VALUES (…………………………..),
VALUES (…………………………..),
VALUES (…………………………..),
VALUES (…………………………..),
VALUES (…………………………..);
Consider that each student has registered 5 courses. So insert marks of each student in each course. There should be at
least 5 x 15 = 75 result entries in the result table.
INSERT INTO Result
VALUES (…………………………..),
VALUES (…………………………..),
VALUES (…………………………..),
VALUES (…………………………..),
VALUES (…………………………..);
Now, the database is ready to be used for data analysis.
Result's Analysis
-- Show result of SP 2021 semester.
SELECT ………………
FROM Result
……………………..
-- find students who failed in SP 2021 semester. Hint: use grade column.
SELECT ………………………
FROM Result
…………………………
How much time it took in query execution? 0.00Sec
-- find students who failed in SP 2021 semester. Hint: use marks column.
SELECT …………..
FROM Result ……………….
How much time it took in query execution? 0.00Sec
-- For SP 2021 semester, find Fail count in each course.
SELECT …………
FROM Result ……………..
-- find grade count for SP 2021 semester.
SELECT ………..
FROM Result …………………
-- find grade count report for each course.
SELECT ……………
FROM Result ………………..
-- find grade count summary of each course for every teacher.
SELECT ……………………
FROM Result ………………
-- which course has the highest Fail count?
SELECT ………………..
FROM Result ……………….
-- create a new table to store the grade summary of each course for every teacher.
CREATE TABLE GradeSummary AS
SELECT …………………..
FROM Result ………………….
-- get data from view
SELECT * FROM GradeSummary;
-- how many A grades are given by every teacher in each course?
SELECT *
FROM GradeSummary
WHERE grade = 'A';
You can add more management queries of your choice .
Download